Streamline adding Sones, remove “add Sone” from menu.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 20 Oct 2010 12:56:45 +0000 (14:56 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 20 Oct 2010 12:56:45 +0000 (14:56 +0200)
src/main/java/net/pterodactylus/sone/web/AddSonePage.java
src/main/java/net/pterodactylus/sone/web/WebInterface.java
src/main/resources/i18n/sone.en.properties
src/main/resources/templates/knownSones.html

index 3d5d1f9..9fdf122 100644 (file)
@@ -17,6 +17,7 @@
 
 package net.pterodactylus.sone.web;
 
+import net.pterodactylus.sone.web.page.Page.Request.Method;
 import net.pterodactylus.util.template.Template;
 
 /**
@@ -48,8 +49,12 @@ public class AddSonePage extends SoneTemplatePage {
        @Override
        protected void processTemplate(Request request, Template template) throws RedirectException {
                super.processTemplate(request, template);
-               final String soneKey = request.getHttpRequest().getPartAsStringFailsafe("request-uri", 256);
-               webInterface.core().loadSone(soneKey);
+               if (request.getMethod() == Method.POST) {
+                       String soneKey = request.getHttpRequest().getPartAsStringFailsafe("request-uri", 256);
+                       String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 64);
+                       webInterface.core().loadSone(soneKey);
+                       throw new RedirectException(returnPage);
+               }
        }
 
 }
index 6eb993d..2120096 100644 (file)
@@ -178,7 +178,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 AddSonePage(addSoneTemplate, this)));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new KnownSonesPage(knownSonesTemplate, this), "KnownSones"));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new EditProfilePage(editProfileTemplate, this), "EditProfile"));
                pageToadlets.add(pageToadletFactory.createPageToadlet(new BackupProfilePage(backupProfileTemplate, this)));
index ed1cbd1..d67d3b3 100644 (file)
@@ -6,8 +6,6 @@ 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.KnownSones.Name=Known Sones
 Navigation.Menu.Item.KnownSones.Tooltip=Shows all known Sones
 Navigation.Menu.Item.EditProfile.Name=Edit Profile
index 26a98ac..f26e15a 100644 (file)
@@ -6,6 +6,7 @@
 
        <form action="addSone.html" method="post">
                <input type="hidden" name="formPassword" value="<% formPassword|html>" />
+               <input type="hidden" name="returnPage" value="<% request.url|html>" />
                <input id="addsone" type="text" name="request-uri" />
                <button type="submit"><%= Page.Index.AddSone.Button.Add|l10n|html></button>
        </form>