X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FViewPostPage.java;h=fe63b3426e1ec863cc923996df8542c94f4e4567;hb=9ee1da2306234248b6077946fc254d8436fb4bd1;hp=3f3dadcfa3f531e29e5970a8386343de3184d29d;hpb=4c831fb948000bc1730ebcde73eeb62317f4ac54;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 3f3dadc..fe63b34 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.data.Reply; +import net.pterodactylus.sone.template.SoneAccessor; 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 +50,33 @@ public class ViewPostPage extends SoneTemplatePage { * {@inheritDoc} */ @Override - protected void processTemplate(Request request, Template template) throws RedirectException { - super.processTemplate(request, template); + protected String getPageTitle(Request 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; + } + + /** + * {@inheritDoc} + */ + @Override + protected void processTemplate(Request 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); + webInterface.getCore().markPostKnown(post); + for (Reply reply : webInterface.getCore().getReplies(post)) { + webInterface.getCore().markReplyKnown(reply); + } } }