Author: nextgens
Date: 2008-09-28 10:32:44 +0000 (Sun, 28 Sep 2008)
New Revision: 22869
Modified:
trunk/freenet/src/freenet/clients/http/FirstTimeWizardToadlet.java
trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
Log:
solves #2624: Show the wizard until dismissed by the user
It will re-display it to everyone... but that's something we want imho
Modified: trunk/freenet/src/freenet/clients/http/FirstTimeWizardToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/FirstTimeWizardToadlet.java
2008-09-27 18:24:34 UTC (rev 22868)
+++ trunk/freenet/src/freenet/clients/http/FirstTimeWizardToadlet.java
2008-09-28 10:32:44 UTC (rev 22869)
@@ -45,7 +45,8 @@
BANDWIDTH,
DATASTORE_SIZE,
MEMORY,
- CONGRATZ;
+ CONGRATZ,
+ FINAL;
}
@@ -271,10 +272,18 @@
congratzInfoboxHeader.addChild("#", l10n("congratz"));
congratzInfoboxContent.addChild("p",
l10n("congratzLong"));
- congratzInfoboxContent.addChild("a", "href", "/",
L10n.getString("FirstTimeWizardToadlet.continueEnd"));
+ congratzInfoboxContent.addChild("a", "href",
"?step="+WIZARD_STEP.FINAL,
L10n.getString("FirstTimeWizardToadlet.continueEnd"));
this.writeHTMLReply(ctx, 200, "OK",
pageNode.generate());
return;
+ } else if(currentStep == WIZARD_STEP.FINAL) {
+ try {
+ config.get("fproxy").set("hasCompletedWizard",
true);
+ this.writeTemporaryRedirect(ctx, "Return to
home", "/");
+ } catch (ConfigException e) {
+ Logger.error(this, e.getMessage(), e);
+ }
+ return;
}
HTMLNode pageNode =
ctx.getPageMaker().getPageNode(l10n("homepageTitle"), false, ctx);
@@ -291,7 +300,7 @@
secondParagraph.addChild("a", "href",
"?step="+WIZARD_STEP.SECURITY_NETWORK).addChild("#",
L10n.getString("FirstTimeWizardToadlet.clickContinue"));
HTMLNode thirdParagraph = welcomeInfoboxContent.addChild("p");
- thirdParagraph.addChild("a", "href", "/").addChild("#",
l10n("skipWizard"));
+ thirdParagraph.addChild("a", "href",
"?step="+WIZARD_STEP.FINAL).addChild("#", l10n("skipWizard"));
this.writeHTMLReply(ctx, 200, "OK", pageNode.generate());
}
Modified: trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
2008-09-27 18:24:34 UTC (rev 22868)
+++ trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
2008-09-28 10:32:44 UTC (rev 22869)
@@ -3,6 +3,7 @@
* http://www.gnu.org/ for further details of the GPL. */
package freenet.clients.http;
+import freenet.config.NodeNeedRestartException;
import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
@@ -69,7 +70,8 @@
private Thread myThread;
private boolean advancedModeEnabled;
private boolean ssl = false;
- private boolean fProxyJavascriptEnabled;
+ private volatile boolean fProxyJavascriptEnabled;
+ private volatile boolean fproxyHasCompletedWizard;
private final PageMaker pageMaker;
private NodeClientCore core;
private final Executor executor;
@@ -385,6 +387,21 @@
new FProxyAdvancedModeEnabledCallback(this));
fproxyConfig.register("javascriptEnabled", false,
configItemOrder++, true, false, "SimpleToadletServer.enableJS",
"SimpleToadletServer.enableJSLong",
new FProxyJavascriptEnabledCallback(this));
+ fproxyConfig.register("hasCompletedWizard", false,
configItemOrder++, true, false, "SimpleToadletServer.hasCompletedWizard",
"SimpleToadletServer.hasCompletedWizardLong",
+ new BooleanCallback() {
+ @Override
+ public Boolean get() {
+ return fproxyHasCompletedWizard;
+ }
+
+ @Override
+ public void set(Boolean val) throws
InvalidConfigValueException, NodeNeedRestartException {
+ if(val == get()) return;
+ fproxyHasCompletedWizard = val;
+ }
+ });
+ fproxyHasCompletedWizard =
fproxyConfig.getBoolean("hasCompletedWizard");
+
fproxyConfig.register("showPanicButton", false,
configItemOrder++, true, true, "SimpleToadletServer.panicButton",
"SimpleToadletServer.panicButtonLong",
new BooleanCallback(){
@Override
@@ -588,13 +605,22 @@
}
public Toadlet findToadlet(URI uri) throws PermanentRedirectException {
- Iterator i = toadlets.iterator();
String path = uri.getPath();
+
+ if(!fproxyHasCompletedWizard) {
+
if(!(path.startsWith(FirstTimeWizardToadlet.TOADLET_URL) ||
+ path.startsWith(StaticToadlet.ROOT_URL)))
+ try {
+ throw new
PermanentRedirectException(new URI(FirstTimeWizardToadlet.TOADLET_URL));
+ } catch(URISyntaxException e) { throw new
Error(e); }
+ }
+
+ Iterator i = toadlets.iterator();
while(i.hasNext()) {
ToadletElement te = (ToadletElement) i.next();
-
+
if(path.startsWith(te.prefix))
- return te.t;
+ return te.t;
if(te.prefix.length() > 0 &&
te.prefix.charAt(te.prefix.length()-1) == '/') {
if(path.equals(te.prefix.substring(0,
te.prefix.length()-1))) {
URI newURI;
Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
===================================================================
--- trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties 2008-09-27
18:24:34 UTC (rev 22868)
+++ trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties 2008-09-28
10:32:44 UTC (rev 22869)
@@ -1127,6 +1127,8 @@
SimpleToadletServer.enableInlinePrefetchLong=This may help if your browser
only uses a small number of connections to talk to the node. On the other hand
it may not.
SimpleToadletServer.enablePersistentConnections=Enable persistent HTTP
connections? (Read detailed description)
SimpleToadletServer.enablePersistentConnectionsLong=Don't enable this unless
your browser is configured to use lots of connections even if they are
persistent.
+SimpleToadletServer.hasCompletedWizard=Have you completed the wizard yet?
+SimpleToadletServer.hasCompletedWizardLong=Have you completed the wizard yet?
If not, fproxy will redirect all your requests to it.
SimpleToadletServer.illegalCSSName=CSS name must not contain slashes or colons!
SimpleToadletServer.panicButton=Show the panic button?
SimpleToadletServer.panicButtonLong=Shows a 'panic button' on the queue page
that will remove all requests with no confirmation.