diff --git a/src/main/java/com/jesuspinar/webserver/Manager.java b/src/main/java/com/jesuspinar/webserver/Manager.java index c936771..7a3335c 100644 --- a/src/main/java/com/jesuspinar/webserver/Manager.java +++ b/src/main/java/com/jesuspinar/webserver/Manager.java @@ -11,15 +11,26 @@ import java.time.format.DateTimeFormatter; public class Manager { @GetMapping({"/", "", "/index"}) public String welcome(Model model){ + loadTheme(model); model.addAttribute("mesage", "Hello"); return "index"; } @GetMapping("/hour") public String hour(Model model){ + loadTheme(model); + return "time"; + } + + private void loadTheme(Model model) { DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm:ss"); model.addAttribute("dateTime", dtf.format(LocalDateTime.now())); -// model.addAttribute("bg", "dark"); - return "time"; + DateTimeFormatter hour = DateTimeFormatter.ofPattern("HH"); + int h = Integer.parseInt(hour.format(LocalDateTime.now())); + String bg = "light"; + if (h >= 20 || h <= 7){ + bg = "dark"; + } + model.addAttribute("background", bg); } } diff --git a/src/main/resources/css/style.css b/src/main/resources/css/style.css deleted file mode 100644 index 727855e..0000000 --- a/src/main/resources/css/style.css +++ /dev/null @@ -1 +0,0 @@ -html{background: slategrey} \ No newline at end of file diff --git a/src/main/resources/static/css/style.css b/src/main/resources/static/css/dark.css similarity index 68% rename from src/main/resources/static/css/style.css rename to src/main/resources/static/css/dark.css index 5b9e0af..cdfa4fb 100644 --- a/src/main/resources/static/css/style.css +++ b/src/main/resources/static/css/dark.css @@ -2,7 +2,3 @@ body{ background-color: slategrey; color: white; } - -h1{ - font-size: 4rem; -} \ No newline at end of file diff --git a/src/main/resources/static/css/light.css b/src/main/resources/static/css/light.css new file mode 100644 index 0000000..8d995f0 --- /dev/null +++ b/src/main/resources/static/css/light.css @@ -0,0 +1,4 @@ +body{ + background-color: aliceblue; + color: dimgray; +} \ No newline at end of file diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index dd9e712..6f571a0 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -4,7 +4,7 @@ - + Index diff --git a/src/main/resources/templates/time.html b/src/main/resources/templates/time.html index 510f603..66b807f 100644 --- a/src/main/resources/templates/time.html +++ b/src/main/resources/templates/time.html @@ -4,7 +4,8 @@ - + + Time