X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FViewPostPage.java;h=967b9c5953975b9824a32854eaac8d8b012d5d07;hb=6991fe9edc0e1652b695f9c0b2844bb6a0842c84;hp=a013198af55ecb3edf4f215d8370c66f43ce7d35;hpb=fd30c0adf935d90f496671d9122f5ab0b9043670;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 a013198..967b9c5 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,22 +49,28 @@ public class ViewPostPage extends SoneTemplatePage { * {@inheritDoc} */ @Override - protected void processTemplate(Request request, Template template) throws RedirectException { + 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); + boolean raw = request.getHttpRequest().getParam("raw").equals("true"); + Post post = webInterface.getCore().getPost(postId); + templateContext.set("post", post); + templateContext.set("raw", raw); } - // - // 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); + } } }