summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/eu/mulk/mulkcms2/benki/wiki/WikiResource.java24
-rw-r--r--src/main/resources/templates/base.html15
-rw-r--r--src/main/resources/templates/benki/wiki/wikiPage.html42
3 files changed, 46 insertions, 35 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);
+ }
}
diff --git a/src/main/resources/templates/base.html b/src/main/resources/templates/base.html
new file mode 100644
index 0000000..8fefe31
--- /dev/null
+++ b/src/main/resources/templates/base.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="UTF-8">
+
+ <title>{#insert title}{/}</title>
+
+ <link rel="stylesheet" type="text/css" href="/common.css" />
+ <script type="module" src="/components.js"></script>
+</head>
+
+<body>
+{#insert body}{/}
+</body>
+</html>
diff --git a/src/main/resources/templates/benki/wiki/wikiPage.html b/src/main/resources/templates/benki/wiki/wikiPage.html
index 865d3ba..7caf94d 100644
--- a/src/main/resources/templates/benki/wiki/wikiPage.html
+++ b/src/main/resources/templates/benki/wiki/wikiPage.html
@@ -1,28 +1,22 @@
-<!DOCTYPE html>
-<html>
-<head>
- <meta charset="UTF-8">
+{@eu.mulk.mulkcms2.benki.wiki.WikiPageRevision page}
- <title>{title} &#8212; Benki Wiki</title>
+{#include base.html}
+{#title}{page.title} &#8212; Benki Wiki{/title}
+{#body}
+<article id="wiki-page">
+ <header>
+ <h1>{page.title}</h1>
+ </header>
- <link rel="stylesheet" type="text/css" href="/common.css" />
-</head>
+ <main>
+ {#with page}{content.raw}{/}
+ </main>
-<body>
- <article id="wiki-page">
- <header>
- <h1>{title}</h1>
- </header>
+ <hr>
- <main>
- {content.raw}
- </main>
-
- <hr>
-
- <footer>
- <a href="/wiki/{title}/revisions">Page revisions</a>
- </footer>
- </article>
-</body>
-</html>
+ <footer>
+ <a href="/wiki/{page.title}/revisions">Page revisions</a>
+ </footer>
+</article>
+{/body}
+{/include}