X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FViewPostPage.java;h=4cc986440f3aeeae546e0dad49793f452336dd4c;hb=45f92ec63dbf8134d92ceed67294faa38117b195;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..4cc9864 100644 --- a/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java @@ -18,7 +18,10 @@ package net.pterodactylus.sone.web; import net.pterodactylus.sone.data.Post; +import net.pterodactylus.sone.template.SoneAccessor; +import net.pterodactylus.sone.web.page.FreenetRequest; 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 +39,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 +50,29 @@ public class ViewPostPage extends SoneTemplatePage { * {@inheritDoc} */ @Override - protected void processTemplate(Request request, Template template) throws RedirectException { - super.processTemplate(request, template); + protected String getPageTitle(FreenetRequest request) { String postId = request.getHttpRequest().getParam("post"); - Post post = webInterface.core().getPost(postId); - template.set("post", post); + Post post = webInterface.getCore().getPost(postId, false); + String title = ""; + if ((post != null) && (post.getSone() != null)) { + title = post.getText().substring(0, Math.min(20, post.getText().length())) + "…"; + title += " - " + SoneAccessor.getNiceName(post.getSone()) + " - "; + } + title += webInterface.getL10n().getString("Page.ViewPost.Title"); + return title; } - // - // SONETEMPLATEPAGE METHODS - // - /** * {@inheritDoc} */ @Override - protected boolean requiresLogin() { - return true; + protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException { + super.processTemplate(request, templateContext); + String postId = request.getHttpRequest().getParam("post"); + boolean raw = request.getHttpRequest().getParam("raw").equals("true"); + Post post = webInterface.getCore().getPost(postId); + templateContext.set("post", post); + templateContext.set("raw", raw); } }