Add a “Sone rescue mode.”
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 17 Nov 2010 12:46:07 +0000 (13:46 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 17 Nov 2010 12:46:07 +0000 (13:46 +0100)
src/main/java/net/pterodactylus/sone/core/Core.java
src/main/java/net/pterodactylus/sone/web/OptionsPage.java
src/main/resources/i18n/sone.en.properties
src/main/resources/templates/options.html

index 1bf6647..ccf2cd3 100644 (file)
@@ -195,6 +195,16 @@ public class Core implements IdentityListener {
        }
 
        /**
+        * Returns whether the “Sone rescue mode” is currently activated.
+        *
+        * @return {@code true} if the “Sone rescue mode” is currently activated,
+        *         {@code false} if it is not
+        */
+       public boolean isSoneRescueMode() {
+               return options.getBooleanOption("SoneRescueMode").get();
+       }
+
+       /**
         * Returns the identity manager used by the core.
         *
         * @return The identity manager
@@ -1164,6 +1174,7 @@ public class Core implements IdentityListener {
                        }
 
                }));
+               options.addBooleanOption("SoneRescueMode", new DefaultOption<Boolean>(false));
                options.addBooleanOption("ClearOnNextRestart", new DefaultOption<Boolean>(false));
                options.addBooleanOption("ReallyClearOnNextRestart", new DefaultOption<Boolean>(false));
 
@@ -1179,6 +1190,7 @@ public class Core implements IdentityListener {
                }
 
                options.getIntegerOption("InsertionDelay").set(configuration.getIntValue("Option/InsertionDelay").getValue(null));
+               options.getBooleanOption("SoneRescueMode").set(configuration.getBooleanValue("Option/SoneRescueMode").getValue(null));
 
                /* load known Sones. */
                int soneCounter = 0;
@@ -1225,6 +1237,7 @@ public class Core implements IdentityListener {
                /* store the options first. */
                try {
                        configuration.getIntValue("Option/InsertionDelay").setValue(options.getIntegerOption("InsertionDelay").getReal());
+                       configuration.getBooleanValue("Option/SoneRescueMode").setValue(options.getBooleanOption("SoneRescueMode").getReal());
                        configuration.getBooleanValue("Option/ClearOnNextRestart").setValue(options.getBooleanOption("ClearOnNextRestart").getReal());
                        configuration.getBooleanValue("Option/ReallyClearOnNextRestart").setValue(options.getBooleanOption("ReallyClearOnNextRestart").getReal());
 
index 5127611..29ac52b 100644 (file)
@@ -55,6 +55,8 @@ public class OptionsPage extends SoneTemplatePage {
                if (request.getMethod() == Method.POST) {
                        Integer insertionDelay = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("insertion-delay", 16));
                        options.getIntegerOption("InsertionDelay").set(insertionDelay);
+                       boolean soneRescueMode = Boolean.parseBoolean(request.getHttpRequest().getPartAsStringFailsafe("sone-rescue-mode", 5));
+                       options.getBooleanOption("SoneRescueMode").set(soneRescueMode);
                        boolean clearOnNextRestart = Boolean.parseBoolean(request.getHttpRequest().getPartAsStringFailsafe("clear-on-next-restart", 5));
                        options.getBooleanOption("ClearOnNextRestart").set(clearOnNextRestart);
                        boolean reallyClearOnNextRestart = Boolean.parseBoolean(request.getHttpRequest().getPartAsStringFailsafe("really-clear-on-next-restart", 5));
@@ -62,6 +64,7 @@ public class OptionsPage extends SoneTemplatePage {
                        throw new RedirectException(getPath());
                }
                template.set("insertion-delay", options.getIntegerOption("InsertionDelay").get());
+               template.set("sone-rescue-mode", options.getBooleanOption("SoneRescueMode").get());
                template.set("clear-on-next-restart", options.getBooleanOption("ClearOnNextRestart").get());
                template.set("really-clear-on-next-restart", options.getBooleanOption("ReallyClearOnNextRestart").get());
        }
index 546e774..9cfe916 100644 (file)
@@ -27,6 +27,8 @@ Page.Options.Page.Title=Options
 Page.Options.Page.Description=These options influence the runtime behaviour of the Sone plugin.
 Page.Options.Section.RuntimeOptions.Title=Runtime Behaviour
 Page.Options.Option.InsertionDelay.Description=The number of seconds the Sone inserter waits after a modification of a Sone before it is being inserted.
+Page.Options.Section.RescueOptions.Title=Rescue Settings
+Page.Options.Option.SoneRescueMode.Description=Try to rescue your Sones at the next start of the Sone plugin. This will read your all your old Sones from Freenet and ignore any disappearing postings and replies. You have to manually disable the rescue mode once you are satisfied with what has been restored!
 Page.Options.Section.Cleaning.Title=Clean Up
 Page.Options.Option.ClearOnNextRestart.Description=Resets the configuration of the Sone plugin at the next restart. Warning! {strong}This will destroy all of your Sones{/strong} so make sure you have backed up everyhing you still need! Also, you need to set the next option to true to actually do it.
 Page.Options.Option.ReallyClearOnNextRestart.Description=This option needs to be set to “yes” if you really, {strong}really{/strong} want to clear the plugin configuration on the next restart.
index 8221a44..f0baa50 100644 (file)
                <p><%= Page.Options.Option.InsertionDelay.Description|l10n|html></p>
                <p><input type="text" name="insertion-delay" value="<% insertion-delay|html>" /></p>
 
+               <h2><%= Page.Options.Section.RescueOptions.Title|l10n|html></h2>
+
+               <p><%= Page.Options.Option.SoneRescueMode.Description|l10n|html></p>
+               <p><select name="sone-rescue-mode"><option disabled="disabled"><%= WebInterface.SelectBox.Choose|l10n|html></option><option value="true"<%if sone-rescue-mode> selected="selected"<%/if>><%= WebInterface.SelectBox.Yes|l10n|html></option><option value="false"<%if !sone-rescue-mode> selected="selected"<%/if>><%= WebInterface.SelectBox.No|l10n|html></option></select>
+
                <h2><%= Page.Options.Section.Cleaning.Title|l10n|html></h2>
 
                <p><%= Page.Options.Option.ClearOnNextRestart.Description|l10n|html|replace needle="{strong}" replacement="<strong>"|replace needle="{/strong}" replacement="</strong>"></p>