Author: Jogy
Date: 2006-05-18 14:01:52 +0000 (Thu, 18 May 2006)
New Revision: 8767
Modified:
trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
trunk/freenet/src/freenet/clients/http/Toadlet.java
trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java
Log:
- Put Toadlet.sendErrorPage() messages into a error infobox
- add some HTML-escaping to DarknetConnectionsToadlet
- nifties like changing button-label-casing to "Xxx xxx"
Modified: trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
2006-05-18 13:38:25 UTC (rev 8766)
+++ trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
2006-05-18 14:01:52 UTC (rev 8767)
@@ -258,7 +258,7 @@
buf.append("</table>\n");
}
//
- buf.append("<input type=\"submit\" name=\"disconnect\"
value=\"Disconnect from selected Peers\" />\n");
+ buf.append("<input type=\"submit\" name=\"disconnect\"
value=\"Disconnect from selected peers\" />\n");
buf.append("</form>\n");
buf.append("</div>\n");
buf.append("</div>\n");
@@ -321,7 +321,7 @@
ref += line+"\n";
}
} catch (IOException e) {
- this.sendErrorPage(ctx, 200, "Failed to
Add Node", "Failed to add node: Unable to retrieve node reference from
"+urltext+".");
+ this.sendErrorPage(ctx, 200, "Failed To
Add Node", "Unable to retrieve node reference from " +
HTMLEncoder.encode(urltext) + ".<br /> <a href=\".\">Please try again</a>.");
} finally {
if( in != null ){
in.close();
@@ -332,7 +332,7 @@
// this slightly scary looking regexp chops any
extra characters off the beginning or ends of lines and removes extra line
breaks
ref =
reftext.replaceAll(".*?((?:[\\w,\\.]+\\=[^\r\n]+?)|(?:End))[
\\t]*(?:\\r?\\n)+", "$1\n");
} else {
- this.sendErrorPage(ctx, 200, "Failed to Add
Node", "Failed to add node: Could not detect either a node reference or a URL.
Please <a href=\".\">Try again</a>.");
+ this.sendErrorPage(ctx, 200, "Failed To Add
Node", "Could not detect either a node reference or a URL.<br /> <a
href=\".\">Please try again</a>.");
request.freeParts();
return;
}
@@ -345,25 +345,25 @@
try {
fs = new SimpleFieldSet(ref, true);
} catch (IOException e) {
- this.sendErrorPage(ctx, 200, "Failed to add
node", "Unable to parse the given text: <pre>"+ref+"</pre> as a node reference:
"+e+" Please <a href=\".\">Try again</a>.");
+ this.sendErrorPage(ctx, 200, "Failed To Add
Node", "Unable to parse the given text: <pre>" + HTMLEncoder.encode(ref) +
"</pre> as a node reference: "+HTMLEncoder.encode(e.toString())+".<br /> <a
href=\".\">Please try again</a>.");
return;
}
PeerNode pn;
try {
pn = new PeerNode(fs, this.node, false);
} catch (FSParseException e1) {
- this.sendErrorPage(ctx, 200, "Failed to add
node", "Unable to parse the given text: <pre>"+ref+"</pre> as a node reference:
"+e1+". Please <a href=\".\">Try again</a>.");
+ this.sendErrorPage(ctx, 200, "Failed To Add
Node", "Unable to parse the given text: <pre>" + HTMLEncoder.encode(ref) +
"</pre> as a node reference: " + HTMLEncoder.encode(e1.toString()) + ".<br />
Please <a href=\".\">Try again</a>");
return;
} catch (PeerParseException e1) {
- this.sendErrorPage(ctx, 200, "Failed to add
node", "Unable to parse the given text: <pre>"+ref+"</pre> as a node reference:
"+e1+". Please <a href=\".\">Try again</a>.");
+ this.sendErrorPage(ctx, 200, "Failed To Add
Node", "Unable to parse the given text: <pre>" + HTMLEncoder.encode(ref) +
"</pre> as a node reference: " + HTMLEncoder.encode(e1.toString()) + ".<br />
Please <a href=\".\">Try again</a>");
return;
}
if(pn.getIdentity()==node.getIdentity()) {
- this.sendErrorPage(ctx, 200, "Referencing to
self", "You can't add your own node to the list of remote peers. Return to the
connections page <a href=\".\">here</a>.");
+ this.sendErrorPage(ctx, 200, "Failed To Add
Node", "You can't add your own node to the list of remote peers.<br /> <a
href=\".\">Return to the connections page</a>");
return;
}
if(!this.node.addDarknetConnection(pn)) {
- this.sendErrorPage(ctx, 200, "Failed to add
node", "We already have the given reference. Return to the connections page <a
href=\".\">here</a>.");
+ this.sendErrorPage(ctx, 200, "Failed To Add
Node", "We already have the given reference.<br /> <a href=\".\">Return to the
connections page</a>");
return;
}
} else if (request.isPartSet("disconnect")) {
@@ -378,5 +378,4 @@
}
this.handleGet(uri, ctx);
}
-
}
Modified: trunk/freenet/src/freenet/clients/http/Toadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/Toadlet.java 2006-05-18 13:38:25 UTC
(rev 8766)
+++ trunk/freenet/src/freenet/clients/http/Toadlet.java 2006-05-18 14:01:52 UTC
(rev 8767)
@@ -167,7 +167,16 @@
StringBuffer buf = new StringBuffer();
ctx.getPageMaker().makeHead(buf, desc);
+ //
+ buf.append("<div class=\"infobox infobox-error\">\n");
+ buf.append("<div class=\"infobox-header\">\n");
+ buf.append(desc);
+ buf.append("</div>\n");
+ buf.append("<div class=\"infobox-content\">\n");
buf.append(message);
+ //
+ buf.append("</div>\n");
+ buf.append("</div>\n");
ctx.getPageMaker().makeTail(buf);
writeReply(ctx, code, "text/html", desc, buf.toString());
}
Modified: trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java 2006-05-18
13:38:25 UTC (rev 8766)
+++ trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java 2006-05-18
14:01:52 UTC (rev 8767)
@@ -87,7 +87,7 @@
buf.append("Are you sure you wish to shut down your
Freenet node?\n");
buf.append("<form action=\"/\" method=\"post\">\n");
buf.append("<input type=\"submit\" name=\"cancel\"
value=\"Cancel\" />\n");
- buf.append("<input type=\"submit\"
name=\"shutdownconfirm\" value=\"Shut Down\" />\n");
+ buf.append("<input type=\"submit\"
name=\"shutdownconfirm\" value=\"Shut down\" />\n");
buf.append("</form>\n");
buf.append("</div>\n");
buf.append("</div>\n");
@@ -236,7 +236,7 @@
buf.append("Description:\n");
buf.append("<input type=\"text\" name=\"name\"
value=\""+HTMLEncoder.encode(request.getParam("desc"))+"\" style=\"width: 100%;
\" />\n");
buf.append("<input type=\"hidden\" name=\"key\"
value=\""+HTMLEncoder.encode(request.getParam("newbookmark"))+"\" />\n");
- buf.append("<input type=\"submit\" name=\"addbookmark\"
value=\"Add Bookmark\" />\n");
+ buf.append("<input type=\"submit\" name=\"addbookmark\"
value=\"Add bookmark\" />\n");
buf.append("</form>\n");
buf.append("</div>\n");
buf.append("</div>\n");
@@ -450,12 +450,12 @@
buf.append("<br />\n");
if (mode == MODE_ADD) {
- buf.append("<input type=\"submit\" name=\"addbookmark\"
value=\"Add Bookmark\" class=\"confirm\" />\n");
+ buf.append("<input type=\"submit\" name=\"addbookmark\"
value=\"Add bookmark\" class=\"confirm\" />\n");
} else {
- buf.append("<input type=\"submit\"
name=\"update_"+b.hashCode()+"\" value=\"Update Bookmark\" class=\"confirm\"
/>\n");
+ buf.append("<input type=\"submit\"
name=\"update_"+b.hashCode()+"\" value=\"Update bookmark\" class=\"confirm\"
/>\n");
}
- buf.append("<input type=\"submit\" value=\"Cancel\"
class=\"cancel\" />\n");
+ buf.append("<input type=\"submit\" value=\"Cancel\"
class=\"cancel\" />\n");
buf.append("<input type=\"hidden\" name=\"managebookmarks\"
value=\"yes\" />\n");
buf.append("</div>\n");
buf.append("</form>\n");
@@ -468,4 +468,3 @@
return "GET, POST";
}
}
-