From daccb857e7d487504cdc651caa1dc678dea579eb Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 2 Apr 2011 11:19:49 +0200 Subject: [PATCH] Show the beginning of the post and the name of the posting Sone in the title. This fixes #19. --- .../java/net/pterodactylus/sone/web/ViewPostPage.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java b/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java index 967b9c5..e528709 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,6 +50,22 @@ public class ViewPostPage extends SoneTemplatePage { * {@inheritDoc} */ @Override + protected String getPageTitle(Request 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(Request request, TemplateContext templateContext) throws RedirectException { super.processTemplate(request, templateContext); String postId = request.getHttpRequest().getParam("post"); -- 2.7.4