X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FViewPostPage.java;h=56bac8d37662727d87982a4c2ba463dec210df7d;hp=fe63b3426e1ec863cc923996df8542c94f4e4567;hb=7b55e0be6a3283e43a9bbab98f82aebdd948eb33;hpb=9d341071d7fc10118038e238d29ce7bd38ff08c4 diff --git a/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java b/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java index fe63b34..56bac8d 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–2016 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,9 +17,13 @@ package net.pterodactylus.sone.web; +import java.net.URI; + +import com.google.common.base.Optional; + 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; @@ -50,13 +54,13 @@ public class ViewPostPage extends SoneTemplatePage { * {@inheritDoc} */ @Override - protected String getPageTitle(Request request) { + protected String getPageTitle(FreenetRequest request) { String postId = request.getHttpRequest().getParam("post"); - Post post = webInterface.getCore().getPost(postId, false); + Optional post = webInterface.getCore().getPost(postId); String title = ""; - if ((post != null) && (post.getSone() != null)) { - title = post.getText().substring(0, Math.min(20, post.getText().length())) + "…"; - title += " - " + SoneAccessor.getNiceName(post.getSone()) + " - "; + 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; @@ -66,17 +70,20 @@ public class ViewPostPage extends SoneTemplatePage { * {@inheritDoc} */ @Override - protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException { - super.processTemplate(request, templateContext); + protected void handleRequest(FreenetRequest request, TemplateContext templateContext) throws RedirectException { String postId = request.getHttpRequest().getParam("post"); boolean raw = request.getHttpRequest().getParam("raw").equals("true"); - Post post = webInterface.getCore().getPost(postId); - templateContext.set("post", post); + Optional post = webInterface.getCore().getPost(postId); + templateContext.set("post", post.orNull()); templateContext.set("raw", raw); - webInterface.getCore().markPostKnown(post); - for (Reply reply : webInterface.getCore().getReplies(post)) { - webInterface.getCore().markReplyKnown(reply); - } + } + + /** + * {@inheritDoc} + */ + @Override + public boolean isLinkExcepted(URI link) { + return true; } }