From: David ‘Bombe’ Roden Date: Sat, 16 Oct 2010 01:36:00 +0000 (+0200) Subject: Add possibility to load a Sone by its Freenet URI. X-Git-Tag: 0.1-RC1~296 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=464607ee6c7e508210021e23ad5e5d723c00d608;p=Sone.git Add possibility to load a Sone by its Freenet URI. --- 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 index 0000000..647a635 --- /dev/null +++ b/src/main/java/net/pterodactylus/sone/web/AddSonePage.java @@ -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 . + */ + +package net.pterodactylus.sone.web; + +import net.pterodactylus.util.template.Template; + +/** + * This page lets the user add a Sone by URI. + * + * @author David ‘Bombe’ Roden + */ +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); + } + +} diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index a0a1c3d..e628533 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -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))); diff --git a/src/main/resources/i18n/sone.en.properties b/src/main/resources/i18n/sone.en.properties index c2404f2..e307f33 100644 --- a/src/main/resources/i18n/sone.en.properties +++ b/src/main/resources/i18n/sone.en.properties @@ -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 index 0000000..d459b02 --- /dev/null +++ b/src/main/resources/templates/addSone.html @@ -0,0 +1,17 @@ +
+ +

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

+ +
<%= Page.AddSone.Text.SoneLoading|l10n|html|replace needle="{link}" replacement=''|replace needle="{/link}" replacement=''>
+ +
<%= Page.AddSone.Text.ReturnToIndex|l10n|html|replace needle="{link}" replacement=''|replace needle="{/link}" replacement=''>
+ +
<%= Page.AddSone.Text.AddAnotherSone|l10n|html>
+ +
+ + + +
+ +
diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 9573b9d..d148926 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -52,5 +52,14 @@
<%= Page.Index.PostList.Text.NoPostYet|l10n|html>
<%/foreach> + +

<%= Page.Index.AddSone.Title|l10n|html>

+ +
<%= Page.Index.AddSone.Description|l10n|html>
- \ No newline at end of file +
+ + + +
+