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=967b9c5953975b9824a32854eaac8d8b012d5d07;hpb=6991fe9edc0e1652b695f9c0b2844bb6a0842c84;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 967b9c5..fe63b34 100644 --- a/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java @@ -19,6 +19,7 @@ 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; @@ -49,24 +50,29 @@ public class ViewPostPage extends SoneTemplatePage { * {@inheritDoc} */ @Override - protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException { - super.processTemplate(request, templateContext); + protected String getPageTitle(Request request) { 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); + 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 postProcess(Request request, TemplateContext templateContext) { - Post post = (Post) templateContext.get("post"); - if (post == null) { - return; - } + 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);