summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2020-01-25 10:09:57 +0100
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2020-01-25 10:10:09 +0100
commitae402342fe5736d74cf86e21c642abbb0805ff83 (patch)
treef46fea3076f18b2fcfb9fb6fa6fbd1370e0dfcd9 /src/main/java
parent298dcac3717ccde4231a5f35b9a59319036d40bd (diff)
Web: Extract base template.
Change-Id: I20a4fbb04aa75a94f96617b0c4d1be00ab3e4aca
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/eu/mulk/mulkcms2/benki/wiki/WikiResource.java24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/main/java/eu/mulk/mulkcms2/benki/wiki/WikiResource.java b/src/main/java/eu/mulk/mulkcms2/benki/wiki/WikiResource.java
index ebed4e2..714b785 100644
--- a/src/main/java/eu/mulk/mulkcms2/benki/wiki/WikiResource.java
+++ b/src/main/java/eu/mulk/mulkcms2/benki/wiki/WikiResource.java
@@ -4,6 +4,7 @@ import static javax.ws.rs.core.MediaType.TEXT_HTML;
import io.quarkus.panache.common.Sort;
import io.quarkus.qute.Template;
+import io.quarkus.qute.TemplateExtension;
import io.quarkus.qute.TemplateInstance;
import io.quarkus.qute.api.ResourcePath;
import io.quarkus.security.Authenticated;
@@ -11,6 +12,7 @@ import io.quarkus.security.identity.SecurityIdentity;
import io.smallrye.jwt.auth.principal.JWTCallerPrincipal;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
+import java.time.temporal.TemporalAccessor;
import java.util.Map;
import java.util.Optional;
import javax.inject.Inject;
@@ -55,17 +57,7 @@ public class WikiResource {
throw new NotFoundException();
}
var page = maybePage.get();
- return wikiPage
- .data("title", page.title)
- .data(
- "date",
- Map.of(
- "htmlFormat", htmlDateFormatter.format(page.date),
- "humanFormat", humanDateFormatter.format(page.date)))
- .data(
- "author",
- Map.of("name", String.format("%s %s", page.author.firstName, page.author.lastName)))
- .data("content", page.content);
+ return wikiPage.data("page", page);
}
@POST
@@ -85,4 +77,14 @@ public class WikiResource {
public TemplateInstance getPageRevisions(@PathParam("pageName") String pageName) {
throw new NotImplementedYetException();
}
+
+ @TemplateExtension
+ static String humanDateTime(TemporalAccessor x) {
+ return humanDateFormatter.format(x);
+ }
+
+ @TemplateExtension
+ static String htmlDateTime(TemporalAccessor x) {
+ return htmlDateFormatter.format(x);
+ }
}