From: David ‘Bombe’ Roden Date: Wed, 17 Nov 2010 12:46:07 +0000 (+0100) Subject: Add a “Sone rescue mode.” X-Git-Tag: 0.3-RC1~31 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=d09a140deee9781a8e9673618c5f2d91130d896d Add a “Sone rescue mode.” --- diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 1bf6647..ccf2cd3 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -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(false)); options.addBooleanOption("ClearOnNextRestart", new DefaultOption(false)); options.addBooleanOption("ReallyClearOnNextRestart", new DefaultOption(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()); diff --git a/src/main/java/net/pterodactylus/sone/web/OptionsPage.java b/src/main/java/net/pterodactylus/sone/web/OptionsPage.java index 5127611..29ac52b 100644 --- a/src/main/java/net/pterodactylus/sone/web/OptionsPage.java +++ b/src/main/java/net/pterodactylus/sone/web/OptionsPage.java @@ -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()); } diff --git a/src/main/resources/i18n/sone.en.properties b/src/main/resources/i18n/sone.en.properties index 546e774..9cfe916 100644 --- a/src/main/resources/i18n/sone.en.properties +++ b/src/main/resources/i18n/sone.en.properties @@ -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. diff --git a/src/main/resources/templates/options.html b/src/main/resources/templates/options.html index 8221a44..f0baa50 100644 --- a/src/main/resources/templates/options.html +++ b/src/main/resources/templates/options.html @@ -20,6 +20,11 @@

<%= Page.Options.Option.InsertionDelay.Description|l10n|html>

+

<%= Page.Options.Section.RescueOptions.Title|l10n|html>

+ +

<%= Page.Options.Option.SoneRescueMode.Description|l10n|html>

+

+

<%= Page.Options.Section.Cleaning.Title|l10n|html>

<%= Page.Options.Option.ClearOnNextRestart.Description|l10n|html|replace needle="{strong}" replacement=""|replace needle="{/strong}" replacement="">