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=d0ca904c4baa74cb2eac645dc951e509b28245c9;hpb=b28eb5baea51a37d9765833e0184e2a10a86819b;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 d0ca904..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 @@ -25,6 +25,8 @@ 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. * @@ -48,38 +50,29 @@ public class ViewPostPage extends SoneTemplatePage { // TEMPLATEPAGE METHODS // - /** - * {@inheritDoc} - */ @Override protected String getPageTitle(FreenetRequest request) { String postId = request.getHttpRequest().getParam("post"); - Post post = webInterface.getCore().getPost(postId, false); + Optional post = webInterface.getCore().getDatabase().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; } - /** - * {@inheritDoc} - */ @Override protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException { super.processTemplate(request, templateContext); 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().getDatabase().getPost(postId); + templateContext.set("post", post.orNull()); templateContext.set("raw", raw); } - /** - * {@inheritDoc} - */ @Override public boolean isLinkExcepted(URI link) { return true;