X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FViewPostPage.java;h=409c63a77acc5d3752e47842f3112e85bf3f44de;hb=2e03e9dddbea4b81aacaf1aa316f5c3ccffd4bf9;hp=864dc846c78f91c79174e9eb9dd4169d66fb606e;hpb=c8f32a3dce696bfdb8b8b2b31cb736dae2524f71;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 864dc84..409c63a 100644 --- a/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java @@ -1,5 +1,5 @@ /* - * Sone - ViewPostPage.java - Copyright © 2010 David Roden + * Sone - ViewPostPage.java - Copyright © 2010–2013 David Roden * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,11 +17,16 @@ package net.pterodactylus.sone.web; +import java.net.URI; + import net.pterodactylus.sone.data.Post; -import net.pterodactylus.sone.data.Reply; +import net.pterodactylus.sone.template.SoneAccessor; +import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; +import com.google.common.base.Optional; + /** * This page lets the user view a post and all its replies. * @@ -45,30 +50,32 @@ public class ViewPostPage extends SoneTemplatePage { // TEMPLATEPAGE METHODS // - /** - * {@inheritDoc} - */ @Override - protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException { + protected String getPageTitle(FreenetRequest request) { + String postId = request.getHttpRequest().getParam("post"); + Optional post = webInterface.getCore().getDatabase().getPost(postId); + String title = ""; + if (post.isPresent()) { + title = post.get().getText().substring(0, Math.min(20, post.get().getText().length())) + "…"; + title += " - " + SoneAccessor.getNiceName(post.get().getSone()) + " - "; + } + title += webInterface.getL10n().getString("Page.ViewPost.Title"); + return title; + } + + @Override + protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException { super.processTemplate(request, templateContext); String postId = request.getHttpRequest().getParam("post"); - Post post = webInterface.getCore().getPost(postId); - templateContext.set("post", post); + boolean raw = request.getHttpRequest().getParam("raw").equals("true"); + Optional post = webInterface.getCore().getDatabase().getPost(postId); + templateContext.set("post", post.orNull()); + templateContext.set("raw", raw); } - /** - * {@inheritDoc} - */ @Override - protected void postProcess(Request request, TemplateContext templateContext) { - Post post = (Post) templateContext.get("post"); - if (post == null) { - return; - } - webInterface.getCore().markPostKnown(post); - for (Reply reply : webInterface.getCore().getReplies(post)) { - webInterface.getCore().markReplyKnown(reply); - } + public boolean isLinkExcepted(URI link) { + return true; } }