diff --git a/src/main/java/ru/mcs/sopds/controller/WebController.java b/src/main/java/ru/mcs/sopds/controller/WebController.java index 321a2ba..68abfd2 100644 --- a/src/main/java/ru/mcs/sopds/controller/WebController.java +++ b/src/main/java/ru/mcs/sopds/controller/WebController.java @@ -1,5 +1,6 @@ package ru.mcs.sopds.controller; +import jakarta.servlet.http.HttpServletRequest; import ru.mcs.sopds.entity.*; import ru.mcs.sopds.service.BookService; import lombok.RequiredArgsConstructor; @@ -10,6 +11,7 @@ import org.springframework.ui.Model; import org.springframework.web.bind.annotation.*; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -21,7 +23,13 @@ private final BookService bookService; @GetMapping("/") - public String home(Model model) { + public String mainPage(Model model, HttpServletRequest request) { + // Основные данные для главной страницы + model.addAttribute("appTitle", "Simple OPDS Catalog"); + model.addAttribute("breadcrumbs", Arrays.asList("Главная")); + model.addAttribute("currentPath", request.getRequestURI()); + model.addAttribute("request", request); + // Статистика Map stats = new HashMap<>(); stats.put("booksCount", bookService.getBooksCount()); @@ -30,11 +38,10 @@ stats.put("genresCount", bookService.getGenresCount()); model.addAttribute("stats", stats); - model.addAttribute("recentBooks", bookService.getRecentBooks(8)); - model.addAttribute("popularGenres", bookService.getPopularGenres(10)); - model.addAttribute("topGenres", bookService.getPopularGenres(5)); + model.addAttribute("recentBooks", bookService.getRecentBooks(12)); + model.addAttribute("popularGenres", bookService.getPopularGenres(8)); - return "index"; + return "main"; } @GetMapping("/books") diff --git a/src/main/java/ru/mcs/sopds/dto/SystemMessage.java b/src/main/java/ru/mcs/sopds/dto/SystemMessage.java new file mode 100644 index 0000000..2ff012a --- /dev/null +++ b/src/main/java/ru/mcs/sopds/dto/SystemMessage.java @@ -0,0 +1,16 @@ +package ru.mcs.sopds.dto; + +import lombok.Data; + +@Data +public class SystemMessage { + private String type; // success, warning, alert, primary + private String title; + private String text; + + public SystemMessage(String type, String title, String text) { + this.type = type; + this.title = title; + this.text = text; + } +} \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 2d2cc6b..d9d32e8 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -23,6 +23,12 @@ cache: false prefix: classpath:/templates/ + web: + resources: + static-locations: classpath:/static/ + mvc: + static-path-pattern: /** + server: port: 8080 diff --git a/src/main/resources/templates/fragments/breadcrumbs.html b/src/main/resources/templates/fragments/breadcrumbs.html new file mode 100644 index 0000000..2c6ce9a --- /dev/null +++ b/src/main/resources/templates/fragments/breadcrumbs.html @@ -0,0 +1,21 @@ + + + +
+ +
+ + \ No newline at end of file diff --git a/src/main/resources/templates/fragments/footer.html b/src/main/resources/templates/fragments/footer.html new file mode 100644 index 0000000..dc118a9 --- /dev/null +++ b/src/main/resources/templates/fragments/footer.html @@ -0,0 +1,20 @@ + + + +
+
+
+
+

© 2024 Simple OPDS Catalog. Java Spring Boot Version.

+
+ +
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/fragments/logo.html b/src/main/resources/templates/fragments/logo.html new file mode 100644 index 0000000..3da6334 --- /dev/null +++ b/src/main/resources/templates/fragments/logo.html @@ -0,0 +1,14 @@ + + + +
+
+ + SOPDS + +

Simple OPDS Catalog

+

Версия на Java Spring Boot

+
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/fragments/menu.html b/src/main/resources/templates/fragments/menu.html new file mode 100644 index 0000000..1cceca7 --- /dev/null +++ b/src/main/resources/templates/fragments/menu.html @@ -0,0 +1,48 @@ + + + +
+ +
+ + \ No newline at end of file diff --git a/src/main/resources/templates/fragments/messages.html b/src/main/resources/templates/fragments/messages.html new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/main/resources/templates/fragments/messages.html diff --git a/src/main/resources/templates/fragments/top.html b/src/main/resources/templates/fragments/top.html new file mode 100644 index 0000000..e3fc343 --- /dev/null +++ b/src/main/resources/templates/fragments/top.html @@ -0,0 +1,35 @@ + + + +
+
+
+ +
+ +
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/main.html b/src/main/resources/templates/main.html new file mode 100644 index 0000000..556d743 --- /dev/null +++ b/src/main/resources/templates/main.html @@ -0,0 +1,105 @@ + + + + + + + SOPDS + + + + + + + + +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+
+ + + + + + +
+ + \ No newline at end of file diff --git a/src/main/resources/templates/test-main.html b/src/main/resources/templates/test-main.html new file mode 100644 index 0000000..6045dad --- /dev/null +++ b/src/main/resources/templates/test-main.html @@ -0,0 +1,84 @@ + + + + Главная - SOPDS + + +
+ +
+
+
+ 0 + Книг +
+
+
+
+ 0 + Авторов +
+
+
+
+ 0 + Серий +
+
+
+
+ 0 + Жанров +
+
+
+ + +
+
+

Последние добавленные книги

+
+
+
+
+ Название книги +
+
+ Автор: Автор +
+
+ Формат: fb2 +
+ + Подробнее + +
+
+
+
+
Книги не найдены
+

В библиотеке пока нет книг. Добавьте книги в папку сканирования.

+
+
+
+ + +
+
+

Популярные жанры

+ +
+
+
+ + \ No newline at end of file