Author: batosai
Date: 2008-08-05 13:23:53 +0000 (Tue, 05 Aug 2008)
New Revision: 21613

Modified:
   trunk/apps/WoT/src/plugins/WoT/WoTplugin.java
Log:
Give people the ability to choose their nickname (docName).

Modified: trunk/apps/WoT/src/plugins/WoT/WoTplugin.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/WoTplugin.java       2008-08-05 12:46:48 UTC 
(rev 21612)
+++ trunk/apps/WoT/src/plugins/WoT/WoTplugin.java       2008-08-05 13:23:53 UTC 
(rev 21613)
@@ -78,9 +78,6 @@
                if(page.equals("/ownidentities")) {
                        return makeOwnIdentitiesPage();
                }
-               if(page.equals("/createIdentity")) {
-                       return makeCreateIdentityPage();
-               }
                else {
                        return makeHomePage();
                }
@@ -96,6 +93,9 @@

                String page = request.getPath().substring(SELF_URI.length());
                if(page.equals("/createIdentity")) {
+                       return 
makeCreateIdentityPage(request.getPartAsString("nickName",1024));
+               }
+               else if(page.equals("/createIdentity2")) {
                        try {
                                OwnIdentity identity = new OwnIdentity( new 
FreenetURI(request.getPartAsString("insertURI",1024)),
                                                                                
                                new 
FreenetURI(request.getPartAsString("requestURI",1024)),
@@ -147,12 +147,12 @@

                ObjectSet<OwnIdentity> ownIdentities = 
db.queryByExample(OwnIdentity.class);
                if(ownIdentities.size() == 0) {
-                       boxContent.addChild("p", "You have no own identites 
yet, you should create one...");
+                       boxContent.addChild("p", "You have no own identities 
yet, you should create one...");
                }
                else {
                        HTMLNode identitiesTable = boxContent.addChild("table", 
"border", "0");
                        HTMLNode row=identitiesTable.addChild("tr");
-                       row.addChild("th", "Request URI");
+                       row.addChild("th", "");
                        row.addChild("th", "Last change");
                        row.addChild("th", "Last insert");
                        row.addChild("th", "Publish TrustList ?");
@@ -160,29 +160,32 @@
                        while(ownIdentities.hasNext()) {
                                OwnIdentity id = ownIdentities.next();
                                row=identitiesTable.addChild("tr");
-                               row.addChild("td", new String[] {"style"}, new 
String[] {"font-size: x-small"}, id.getRequestURI().toString());
+                               row.addChild("td", new String[] {"title", 
"style"}, new String[] {id.getRequestURI().toString(), "cursor: help;"}, 
id.getRequestURI().getDocName());
                                row.addChild("td", 
id.getLastChange().toString());
-                               row.addChild("td", 
id.getLastInsert().toString());
+                               row.addChild("td", 
id.getLastInsert().equals(new Date(0)) ? "never" : 
id.getLastInsert().toString());
                                row.addChild("td", id.PublishesTrustList() ? 
"true" : "false");
                        }
                }

-               boxContent.addChild(new HTMLNode("a", "href", SELF_URI + 
"/createIdentity", "Create a new Identity"));
+               HTMLNode createForm = pr.addFormChild(boxContent, SELF_URI + 
"/createIdentity", "createForm");
+               createForm.addChild("span", new String[] {"title", "style"}, 
new String[] { "No spaces or special characters.", "border-bottom: 1px dotted; 
cursor: help;"} , "NickName : ");
+               createForm.addChild("input", new String[] {"type", "name", 
"size"}, new String[] {"text", "nickName", "30"});
+               createForm.addChild("input", new String[] { "type", "name", 
"value" }, new String[] { "submit", "create", "Create a new identity !" });

                contentNode.addChild(box);
                return pageNode.generate();
        }

-       private String makeCreateIdentityPage() {
+       private String makeCreateIdentityPage(String nickName) {

                HTMLNode pageNode = getPageNode();
                HTMLNode contentNode = pm.getContentNode(pageNode);
                HTMLNode box = pm.getInfobox("Identity creation");
                HTMLNode boxContent = pm.getContentNode(box);

-               FreenetURI[] keypair = client.generateKeyPair("WoT");
+               FreenetURI[] keypair = client.generateKeyPair(nickName);

-               HTMLNode createForm = pr.addFormChild(boxContent, SELF_URI + 
"/createIdentity", "createForm");
+               HTMLNode createForm = pr.addFormChild(boxContent, SELF_URI + 
"/createIdentity2", "createForm");
                createForm.addChild("#", "Request URI : ");
                createForm.addChild("input", new String[] { "type", "name", 
"size", "value" }, new String[] { "text", "requestURI", "70", 
keypair[1].toString() });
                createForm.addChild("br");


Reply via email to