X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FViewPostPage.java;h=864dc846c78f91c79174e9eb9dd4169d66fb606e;hb=0e04143f3b957248ebd4e263372ebed4ae39928d;hp=0918e55564556b05ddba9e20e9538b211823d159;hpb=d9e840e34436f648179a318512b92836187f31e0;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java b/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java index 0918e55..864dc84 100644 --- a/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java @@ -18,7 +18,9 @@ package net.pterodactylus.sone.web; import net.pterodactylus.sone.data.Post; +import net.pterodactylus.sone.data.Reply; import net.pterodactylus.util.template.Template; +import net.pterodactylus.util.template.TemplateContext; /** * This page lets the user view a post and all its replies. @@ -36,7 +38,7 @@ public class ViewPostPage extends SoneTemplatePage { * The Sone web interface */ public ViewPostPage(Template template, WebInterface webInterface) { - super("viewPost.html", template, "Page.ViewPost.Title", webInterface); + super("viewPost.html", template, "Page.ViewPost.Title", webInterface, false); } // @@ -47,23 +49,26 @@ public class ViewPostPage extends SoneTemplatePage { * {@inheritDoc} */ @Override - protected void processTemplate(Request request, Template template) throws RedirectException { - super.processTemplate(request, template); + protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException { + super.processTemplate(request, templateContext); String postId = request.getHttpRequest().getParam("post"); - Post post = webInterface.core().getPost(postId); - template.set("post", post); + Post post = webInterface.getCore().getPost(postId); + templateContext.set("post", post); } - // - // SONETEMPLATEPAGE METHODS - // - /** * {@inheritDoc} */ @Override - protected boolean requiresLogin() { - return true; + protected void postProcess(Request request, TemplateContext templateContext) { + Post post = (Post) templateContext.get("post"); + if (post == null) { + return; + } + webInterface.getCore().markPostKnown(post); + for (Reply reply : webInterface.getCore().getReplies(post)) { + webInterface.getCore().markReplyKnown(reply); + } } }