From 371164a188b93b24f33cb5badb0362ac2544d33d Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Mon, 23 Mar 2020 06:21:25 +0100 Subject: Use generic page template for bookmark and lazy chat lists. Change-Id: I86cc78c8164d6672d8b5cfbc2a3433954068967e --- .../eu/mulk/mulkcms2/benki/bookmarks/Bookmark.java | 10 +++ .../mulkcms2/benki/bookmarks/BookmarkResource.java | 12 ++- .../java/eu/mulk/mulkcms2/benki/generic/Post.java | 4 + .../mulkcms2/benki/lazychat/LazychatMessage.java | 10 +++ .../mulkcms2/benki/lazychat/LazychatResource.java | 14 ++-- src/main/resources/templates/base.html | 7 +- .../resources/templates/benki/about/index.html | 2 + .../templates/benki/bookmarks/bookmarkList.html | 68 ----------------- .../templates/benki/lazychat/lazychatList.html | 52 ------------- .../resources/templates/benki/posts/postList.html | 85 ++++++++++++++++++++++ .../resources/templates/benki/wiki/wikiPage.html | 2 + .../templates/benki/wiki/wikiPageRevisionList.html | 2 + src/main/resources/templates/tags/navbar.html | 6 ++ 13 files changed, 138 insertions(+), 136 deletions(-) delete mode 100644 src/main/resources/templates/benki/bookmarks/bookmarkList.html delete mode 100644 src/main/resources/templates/benki/lazychat/lazychatList.html create mode 100644 src/main/resources/templates/benki/posts/postList.html create mode 100644 src/main/resources/templates/tags/navbar.html (limited to 'src') diff --git a/src/main/java/eu/mulk/mulkcms2/benki/bookmarks/Bookmark.java b/src/main/java/eu/mulk/mulkcms2/benki/bookmarks/Bookmark.java index 8beda97..ea62af3 100644 --- a/src/main/java/eu/mulk/mulkcms2/benki/bookmarks/Bookmark.java +++ b/src/main/java/eu/mulk/mulkcms2/benki/bookmarks/Bookmark.java @@ -56,4 +56,14 @@ public class Bookmark extends Post { @CheckForNull Integer count) { return findViewable(Bookmark.class, session, viewer, owner, cursor, count); } + + @Override + public boolean isBookmark() { + return true; + } + + @Override + public boolean isLazychatMessage() { + return false; + } } diff --git a/src/main/java/eu/mulk/mulkcms2/benki/bookmarks/BookmarkResource.java b/src/main/java/eu/mulk/mulkcms2/benki/bookmarks/BookmarkResource.java index 1f57c74..d026a1a 100644 --- a/src/main/java/eu/mulk/mulkcms2/benki/bookmarks/BookmarkResource.java +++ b/src/main/java/eu/mulk/mulkcms2/benki/bookmarks/BookmarkResource.java @@ -75,9 +75,9 @@ public class BookmarkResource { @ConfigProperty(name = "mulkcms.bookmarks.default-max-results") int defaultMaxResults; - @ResourcePath("benki/bookmarks/bookmarkList.html") + @ResourcePath("benki/posts/postList.html") @Inject - Template bookmarkList; + Template postList; @ResourcePath("benki/bookmarks/newBookmark.html") @Inject @@ -104,9 +104,11 @@ public class BookmarkResource { var session = entityManager.unwrap(Session.class); var q = Bookmark.findViewable(session, identity, null, cursor, maxResults); - return bookmarkList + return postList .data("posts", q.posts) .data("feedUri", "/bookmarks/feed") + .data("pageTitle", "Bookmarks") + .data("showBookmarkForm", false) .data("authenticated", !identity.isAnonymous()) .data("hasPreviousPage", q.prevCursor != null) .data("hasNextPage", q.nextCursor != null) @@ -129,9 +131,11 @@ public class BookmarkResource { var session = entityManager.unwrap(Session.class); var q = Bookmark.findViewable(session, identity, owner, cursor, maxResults); - return bookmarkList + return postList .data("posts", q.posts) .data("feedUri", String.format("/bookmarks/~%s/feed", ownerName)) + .data("pageTitle", "Bookmarks") + .data("showBookmarkForm", false) .data("authenticated", !identity.isAnonymous()) .data("hasPreviousPage", q.prevCursor != null) .data("hasNextPage", q.nextCursor != null) diff --git a/src/main/java/eu/mulk/mulkcms2/benki/generic/Post.java b/src/main/java/eu/mulk/mulkcms2/benki/generic/Post.java index 898eeb4..7d75bb4 100644 --- a/src/main/java/eu/mulk/mulkcms2/benki/generic/Post.java +++ b/src/main/java/eu/mulk/mulkcms2/benki/generic/Post.java @@ -75,6 +75,10 @@ public abstract class Post extends PanacheEntityBase { inverseJoinColumns = @JoinColumn(name = "target")) public Set targets; + public abstract boolean isBookmark(); + + public abstract boolean isLazychatMessage(); + protected static CriteriaQuery queryViewable( Class entityClass, SecurityIdentity readerIdentity, diff --git a/src/main/java/eu/mulk/mulkcms2/benki/lazychat/LazychatMessage.java b/src/main/java/eu/mulk/mulkcms2/benki/lazychat/LazychatMessage.java index 4e58259..4c7f6a0 100644 --- a/src/main/java/eu/mulk/mulkcms2/benki/lazychat/LazychatMessage.java +++ b/src/main/java/eu/mulk/mulkcms2/benki/lazychat/LazychatMessage.java @@ -46,4 +46,14 @@ public class LazychatMessage extends Post { @CheckForNull Integer count) { return findViewable(LazychatMessage.class, session, viewer, owner, cursor, count); } + + @Override + public boolean isBookmark() { + return false; + } + + @Override + public boolean isLazychatMessage() { + return true; + } } diff --git a/src/main/java/eu/mulk/mulkcms2/benki/lazychat/LazychatResource.java b/src/main/java/eu/mulk/mulkcms2/benki/lazychat/LazychatResource.java index 4284d96..cb89e71 100644 --- a/src/main/java/eu/mulk/mulkcms2/benki/lazychat/LazychatResource.java +++ b/src/main/java/eu/mulk/mulkcms2/benki/lazychat/LazychatResource.java @@ -40,9 +40,9 @@ public class LazychatResource { @ConfigProperty(name = "mulkcms.lazychat.default-max-results") int defaultMaxResults; - @ResourcePath("benki/lazychat/lazychatList.html") + @ResourcePath("benki/posts/postList.html") @Inject - Template lazychatList; + Template postList; @Inject SecurityIdentity identity; @@ -59,9 +59,10 @@ public class LazychatResource { var session = entityManager.unwrap(Session.class); var q = LazychatMessage.findViewable(session, identity, null, cursor, maxResults); - return lazychatList + return postList .data("posts", q.posts) - .data("authenticated", !identity.isAnonymous()) + .data("pageTitle", "Lazy Chat") + .data("showBookmarkForm", false) .data("hasPreviousPage", q.prevCursor != null) .data("hasNextPage", q.nextCursor != null) .data("previousCursor", q.prevCursor) @@ -83,9 +84,10 @@ public class LazychatResource { var session = entityManager.unwrap(Session.class); var q = LazychatMessage.findViewable(session, identity, owner, cursor, maxResults); - return lazychatList + return postList .data("posts", q.posts) - .data("authenticated", !identity.isAnonymous()) + .data("pageTitle", "Lazy Chat") + .data("showBookmarkForm", false) .data("hasPreviousPage", q.prevCursor != null) .data("hasNextPage", q.nextCursor != null) .data("previousCursor", q.prevCursor) diff --git a/src/main/resources/templates/base.html b/src/main/resources/templates/base.html index 0d4408c..9a1ba04 100644 --- a/src/main/resources/templates/base.html +++ b/src/main/resources/templates/base.html @@ -18,12 +18,7 @@
diff --git a/src/main/resources/templates/benki/about/index.html b/src/main/resources/templates/benki/about/index.html index 520644e..edfd82e 100644 --- a/src/main/resources/templates/benki/about/index.html +++ b/src/main/resources/templates/benki/about/index.html @@ -6,6 +6,8 @@ {#siteSection}About This Site{/siteSection} {#aboutClass}this-page{/aboutClass} +{#nav}{#navbar siteSection="About" /}{/nav} + {#head}{/head} {#body} diff --git a/src/main/resources/templates/benki/bookmarks/bookmarkList.html b/src/main/resources/templates/benki/bookmarks/bookmarkList.html deleted file mode 100644 index 8c87a55..0000000 --- a/src/main/resources/templates/benki/bookmarks/bookmarkList.html +++ /dev/null @@ -1,68 +0,0 @@ -{@java.util.List posts} -{@java.lang.Boolean authenticated} -{@java.lang.Boolean hasPreviousPage} -{@java.lang.Boolean hasNextPage} -{@java.lang.Integer previousCursor} -{@java.lang.Integer nextCursor} -{@java.lang.Integer pageSize} - -{#include base.html} - -{#title}Benki Bookmarks{/title} -{#siteSection}Bookmarks{/siteSection} -{#bookmarksClass}this-page{/bookmarksClass} - -{#head} - - - - - -{/head} - -{#body} - -{! #if authenticated !} - -

-
- -
-
-{! /if !} - -
- {#if hasPreviousPage}⇠ previous page{/if} - - {#if hasNextPage}next page ⇢{/if} -
- -
- {#for post in posts} - {#with post} -
-
-

{title}

-
- - {owner.firstName} {owner.lastName} -
-
- -
- {descriptionHtml.raw} -
-
- {/with} - {/for} -
- -
- {#if hasPreviousPage}⇠ previous page{/if} - - {#if hasNextPage}next page ⇢{/if} -
- -{/body} - -{/include} diff --git a/src/main/resources/templates/benki/lazychat/lazychatList.html b/src/main/resources/templates/benki/lazychat/lazychatList.html deleted file mode 100644 index b644662..0000000 --- a/src/main/resources/templates/benki/lazychat/lazychatList.html +++ /dev/null @@ -1,52 +0,0 @@ -{@java.util.List posts} -{@java.lang.Boolean authenticated} -{@java.lang.Boolean hasPreviousPage} -{@java.lang.Boolean hasNextPage} -{@java.lang.Integer previousCursor} -{@java.lang.Integer nextCursor} -{@java.lang.Integer pageSize} - -{#include base.html} - -{#title}Benki Lazychat{/title} -{#siteSection}Lazychat{/siteSection} -{#lazychatClass}this-page{/lazychatClass} - -{#head}{/head} - -{#body} - -
- {#if hasPreviousPage}⇠ previous page{/if} - - {#if hasNextPage}next page ⇢{/if} -
- -
- {#for post in posts} - {#with post} -
-
-
- - {owner.firstName} {owner.lastName} -
-
- -
- {contentHtml.raw} -
-
- {/with} - {/for} -
- -
- {#if hasPreviousPage}⇠ previous page{/if} - - {#if hasNextPage}next page ⇢{/if} -
- -{/body} - -{/include} diff --git a/src/main/resources/templates/benki/posts/postList.html b/src/main/resources/templates/benki/posts/postList.html new file mode 100644 index 0000000..b68f796 --- /dev/null +++ b/src/main/resources/templates/benki/posts/postList.html @@ -0,0 +1,85 @@ +{@java.util.List posts} +{@java.lang.String pageTitle} +{@java.lang.Boolean showBookmarkForm} +{@java.lang.Boolean hasPreviousPage} +{@java.lang.Boolean hasNextPage} +{@java.lang.Integer previousCursor} +{@java.lang.Integer nextCursor} +{@java.lang.Integer pageSize} + +{#include base.html} + +{#title}Benki {pageTitle}{/title} +{#siteSection}{pageTitle}{/siteSection} + +{#nav}{#navbar siteSection=pageTitle /}{/nav} + +{#head} + + + + + +{/head} + +{#body} + +{#if showBookmarkForm} + +

+
+ +
+
+{/if} + +
+ {#if hasPreviousPage}⇠ previous page{/if} + + {#if hasNextPage}next page ⇢{/if} +
+ +
+ {#for post in posts} + {#with post} + {#if post.isBookmark} +
+
+

{title}

+
+ + {owner.firstName} {owner.lastName} +
+
+ +
+ {descriptionHtml.raw} +
+
+ {#else} +
+
+
+ + {owner.firstName} {owner.lastName} +
+
+ +
+ {contentHtml.raw} +
+
+ {/if} + {/with} + {/for} +
+ +
+ {#if hasPreviousPage}⇠ previous page{/if} + + {#if hasNextPage}next page ⇢{/if} +
+ +{/body} + +{/include} diff --git a/src/main/resources/templates/benki/wiki/wikiPage.html b/src/main/resources/templates/benki/wiki/wikiPage.html index c5155bc..a98b147 100644 --- a/src/main/resources/templates/benki/wiki/wikiPage.html +++ b/src/main/resources/templates/benki/wiki/wikiPage.html @@ -6,6 +6,8 @@ {#siteSection}Wiki{/siteSection} {#wikiClass}this-page{/wikiClass} +{#nav}{#navbar siteSection="Wiki" /}{/nav} + {#head} diff --git a/src/main/resources/templates/benki/wiki/wikiPageRevisionList.html b/src/main/resources/templates/benki/wiki/wikiPageRevisionList.html index 2fd04eb..91e5058 100644 --- a/src/main/resources/templates/benki/wiki/wikiPageRevisionList.html +++ b/src/main/resources/templates/benki/wiki/wikiPageRevisionList.html @@ -7,6 +7,8 @@ {#siteSection}Wiki{/siteSection} {#wikiClass}this-page{/wikiClass} +{#nav}{#navbar siteSection="Wiki" /}{/nav} + {#body}

Revisions — {title}

diff --git a/src/main/resources/templates/tags/navbar.html b/src/main/resources/templates/tags/navbar.html new file mode 100644 index 0000000..b3d12d8 --- /dev/null +++ b/src/main/resources/templates/tags/navbar.html @@ -0,0 +1,6 @@ +
    +
  1. Bookmarks
  2. +
  3. Lazy Chat
  4. +
  5. Wiki
  6. +
  7. Contact Info
  8. +
-- cgit v1.2.3