Show the beginning of the post and the name of the posting Sone in the title.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 2 Apr 2011 09:19:49 +0000 (11:19 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 2 Apr 2011 09:19:49 +0000 (11:19 +0200)
This fixes #19.

src/main/java/net/pterodactylus/sone/web/ViewPostPage.java

index 967b9c5..e528709 100644 (file)
@@ -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");