personalweb

archived
git clone git://git.wimdupont.com/personalweb.git
Log | Files | Refs | LICENSE

commit ef98881f05cbe1c159e2e5143e0241673f82304e
parent 51b22052b9185b50d4d81d8ff9ec7fcf5ada0d84
Author: Wim Dupont <wim@wimdupont.com>
Date:   Sun, 13 Feb 2022 12:01:42 +0100

updated booklist styling and layout


Former-commit-id: 4a958d6ef1d5beed1f3adc6cae2e47363e6658e1
Diffstat:
Msrc/main/java/com/wimdupont/personalweb/controller/BookController.java | 10+++++++---
Msrc/main/resources/db/migration/repeatable/R__fill_book_table.sql | 6+++---
Msrc/main/resources/static/css/main.css | 20+++++++++++++-------
Msrc/main/resources/templates/books.html | 29++++++++++++++---------------
4 files changed, 37 insertions(+), 28 deletions(-)

diff --git a/src/main/java/com/wimdupont/personalweb/controller/BookController.java b/src/main/java/com/wimdupont/personalweb/controller/BookController.java @@ -9,7 +9,9 @@ import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; @Controller @@ -23,10 +25,12 @@ public class BookController { @GetMapping @SuppressWarnings("unused") public String getBooks(Model model) { - List<BookDto> bookDtoList = bookService.findAllSorted().stream() + Map<String, List<BookDto>> books = bookService.findAllSorted().stream() .map(bookToBookDtoConverter::convert) - .collect(Collectors.toList()); - model.addAttribute("books", bookDtoList); + .collect(Collectors.groupingBy(BookDto::getCategory, + LinkedHashMap::new, + Collectors.mapping(book -> book, Collectors.toList()))); + model.addAttribute("books", books); return "books"; } diff --git a/src/main/resources/db/migration/repeatable/R__fill_book_table.sql b/src/main/resources/db/migration/repeatable/R__fill_book_table.sql @@ -10,10 +10,10 @@ INSERT INTO book VALUES (UUID(), "Java How to Program, Seventh Edition", "Harvey M. Deitel, Paul J. Deitel", "9780132222204", "Programming: Java", null, null), (UUID(), "The C Programming Language, 2nd Edition ", "Brian Wilson Kernighan, Dennis MacAlistair Ritchie", "9780131103627", "Programming: C", null, null), - (UUID(), "Computer Networking: A Top-Down Approach, Seventh Edition", "James Kurose, Keith Ross", "9781292153599", "IT", null, null), + (UUID(), "Computer Networking: A Top-Down Approach, Seventh Edition", "James Kurose, Keith Ross", "9781292153599", "Information Technology", null, null), - (UUID(), "Introduction to Probability, Second Edition", "Joseph K. Blitzstein, Jessica Hwang", "9781138369917", "Math", null, null), - (UUID(), "Introduction to Linear Algebra, Fifth Edition", "Gilbert Strang", "9780980232776", "Math", null, null), + (UUID(), "Introduction to Probability, Second Edition", "Joseph K. Blitzstein, Jessica Hwang", "9781138369917", "Mathematics", null, null), + (UUID(), "Introduction to Linear Algebra, Fifth Edition", "Gilbert Strang", "9780980232776", "Mathematics", null, null), (UUID(), "How to Reassess Your Chess, 4th Edition", "Jeremy Silman", "9781890085131", "Chess", null, null), (UUID(), "Bobby Fischer Teaches Chess", "Bobby Fischer, Stuart Margulies", "9780553263152", "Chess", null, null), diff --git a/src/main/resources/static/css/main.css b/src/main/resources/static/css/main.css @@ -1,5 +1,5 @@ body { - background: linear-gradient(black, darkslategrey) fixed; + background: linear-gradient(black, #2d2a29) fixed; color: #e4e4e4; margin-bottom: 100px ; font-family: sans-serif; @@ -30,20 +30,22 @@ table { border-collapse: collapse; margin-left: auto; margin-right: auto; + table-layout: fixed; + width: 95%; + border: 0px; } td, th { - border: 1px solid #dddddd; text-align: left; - padding: 8px; + padding: 5px; } -tr:nth-child(even) { - background-color: #202929; +td:nth-child(2) { + text-align: left; } -tr:nth-child(odd) { - background-color: black; +tr:hover { + background-color: #624d46; } img { @@ -87,6 +89,10 @@ a:hover { padding-left: 80px; } +.tblcat { + color: cyan; +} + .source-credit { text-align: right; font-size: 60%; diff --git a/src/main/resources/templates/books.html b/src/main/resources/templates/books.html @@ -12,24 +12,23 @@ <div th:insert="navigation"/> </header> <p class="subheader">This is the collection of books of which I own a physical copy</p> - <table> - <tr> - <th>Title</th> - <th>Author</th> - <th>Category</th> - </tr> - <tr th:each="book : ${books}"> - <td><a th:target="_blank" - th:href="@{https://openlibrary.org/isbn/{isbn}(isbn=${book.isbn})}" - th:text="${book.title} + + + <th:block th:each="bookEntry : ${books}"> + <p class="tblcat" th:text="${bookEntry.key}">keyvalue</p> + <table> + <tr th:each="book : ${bookEntry.value}"> + <td><a th:target="_blank" + th:href="@{https://openlibrary.org/isbn/{isbn}(isbn=${book.isbn})}" + th:text="${book.title} + ( ${book.series} ? ' (' + ${book.series} + (${book.seriesNumber} ? ' #' + ${#strings.replace(book.seriesNumber, '.0', '')} : '') + ')' : '' )"/> - </td> - <td th:text="${book.author}"/> - <td th:text="${book.category}"/> - </tr> - </table> + </td> + <td class="td-author" th:text="${book.author}"/> + </tr> + </table> + </th:block> + </div> </body> </html>