--- /dev/null
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+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 <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+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;
+ }
+
+}
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);
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"));
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
--- /dev/null
+<div id="sone">
+
+ <h1><%= Page.ViewPost.Page.Title|l10n|insert needle="{sone}" key=post.sone.niceName|html></h1>
+
+ <div class="post">
+ <div class="author"><a href="viewSone.html?sone=<% post.sone.id>"><% post.sone.niceName|html></a></div>
+ <div class="text"><% post.text|html></div>
+ <div class="time"><% post.time|date format="MMM d, yyyy, HH:mm:ss"></div>
+ </div>
+ <%foreach post.replies reply>
+ <div class="reply">
+ <div class="author"><a href="viewSone.html?sone=<% reply.sone.id>"><% reply.sone.niceName|html></a></div>
+ <div class="text"><% reply.text|html></div>
+ <div class="time"><% reply.time|date format="MMM d, yyyy, HH:mm:ss"></div>
+ </div>
+ <%/foreach>
+ <div class="create-reply">
+ <form method="post" action="createReply.html">
+ <input type="hidden" name="formPassword" value="<% formPassword|html>" />
+ <input type="hidden" name="post" value="<% post.id>" />
+ <input type="text" name="text" value="" />
+ <button type="submit"><%= Page.ViewPost.Button.PostReply|l10n|html></button>
+ </form>
+ </div>
+
+</div>