From: David ‘Bombe’ Roden Date: Sat, 2 Apr 2011 09:19:49 +0000 (+0200) Subject: Show the beginning of the post and the name of the posting Sone in the title. X-Git-Tag: 0.6^2~12 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=daccb857e7d487504cdc651caa1dc678dea579eb;hp=2a17f4983f7ad9cd25e073cf2981d78bc2673ffd;p=Sone.git Show the beginning of the post and the name of the posting Sone in the title. This fixes #19. --- 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");