X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FViewSonePage.java;h=0792a6fdef83f3d62f5a5497157fe34e52b2e1b5;hb=07ca98b45465f7a442e695fbfb6f59100260f39b;hp=4a12ed9b34c6cfc02d688566ee3984eea5db5b7d;hpb=d94f4ab1052fc15248396a062c56ffd45bfefb85;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/ViewSonePage.java b/src/main/java/net/pterodactylus/sone/web/ViewSonePage.java index 4a12ed9..0792a6f 100644 --- a/src/main/java/net/pterodactylus/sone/web/ViewSonePage.java +++ b/src/main/java/net/pterodactylus/sone/web/ViewSonePage.java @@ -17,8 +17,13 @@ package net.pterodactylus.sone.web; +import java.util.List; + +import net.pterodactylus.sone.data.Post; +import net.pterodactylus.sone.data.Reply; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.util.template.Template; +import net.pterodactylus.util.template.TemplateContext; /** * Lets the user browser another Sone. @@ -36,7 +41,7 @@ public class ViewSonePage extends SoneTemplatePage { * The Sone web interface */ public ViewSonePage(Template template, WebInterface webInterface) { - super("viewSone.html", template, "Page.ViewSone.Title", webInterface); + super("viewSone.html", template, "Page.ViewSone.Title", webInterface, false); } // @@ -47,23 +52,30 @@ public class ViewSonePage 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 soneId = request.getHttpRequest().getParam("sone"); - Sone sone = webInterface.core().getSone(soneId); - template.set("sone", sone); + Sone sone = webInterface.getCore().getSone(soneId, false); + templateContext.set("sone", sone); } - // - // SONETEMPLATEPAGE METHODS - // - /** * {@inheritDoc} */ @Override - protected boolean requiresLogin() { - return true; + protected void postProcess(Request request, TemplateContext templateContext) { + Sone sone = (Sone) templateContext.get("sone"); + if (sone == null) { + return; + } + webInterface.getCore().markSoneKnown(sone); + List posts = sone.getPosts(); + for (Post post : posts) { + webInterface.getCore().markPostKnown(post); + for (Reply reply : webInterface.getCore().getReplies(post)) { + webInterface.getCore().markReplyKnown(reply); + } + } } }