diff --git a/pom.xml b/pom.xml index 3225bb6..2ee3ac9 100644 --- a/pom.xml +++ b/pom.xml @@ -25,6 +25,15 @@ org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-data-jpa + + + com.h2database + h2 + runtime + org.springframework.boot diff --git a/src/main/java/dev/araozu/jerguero/GreetingController.java b/src/main/java/dev/araozu/jerguero/GreetingController.java index db16469..37018cc 100644 --- a/src/main/java/dev/araozu/jerguero/GreetingController.java +++ b/src/main/java/dev/araozu/jerguero/GreetingController.java @@ -1,5 +1,6 @@ package dev.araozu.jerguero; +import org.springframework.context.annotation.Bean; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; diff --git a/src/main/java/dev/araozu/jerguero/controller/post/PostController.java b/src/main/java/dev/araozu/jerguero/controller/post/PostController.java new file mode 100644 index 0000000..7321212 --- /dev/null +++ b/src/main/java/dev/araozu/jerguero/controller/post/PostController.java @@ -0,0 +1,34 @@ +package dev.araozu.jerguero.controller.post; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.*; + +@Controller +public class PostController { + @GetMapping("/crear") + public String createEntry() { + return "post/create"; + } + + @RequestMapping( + value = "/crear", + method = RequestMethod.POST, + consumes = "application/x-www-form-urlencoded", + params = {"definition-title", "definition-content"} + ) + public String createEntryPost( + @RequestParam("definition-title") String title, + @RequestParam("definition-content") String content, + Model model + ) { + model.addAttribute("title", title); + model.addAttribute("content", content); + return "post/create_result"; + } +} + + +class PostInfo { + +} diff --git a/src/main/java/dev/araozu/jerguero/model/Post.java b/src/main/java/dev/araozu/jerguero/model/Post.java new file mode 100644 index 0000000..8114024 --- /dev/null +++ b/src/main/java/dev/araozu/jerguero/model/Post.java @@ -0,0 +1,44 @@ +package dev.araozu.jerguero.model; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +@Entity +public class Post { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + private String title; + private String content; + + protected Post() { + } + + public Post(String title, String content) { + this.title = title; + this.content = content; + } + + @Override + public String toString() { + return String.format( + "Post[id=%d, title='%s', content='%s']", + id, title, content + ); + } + + public Long getId() { + return id; + } + + public String getTitle() { + return title; + } + + public String getContent() { + return content; + } +} diff --git a/src/main/java/dev/araozu/jerguero/model/PostRepository.java b/src/main/java/dev/araozu/jerguero/model/PostRepository.java new file mode 100644 index 0000000..715e27d --- /dev/null +++ b/src/main/java/dev/araozu/jerguero/model/PostRepository.java @@ -0,0 +1,13 @@ +package dev.araozu.jerguero.model; + +import org.springframework.data.repository.CrudRepository; + +import java.util.List; + +public interface PostRepository extends CrudRepository { + + List findByTitle(String title); + + Post findById(long id); + +} diff --git a/src/main/resources/frontend/main.css b/src/main/resources/frontend/main.css index a5e846c..8020105 100644 --- a/src/main/resources/frontend/main.css +++ b/src/main/resources/frontend/main.css @@ -16,9 +16,20 @@ --c-on-bg: white; } +/* Light theme */ +@media (prefers-color-scheme: light) { + :root { + --c-bg: white; + --c-on-bg: black; + } +} html { background-color: var(--c-bg); color: var(--c-on-bg); } + +body { + font-family: Rubik, sans-serif; +} diff --git a/src/main/resources/frontend/tailwind.config.js b/src/main/resources/frontend/tailwind.config.js index 37e9f96..24f2604 100644 --- a/src/main/resources/frontend/tailwind.config.js +++ b/src/main/resources/frontend/tailwind.config.js @@ -19,7 +19,8 @@ module.exports = { "c-chicha-orange": "var(--chicha-orange)", }, fontFamily: { - "chicha": ["Lobster", "sans-serif"], + "chicha": ["Lobster", "serif"], + "rubik": ["Rubik", "sans-serif"], } }, plugins: [], diff --git a/src/main/resources/static/index.html b/src/main/resources/static/index.html index d7f5609..73e0527 100644 --- a/src/main/resources/static/index.html +++ b/src/main/resources/static/index.html @@ -1,5 +1,5 @@ - + - +