--- /dev/null
+/*
+ * Sone - ViewSonePage.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.Sone;
+import net.pterodactylus.util.template.Template;
+
+/**
+ * Lets the user browser another Sone.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class ViewSonePage extends SoneTemplatePage {
+
+ /**
+ * Creates a new “view Sone” page.
+ *
+ * @param template
+ * The template to render
+ * @param webInterface
+ * The Sone web interface
+ */
+ public ViewSonePage(Template template, WebInterface webInterface) {
+ super("viewSone.html", template, "Page.ViewSone.Title", webInterface);
+ }
+
+ //
+ // TEMPLATEPAGE METHODS
+ //
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void processTemplate(Request request, Template template) throws RedirectException {
+ super.processTemplate(request, template);
+ String soneId = request.getHttpRequest().getParam("sone");
+ Sone sone = webInterface.core().getSone(soneId);
+ template.set("sone", sone);
+ }
+
+ //
+ // SONETEMPLATEPAGE METHODS
+ //
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean requiresLogin() {
+ return true;
+ }
+
+}
Template editProfileTemplate = templateFactory.createTemplate(createReader("/templates/editProfile.html"));
editProfileTemplate.set("formPassword", formPassword);
+ Template viewSoneTemplate = templateFactory.createTemplate(createReader("/templates/viewSone.html"));
+ viewSoneTemplate.set("formPassword", formPassword);
+
Template deleteSoneTemplate = templateFactory.createTemplate(createReader("/templates/deleteSone.html"));
deleteSoneTemplate.set("formPassword", formPassword);
pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateSonePage(createSoneTemplate, this), "CreateSone"));
pageToadlets.add(pageToadletFactory.createPageToadlet(new EditProfilePage(editProfileTemplate, this), "EditProfile"));
pageToadlets.add(pageToadletFactory.createPageToadlet(new CreatePostPage(createPostTemplate, this)));
+ pageToadlets.add(pageToadletFactory.createPageToadlet(new ViewSonePage(viewSoneTemplate, this)));
pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteSonePage(deleteSoneTemplate, this), "DeleteSone"));
pageToadlets.add(pageToadletFactory.createPageToadlet(new LoginPage(loginTemplate, this), "Login"));
pageToadlets.add(pageToadletFactory.createPageToadlet(new LogoutPage(logoutTemplate, this), "Logout"));
Page.CreatePost.Button.Post=Post!
Page.CreatePost.Error.EmptyText=You did not enter any text, which is a pity. You should try writing more!
+Page.ViewSone.Title=View Sone - Sone
+Page.ViewSone.Page.TitleWithoutSone=View unknown Sone
+Page.ViewSone.Page.TitleWithSone=View Sone “{sone}”
+Page.ViewSone.UnknownSone.Description=This Sone has not yet been retrieved. Please check back in a short time.
+Page.ViewSone.PostList.Title=Posts by “{sone}”
+Page.ViewSone.PostList.Text.NoPostYet=This Sone has not yet posted anything.
+
Page.Logout.Title=Logout - Sone
--- /dev/null
+<div id="sone">
+
+ <%ifnull sone.name>
+
+ <h1><%= Page.ViewSone.Page.TitleWithoutSone|l10n|html></h1>
+
+ <div><%= Page.ViewSone.UnknownSone.Description|l10n|html></div>
+
+ <%else>
+
+ <h1></h1><%= Page.ViewSone.Page.TitleWithSone|l10n|insert needle="{sone}" key=sone.name|html></h1>
+
+ <h1><%= Page.ViewSone.PostList.Title|l10n|insert needle="{sone}" key=sone.name|html></h1>
+
+ <div id="posts">
+ <%foreach sone.posts post>
+ <div class="post">
+ <div class="author"><a href="viewSone.html?sone=<% post.sone.id>"><% post.sone.name|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>
+ <%foreachelse>
+ <div><%= Page.ViewSone.PostList.Text.NoPostYet|l10n|html></div>
+ <%/foreach>
+ </div>
+
+ <%/if>
+
+</div>