Add possibility to load a Sone by its Freenet URI.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 16 Oct 2010 01:36:00 +0000 (03:36 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 16 Oct 2010 01:36:00 +0000 (03:36 +0200)
src/main/java/net/pterodactylus/sone/web/AddSonePage.java [new file with mode: 0644]
src/main/java/net/pterodactylus/sone/web/WebInterface.java
src/main/resources/i18n/sone.en.properties
src/main/resources/templates/addSone.html [new file with mode: 0644]
src/main/resources/templates/index.html

diff --git a/src/main/java/net/pterodactylus/sone/web/AddSonePage.java b/src/main/java/net/pterodactylus/sone/web/AddSonePage.java
new file mode 100644 (file)
index 0000000..647a635
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Sone - AddSonePage.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.util.template.Template;
+
+/**
+ * This page lets the user add a Sone by URI.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class AddSonePage extends SoneTemplatePage {
+
+       /**
+        * Creates a new “add Sone” page.
+        *
+        * @param template
+        *            The template to render
+        * @param webInterface
+        *            The Sone web interface
+        */
+       public AddSonePage(Template template, WebInterface webInterface) {
+               super("addSone.html", template, "Page.AddSone.Title", webInterface);
+       }
+
+       //
+       // TEMPLATEPAGE METHODS
+       //
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       protected void processTemplate(Request request, Template template) throws RedirectException {
+               super.processTemplate(request, template);
+               String soneKey = request.getHttpRequest().getPartAsStringFailsafe("request-uri", 256);
+               webInterface.core().loadSone(soneKey);
+       }
+
+}
index a0a1c3d..e628533 100644 (file)
@@ -157,6 +157,9 @@ public class WebInterface extends AbstractService {
                Template indexTemplate = templateFactory.createTemplate(createReader("/templates/index.html"));
                indexTemplate.set("formPassword", formPassword);
 
+               Template addSoneTemplate = templateFactory.createTemplate(createReader("/templates/addSone.html"));
+               addSoneTemplate.set("formPassword", formPassword);
+
                Template createSoneTemplate = templateFactory.createTemplate(createReader("/templates/createSone.html"));
                createSoneTemplate.set("formPassword", formPassword);
 
@@ -186,6 +189,7 @@ public class WebInterface extends AbstractService {
                PageToadletFactory pageToadletFactory = new PageToadletFactory(sonePlugin.pluginRespirator().getHLSimpleClient(), "/Sone/");
                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 EditProfilePage(editProfileTemplate, this), "EditProfile"));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new CreatePostPage(createPostTemplate, this)));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateReplyPage(createReplyTemplate, this)));
index c2404f2..e307f33 100644 (file)
@@ -6,6 +6,8 @@ Navigation.Menu.Item.Index.Name=Your Sone
 Navigation.Menu.Item.Index.Tooltip=Show your Sone
 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.EditProfile.Name=Edit Profile
 Navigation.Menu.Item.EditProfile.Tooltip=Edit the Profile of your Sone
 Navigation.Menu.Item.DeleteSone.Name=Delete Sone
@@ -48,6 +50,15 @@ Page.Index.Label.Text=Post text:
 Page.Index.Button.Post=Post!
 Page.Index.PostList.Title=Posts by you and your friends
 Page.Index.PostList.Text.NoPostYet=Nobody has written any posts yet. You should probably start it right now!
+Page.Index.AddSone.Title=Add Sone by Key
+Page.Index.AddSone.Description=Here you can enter the Freenet URI of another Sone that should be loaded.
+Page.Index.AddSone.Button.Add=Add Sone
+
+Page.AddSone.Title=Add Sone - Sone
+Page.AddSone.Page.Title=Add Sone
+Page.AddSone.Text.SoneLoading=The Sone at the given key is now being loaded. Please wait until it appears in your {link}Known Sones.{/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.EditProfile.Title=Edit Profile - Sone
 Page.EditProfile.Page.Title=Edit Profile
diff --git a/src/main/resources/templates/addSone.html b/src/main/resources/templates/addSone.html
new file mode 100644 (file)
index 0000000..d459b02
--- /dev/null
@@ -0,0 +1,17 @@
+<div id="sone">
+
+       <h1><%= Page.AddSone.Page.Title|l10n|html></h1>
+       
+       <div><%= Page.AddSone.Text.SoneLoading|l10n|html|replace needle="{link}" replacement='<a href="knownSones.html">'|replace needle="{/link}" replacement='</a>'></div>
+       
+       <div><%= Page.AddSone.Text.ReturnToIndex|l10n|html|replace needle="{link}" replacement='<a href="index.html">'|replace needle="{/link}" replacement='</a>'></div>
+       
+       <div><%= Page.AddSone.Text.AddAnotherSone|l10n|html></div>
+       
+       <form method="post">
+               <input type="hidden" name="formPassword" value="<% formPassword|html>" />
+               <input type="text" name="request-uri" />
+               <button type="submit"><%= Page.AddSone.Button.AddSone</button>
+       </form>
+
+</div>
index 9573b9d..d148926 100644 (file)
                        <div><%= Page.Index.PostList.Text.NoPostYet|l10n|html></div>
                <%/foreach>
        </div>
+       
+       <h1><%= Page.Index.AddSone.Title|l10n|html></h1>
+       
+       <div><%= Page.Index.AddSone.Description|l10n|html></div>
 
-</div>
\ No newline at end of file
+       <form action="addSone.html" method="post">
+               <input type="hidden" name="formPassword" value="<% formPassword|html>" />
+               <input id="addsone" type="text" name="request-uri" />
+               <button type="submit"><%= Page.Index.AddSone.Button.Add|l10n|html></button>
+       </form>
+</div>