[freenet-cvs] r13951 - trunk/freenet/src/freenet/clients/http

toad at freenetproject.org toad at freenetproject.org
Fri Jul 6 15:34:53 UTC 2007


Author: toad
Date: 2007-07-06 15:34:53 +0000 (Fri, 06 Jul 2007)
New Revision: 13951

Modified:
   trunk/freenet/src/freenet/clients/http/ConnectionsToadlet.java
   trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
   trunk/freenet/src/freenet/clients/http/OpennetConnectionsToadlet.java
Log:
Don't draw the add peer box on the opennet page. Only draw the noderef box if advanced mode is enabled.

Modified: trunk/freenet/src/freenet/clients/http/ConnectionsToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/ConnectionsToadlet.java	2007-07-06 15:26:03 UTC (rev 13950)
+++ trunk/freenet/src/freenet/clients/http/ConnectionsToadlet.java	2007-07-06 15:34:53 UTC (rev 13951)
@@ -419,38 +419,11 @@
 			// END PEER TABLE
 		}
 
-		// BEGIN PEER ADDITION BOX
-		HTMLNode peerAdditionInfobox = contentNode.addChild("div", "class", "infobox infobox-normal");
-		peerAdditionInfobox.addChild("div", "class", "infobox-header", l10n("addPeerTitle"));
-		HTMLNode peerAdditionContent = peerAdditionInfobox.addChild("div", "class", "infobox-content");
-		HTMLNode peerAdditionForm = ctx.addFormChild(peerAdditionContent, ".", "addPeerForm");
-		peerAdditionForm.addChild("#", l10n("pasteReference"));
-		peerAdditionForm.addChild("br");
-		peerAdditionForm.addChild("textarea", new String[] { "id", "name", "rows", "cols" }, new String[] { "reftext", "ref", "8", "74" });
-		peerAdditionForm.addChild("br");
-		peerAdditionForm.addChild("#", (l10n("urlReference") + ' '));
-		peerAdditionForm.addChild("input", new String[] { "id", "type", "name" }, new String[] { "refurl", "text", "url" });
-		peerAdditionForm.addChild("br");
-		peerAdditionForm.addChild("#", (l10n("fileReference") + ' '));
-		peerAdditionForm.addChild("input", new String[] { "id", "type", "name" }, new String[] { "reffile", "file", "reffile" });
-		peerAdditionForm.addChild("br");
-		peerAdditionForm.addChild("#", (l10n("enterDescription") + ' '));
-		peerAdditionForm.addChild("input", new String[] { "id", "type", "name", "size", "maxlength", "value" }, new String[] { "peerPrivateNote", "text", "peerPrivateNote", "16", "250", "" });
-		peerAdditionForm.addChild("br");
-		peerAdditionForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "add", l10n("add") });
+		drawAddPeerBox(contentNode, ctx);
 		
 		// our reference
-		HTMLNode referenceInfobox = contentNode.addChild("div", "class", "infobox infobox-normal");
-		HTMLNode headerReferenceInfobox = referenceInfobox.addChild("div", "class", "infobox-header");
-		// FIXME better way to deal with this sort of thing???
-		L10n.addL10nSubstitution(headerReferenceInfobox, "DarknetConnectionsToadlet.myReferenceHeader",
-				new String[] { "linkref", "/linkref", "linktext", "/linktext" },
-				new String[] { "<a href=\"myref.fref\">", "</a>", "<a href=\"myref.txt\">", "</a>" });
-		HTMLNode warningSentence = headerReferenceInfobox.addChild("pre");
-		L10n.addL10nSubstitution(warningSentence, "DarknetConnectionsToadlet.referenceCopyWarning",
-				new String[] { "bold", "/bold" },
-				new String[] { "<b>", "</b>" });
-		referenceInfobox.addChild("div", "class", "infobox-content").addChild("pre", "id", "reference", getNoderef().toString() + '\n');
+		if(shouldDrawNoderefBox(advancedModeEnabled))
+			drawNoderefBox(contentNode, ctx);
 		
 		// our ports
 		HTMLNode portInfobox = contentNode.addChild("div", "class", "infobox infobox-normal");
@@ -488,8 +461,28 @@
 	}
 	
 	
+	protected abstract boolean shouldDrawNoderefBox(boolean advancedModeEnabled);
+
+	private void drawNoderefBox(HTMLNode contentNode, ToadletContext ctx) {
+		HTMLNode referenceInfobox = contentNode.addChild("div", "class", "infobox infobox-normal");
+		HTMLNode headerReferenceInfobox = referenceInfobox.addChild("div", "class", "infobox-header");
+		// FIXME better way to deal with this sort of thing???
+		L10n.addL10nSubstitution(headerReferenceInfobox, "DarknetConnectionsToadlet.myReferenceHeader",
+				new String[] { "linkref", "/linkref", "linktext", "/linktext" },
+				new String[] { "<a href=\"myref.fref\">", "</a>", "<a href=\"myref.txt\">", "</a>" });
+		HTMLNode warningSentence = headerReferenceInfobox.addChild("pre");
+		L10n.addL10nSubstitution(warningSentence, "DarknetConnectionsToadlet.referenceCopyWarning",
+				new String[] { "bold", "/bold" },
+				new String[] { "<b>", "</b>" });
+		referenceInfobox.addChild("div", "class", "infobox-content").addChild("pre", "id", "reference", getNoderef().toString() + '\n');
+	}
+
 	protected abstract String getPageTitle(String titleCountString, String myName);
 
+	/** Draw the add a peer box. This comes immediately after the main peers table and before the noderef box.
+	 * Implementors may skip it by not doing anything in this method. */
+	protected abstract void drawAddPeerBox(HTMLNode contentNode, ToadletContext ctx);
+
 	protected Comparator comparator(String sortBy, boolean reversed) {
 		return new ComparatorByStatus(sortBy, reversed);
 	}

Modified: trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java	2007-07-06 15:26:03 UTC (rev 13950)
+++ trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java	2007-07-06 15:34:53 UTC (rev 13951)
@@ -447,5 +447,31 @@
 	protected String getPageTitle(String titleCountString, String myName) {
 		return L10n.getString("DarknetConnectionsToadlet.fullTitle", new String[] { "counts", "name" }, new String[] { titleCountString, node.getMyName() } );
 	}
+	
+	protected void drawAddPeerBox(HTMLNode contentNode, ToadletContext ctx) {
+		// BEGIN PEER ADDITION BOX
+		HTMLNode peerAdditionInfobox = contentNode.addChild("div", "class", "infobox infobox-normal");
+		peerAdditionInfobox.addChild("div", "class", "infobox-header", l10n("addPeerTitle"));
+		HTMLNode peerAdditionContent = peerAdditionInfobox.addChild("div", "class", "infobox-content");
+		HTMLNode peerAdditionForm = ctx.addFormChild(peerAdditionContent, ".", "addPeerForm");
+		peerAdditionForm.addChild("#", l10n("pasteReference"));
+		peerAdditionForm.addChild("br");
+		peerAdditionForm.addChild("textarea", new String[] { "id", "name", "rows", "cols" }, new String[] { "reftext", "ref", "8", "74" });
+		peerAdditionForm.addChild("br");
+		peerAdditionForm.addChild("#", (l10n("urlReference") + ' '));
+		peerAdditionForm.addChild("input", new String[] { "id", "type", "name" }, new String[] { "refurl", "text", "url" });
+		peerAdditionForm.addChild("br");
+		peerAdditionForm.addChild("#", (l10n("fileReference") + ' '));
+		peerAdditionForm.addChild("input", new String[] { "id", "type", "name" }, new String[] { "reffile", "file", "reffile" });
+		peerAdditionForm.addChild("br");
+		peerAdditionForm.addChild("#", (l10n("enterDescription") + ' '));
+		peerAdditionForm.addChild("input", new String[] { "id", "type", "name", "size", "maxlength", "value" }, new String[] { "peerPrivateNote", "text", "peerPrivateNote", "16", "250", "" });
+		peerAdditionForm.addChild("br");
+		peerAdditionForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "add", l10n("add") });
+	}
 
+	protected boolean shouldDrawNoderefBox(boolean advancedModeEnabled) {
+		return true;
+	}
+
 }

Modified: trunk/freenet/src/freenet/clients/http/OpennetConnectionsToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/OpennetConnectionsToadlet.java	2007-07-06 15:26:03 UTC (rev 13950)
+++ trunk/freenet/src/freenet/clients/http/OpennetConnectionsToadlet.java	2007-07-06 15:34:53 UTC (rev 13951)
@@ -48,4 +48,13 @@
 		return L10n.getString("OpennetConnectionsToadlet.fullTitle", new String[] { "counts", "name" }, new String[] { titleCountString, node.getMyName() } );
 	}
 
+	protected void drawAddPeerBox(HTMLNode contentNode, ToadletContext ctx) {
+		// Don't draw the add a peer box, it doesn't work anyway.
+	}
+
+	protected boolean shouldDrawNoderefBox(boolean advancedModeEnabled) {
+		// Developers may want to see the noderef.
+		return advancedModeEnabled;
+	}
+
 }




More information about the cvs mailing list