X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FViewPostPage.java;h=d0ca904c4baa74cb2eac645dc951e509b28245c9;hp=3f3dadcfa3f531e29e5970a8386343de3184d29d;hb=c9e306ac8e3ada846e87a0cc256a20fc148f381c;hpb=4c831fb948000bc1730ebcde73eeb62317f4ac54 diff --git a/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java b/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java index 3f3dadc..d0ca904 100644 --- a/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java @@ -17,8 +17,13 @@ package net.pterodactylus.sone.web; +import java.net.URI; + 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. @@ -47,11 +52,37 @@ 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.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; + } + + /** + * {@inheritDoc} + */ + @Override + protected void processTemplate(FreenetRequest 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); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean isLinkExcepted(URI link) { + return true; } }