From fd30c0adf935d90f496671d9122f5ab0b9043670 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 16 Oct 2010 02:57:14 +0200 Subject: [PATCH] =?utf8?q?Add=20=E2=80=9Cview=20post=E2=80=9D=20page.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../net/pterodactylus/sone/web/ViewPostPage.java | 68 ++++++++++++++++++++++ .../net/pterodactylus/sone/web/WebInterface.java | 4 ++ src/main/resources/i18n/sone.en.properties | 4 ++ src/main/resources/templates/viewPost.html | 26 +++++++++ 4 files changed, 102 insertions(+) create mode 100644 src/main/java/net/pterodactylus/sone/web/ViewPostPage.java create mode 100644 src/main/resources/templates/viewPost.html diff --git a/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java b/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java new file mode 100644 index 0000000..a013198 --- /dev/null +++ b/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java @@ -0,0 +1,68 @@ +/* + * Sone - ViewPostPage.java - Copyright © 2010 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 + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.sone.web; + +import net.pterodactylus.sone.data.Post; +import net.pterodactylus.util.template.Template; + +/** + * This page lets the user view a post and all its replies. + * + * @author David ‘Bombe’ Roden + */ +public class ViewPostPage extends SoneTemplatePage { + + /** + * Creates a new “view post” page. + * + * @param template + * The template to render + * @param webInterface + * The Sone web interface + */ + public ViewPostPage(Template template, WebInterface webInterface) { + super("viewPost.html", template, "Page.ViewPost.Title", webInterface); + } + + // + // TEMPLATEPAGE METHODS + // + + /** + * {@inheritDoc} + */ + @Override + protected void processTemplate(Request request, Template template) throws RedirectException { + String postId = request.getHttpRequest().getParam("post"); + Post post = webInterface.core().getPost(postId); + template.set("post", post); + } + + // + // SONETEMPLATEPAGE METHODS + // + + /** + * {@inheritDoc} + */ + @Override + protected boolean requiresLogin() { + return true; + } + +} diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index 32bd783..a0a1c3d 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -172,6 +172,9 @@ public class WebInterface extends AbstractService { Template viewSoneTemplate = templateFactory.createTemplate(createReader("/templates/viewSone.html")); viewSoneTemplate.set("formPassword", formPassword); + Template viewPostTemplate = templateFactory.createTemplate(createReader("/templates/viewPost.html")); + viewPostTemplate.set("formPassword", formPassword); + Template followSoneTemplate = templateFactory.createTemplate(createReader("/templates/followSone.html")); followSoneTemplate.set("formPassword", formPassword); @@ -187,6 +190,7 @@ public class WebInterface extends AbstractService { pageToadlets.add(pageToadletFactory.createPageToadlet(new CreatePostPage(createPostTemplate, this))); pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateReplyPage(createReplyTemplate, this))); pageToadlets.add(pageToadletFactory.createPageToadlet(new ViewSonePage(viewSoneTemplate, this))); + pageToadlets.add(pageToadletFactory.createPageToadlet(new ViewPostPage(viewPostTemplate, this))); pageToadlets.add(pageToadletFactory.createPageToadlet(new FollowSonePage(followSoneTemplate, this))); pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteSonePage(deleteSoneTemplate, this), "DeleteSone")); pageToadlets.add(pageToadletFactory.createPageToadlet(new LoginPage(loginTemplate, this), "Login")); diff --git a/src/main/resources/i18n/sone.en.properties b/src/main/resources/i18n/sone.en.properties index 1ca46dc..c2404f2 100644 --- a/src/main/resources/i18n/sone.en.properties +++ b/src/main/resources/i18n/sone.en.properties @@ -82,6 +82,10 @@ Page.ViewSone.FollowSone.Text=Follow this Sone Page.ViewSone.Following.Title=This Sone follows Page.ViewSone.Following.FollowingNone.Text=Apparently, this Sone does not yet follow any other Sone. +Page.ViewPost.Title=View Post - Sone +Page.ViewPost.Page.Title=View Post by {sone} +Page.ViewPost.Button.PostReply=Post Reply! + Page.FollowSone.Title=Follow Sone - Sone Page.Logout.Title=Logout - Sone diff --git a/src/main/resources/templates/viewPost.html b/src/main/resources/templates/viewPost.html new file mode 100644 index 0000000..237bfce --- /dev/null +++ b/src/main/resources/templates/viewPost.html @@ -0,0 +1,26 @@ +
+ +

<%= Page.ViewPost.Page.Title|l10n|insert needle="{sone}" key=post.sone.niceName|html>

+ +
+ +
<% post.text|html>
+
<% post.time|date format="MMM d, yyyy, HH:mm:ss">
+
+ <%foreach post.replies reply> +
+ +
<% reply.text|html>
+
<% reply.time|date format="MMM d, yyyy, HH:mm:ss">
+
+ <%/foreach> +
+
+ + + + +
+
+ +
-- 2.7.4