commit 8b93f3f8d7afd3bda24f9de2199b418c50438c29
parent cea8a120d900fccc3cbe90f352af768cc8310785
Author: Wim Dupont <wim@wimdupont.com>
Date: Wed, 20 Dec 2023 14:55:22 +0100
bookseries html and style update
Former-commit-id: a9a3af59bd1e63f4eabb770a198167ebd8949787
Diffstat:
3 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/src/main/java/com/wimdupont/personalweb/model/dto/BookDto.java b/src/main/java/com/wimdupont/personalweb/model/dto/BookDto.java
@@ -1,5 +1,7 @@
package com.wimdupont.personalweb.model.dto;
+import org.springframework.util.StringUtils;
+
public record BookDto(
String id,
@@ -11,6 +13,15 @@ public record BookDto(
Double seriesNumber
) {
+ public String seriesWithNumber() {
+ if (series != null) {
+ return seriesNumber != null
+ ? String.format("(%s #%s)", series, seriesNumber)
+ : String.format("(%s)", series);
+ }
+ return "";
+ }
+
private BookDto(Builder builder) {
this(builder.id,
builder.title,
diff --git a/src/main/resources/static/css/main.css b/src/main/resources/static/css/main.css
@@ -93,10 +93,16 @@ a:hover {
font-size: 60%;
}
-.align-right {
+table .align-right {
+ width: 30%;
text-align: right;
}
.center {
text-align: center;
}
+
+.series {
+ font-size: 80%;
+ color: #8f5a44;
+}
diff --git a/src/main/resources/templates/books.html b/src/main/resources/templates/books.html
@@ -16,12 +16,13 @@
<p th:text="${bookEntry.key}">keyvalue</p>
<table>
<tr th:each="book : ${bookEntry.value}">
- <td><a th:target="_blank"
+ <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', '')} : '')
- + ')' : '' )"/>
+ th:title="${book.title}">
+ <span th:text="${book.title}"/>
+ <span class="series" th:text="${book.seriesWithNumber}"/>
+ </a>
</td>
<td class="align-right" th:text="${book.author}"/>
</tr>