diff --git a/src/main/java/id/my/luxic/pastebin/controller/HomeController.java b/src/main/java/id/my/luxic/pastebin/controller/HomeController.java new file mode 100644 index 0000000..ee179ec --- /dev/null +++ b/src/main/java/id/my/luxic/pastebin/controller/HomeController.java @@ -0,0 +1,32 @@ +package id.my.luxic.pastebin.controller; + +import id.my.luxic.pastebin.model.Paste; +import id.my.luxic.pastebin.service.PasteService; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; + +@Controller +public class HomeController { + + private final PasteService service; + + public HomeController(PasteService service) { + this.service = service; + } + + @GetMapping("/") + public String home(Model model) { + model.addAttribute("message", "Hello, Thymeleaf!"); + return "index"; + } + + @GetMapping("/paste/{id}") + public String paste(Model model, @PathVariable String id) { + Paste paste = service.findById(id); + model.addAttribute("paste", paste); + return "paste"; + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index d11cc43..ae31c10 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -4,4 +4,6 @@ spring.datasource.url=jdbc:postgresql://localhost:5432/pastebin spring.datasource.username=postgres spring.datasource.password=password -spring.jpa.hibernate.ddl-auto=update \ No newline at end of file +spring.jpa.hibernate.ddl-auto=update +spring.thymeleaf.cache=false +spring.devtools.livereload.enabled=true \ No newline at end of file diff --git a/src/main/resources/templates/fragments/header.html b/src/main/resources/templates/fragments/header.html new file mode 100644 index 0000000..14fed38 --- /dev/null +++ b/src/main/resources/templates/fragments/header.html @@ -0,0 +1,30 @@ + + +
+ ... + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html new file mode 100644 index 0000000..8193874 --- /dev/null +++ b/src/main/resources/templates/index.html @@ -0,0 +1,10 @@ + + + +This is a message
+ + \ No newline at end of file diff --git a/src/main/resources/templates/paste.html b/src/main/resources/templates/paste.html new file mode 100644 index 0000000..74c7444 --- /dev/null +++ b/src/main/resources/templates/paste.html @@ -0,0 +1,13 @@ + + + +This is a message
+ + \ No newline at end of file