--- /dev/null
+/*
+ * 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);
+ }
+
+}
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);
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)));
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
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
--- /dev/null
+<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>
<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>