From ccd98b291f132395ad87b2ff65d98d8237184be1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 16 Oct 2010 04:58:35 +0200 Subject: [PATCH 1/1] =?utf8?q?Add=20=E2=80=9Cknown=20Sones=E2=80=9D=20page?= =?utf8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../java/net/pterodactylus/sone/core/Core.java | 10 ++++ .../net/pterodactylus/sone/web/KnownSonesPage.java | 54 ++++++++++++++++++++++ .../net/pterodactylus/sone/web/WebInterface.java | 4 ++ src/main/resources/i18n/sone.en.properties | 6 +++ src/main/resources/templates/knownSones.html | 13 ++++++ 5 files changed, 87 insertions(+) create mode 100644 src/main/java/net/pterodactylus/sone/web/KnownSonesPage.java create mode 100644 src/main/resources/templates/knownSones.html diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index eb517fc..c910799 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -19,6 +19,7 @@ package net.pterodactylus.sone.core; import java.net.MalformedURLException; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; @@ -141,6 +142,15 @@ public class Core extends AbstractService { } /** + * Returns all known sones. + * + * @return All known sones + */ + public Collection getKnownSones() { + return soneCache.values(); + } + + /** * Creates a new post. * * @param sone diff --git a/src/main/java/net/pterodactylus/sone/web/KnownSonesPage.java b/src/main/java/net/pterodactylus/sone/web/KnownSonesPage.java new file mode 100644 index 0000000..0127172 --- /dev/null +++ b/src/main/java/net/pterodactylus/sone/web/KnownSonesPage.java @@ -0,0 +1,54 @@ +/* + * Sone - KnownSonesPage.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.util.template.Template; + +/** + * This page shows all known Sones. + * + * @author David ‘Bombe’ Roden + */ +public class KnownSonesPage extends SoneTemplatePage { + + /** + * Creates a “known Sones” page. + * + * @param template + * The template to render + * @param webInterface + * The Sone web interface + */ + public KnownSonesPage(Template template, WebInterface webInterface) { + super("knownSones.html", template, "Page.KnownSones.Title", webInterface); + } + + // + // TEMPLATEPAGE METHODS + // + + /** + * {@inheritDoc} + */ + @Override + protected void processTemplate(Request request, Template template) throws RedirectException { + super.processTemplate(request, template); + template.set("knownSones", webInterface.core().getKnownSones()); + } + +} diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index e628533..4545ac5 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -160,6 +160,9 @@ public class WebInterface extends AbstractService { Template addSoneTemplate = templateFactory.createTemplate(createReader("/templates/addSone.html")); addSoneTemplate.set("formPassword", formPassword); + Template knownSonesTemplate = templateFactory.createTemplate(createReader("/templates/knownSones.html")); + knownSonesTemplate.set("formPassword", formPassword); + Template createSoneTemplate = templateFactory.createTemplate(createReader("/templates/createSone.html")); createSoneTemplate.set("formPassword", formPassword); @@ -190,6 +193,7 @@ public class WebInterface extends AbstractService { pageToadlets.add(pageToadletFactory.createPageToadlet(new IndexPage(indexTemplate, this), "Index")); pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateSonePage(createSoneTemplate, this), "CreateSone")); pageToadlets.add(pageToadletFactory.createPageToadlet(new AddSonePage(addSoneTemplate, this), "AddSone")); + pageToadlets.add(pageToadletFactory.createPageToadlet(new KnownSonesPage(knownSonesTemplate, this), "KnownSones")); pageToadlets.add(pageToadletFactory.createPageToadlet(new EditProfilePage(editProfileTemplate, this), "EditProfile")); pageToadlets.add(pageToadletFactory.createPageToadlet(new CreatePostPage(createPostTemplate, this))); pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateReplyPage(createReplyTemplate, this))); diff --git a/src/main/resources/i18n/sone.en.properties b/src/main/resources/i18n/sone.en.properties index 7ee2d98..2d3c1d3 100644 --- a/src/main/resources/i18n/sone.en.properties +++ b/src/main/resources/i18n/sone.en.properties @@ -8,6 +8,8 @@ Navigation.Menu.Item.CreateSone.Name=Create Sone Navigation.Menu.Item.CreateSone.Tooltip=Create a new Sone Navigation.Menu.Item.AddSone.Name=Add Sone Navigation.Menu.Item.AddSone.Tooltip=Add a Sone by Freenet URI +Navigation.Menu.Item.KnownSones.Name=Known Sones +Navigation.Menu.Item.KnownSones.Tooltip=Shows all known Sones Navigation.Menu.Item.EditProfile.Name=Edit Profile Navigation.Menu.Item.EditProfile.Tooltip=Edit the Profile of your Sone Navigation.Menu.Item.DeleteSone.Name=Delete Sone @@ -61,6 +63,10 @@ Page.AddSone.Text.ReturnToIndex=Or {link}return to the index{/link}. Page.AddSone.Text.AddAnotherSone=Or you can add another Sone by entering it’s Freenet URI below: Page.AddSone.Button.AddSone=Add Sone +Page.KnownSones.Title=Known Sones - Sone +Page.KnownSones.Page.Title=Known Sones +Page.KnownSones.Text.NoKnownSones=There are currently no known Sones. + Page.EditProfile.Title=Edit Profile - Sone Page.EditProfile.Page.Title=Edit Profile Page.EditProfile.Page.Description=On this page you can enter your profile data. diff --git a/src/main/resources/templates/knownSones.html b/src/main/resources/templates/knownSones.html new file mode 100644 index 0000000..2ff7b82 --- /dev/null +++ b/src/main/resources/templates/knownSones.html @@ -0,0 +1,13 @@ +
+ +

<%= Page.KnownSones.Page.Title|l10n|html>

+ +
+ <%foreach knownSones sone> +
<% sone.niceName|html> (<% sone.requestUri|html>)
+ <%foreachelse> +
<%= Page.KnownSones.Text.NoKnownSones|l10n|html>
+ <%/foreach> +
+ +
-- 2.7.4