Author: dbkr
Date: 2006-03-24 23:28:57 +0000 (Fri, 24 Mar 2006)
New Revision: 8308

Modified:
   trunk/freenet/src/freenet/clients/http/BookmarkManager.java
   trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java
   trunk/freenet/src/freenet/clients/http/staticfiles/themes/aqua/theme.css
   trunk/freenet/src/freenet/clients/http/staticfiles/themes/clean/theme.css
   trunk/freenet/src/freenet/node/Version.java
Log:
570: Finally, support for deleting bookmarks from FProxy. Done on a separate 
page which bookmark adding has been moved to.


Modified: trunk/freenet/src/freenet/clients/http/BookmarkManager.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/BookmarkManager.java 2006-03-24 
22:57:51 UTC (rev 8307)
+++ trunk/freenet/src/freenet/clients/http/BookmarkManager.java 2006-03-24 
23:28:57 UTC (rev 8308)
@@ -111,21 +111,15 @@
                }
        }

-       public void removeBookmark(int hashcode) {
-               for (Enumeration e = this.bookmarks.elements(); 
e.hasMoreElements(); ) {
-                       Bookmark i = (Bookmark) e.nextElement();
+       public void removeBookmark(Bookmark b) {
+               if (b.getKeyType().equals("USK")) {
+                       try {
+                               USK u = new USK(b.key);
+                               this.node.uskManager.subscribe(u, this.uskcb, 
true);
+                       } catch (MalformedURLException mue) {

-                       if (i.hashCode() == hashcode) {
-                               if (i.getKeyType().equals("USK")) {
-                                       try {
-                                               USK u = new USK(i.key);
-                                               
this.node.uskManager.subscribe(u, this.uskcb, true);
-                                       } catch (MalformedURLException mue) {
-                                       
-                                       }
-                               }
-                               this.bookmarks.remove(i);
                        }
                }
+               this.bookmarks.remove(b);
        }
 }

Modified: trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java  2006-03-24 
22:57:51 UTC (rev 8307)
+++ trunk/freenet/src/freenet/clients/http/WelcomeToadlet.java  2006-03-24 
23:28:57 UTC (rev 8308)
@@ -99,7 +99,25 @@
                                return;
                        }

-                       this.handleGet(uri, ctx);
+                       try {
+                               this.handleGet(new 
URI("/welcome/?managebookmarks"), ctx);
+                       } catch (URISyntaxException ex) {
+                               
+                       }
+               } else if (request.isParameterSet("managebookmarks")) {
+                       Enumeration e = bookmarks.getBookmarks();
+                       while (e.hasMoreElements()) {
+                               Bookmark b = (Bookmark)e.nextElement();
+                       
+                               if 
(request.isParameterSet("delete_"+b.hashCode())) {
+                                       bookmarks.removeBookmark(b);
+                               }
+                       }
+                       try {
+                               this.handleGet(new 
URI("/welcome/?managebookmarks"), ctx);
+                       } catch (URISyntaxException ex) {
+                               
+                       }
                } else {
                        this.handleGet(uri, ctx);
                }
@@ -128,6 +146,49 @@

                        this.writeReply(ctx, 200, "text/html", "OK", 
buf.toString());
                        return;
+               } else if (request.isParameterSet("managebookmarks")) {
+                       ctx.getPageMaker().makeHead(buf, "Bookmark Manager");
+                       
+                       // existing bookmarks
+                       buf.append("<form action=\".\" method=\"post\">\n");
+                       buf.append("<div class=\"infobox\">\n");
+                       buf.append("<h2>My Bookmarks</h2>\n");
+                       Enumeration e = bookmarks.getBookmarks();
+                       if (!e.hasMoreElements()) {
+                               buf.append("<i>You currently have no bookmarks 
defined</i>");
+                       } else {
+                               buf.append("<ul id=\"bookmarks\">\n");
+                               while (e.hasMoreElements()) {
+                                       Bookmark b = (Bookmark)e.nextElement();
+                               
+                                       buf.append("<li><a 
href=\"/"+HTMLEncoder.encode(b.getKey())+"\">");
+                                       
buf.append(HTMLEncoder.encode(b.getDesc()));
+                                       buf.append("</a>\n");
+                                       buf.append("<input type=\"submit\" 
name=\"delete_"+b.hashCode()+"\" value=\"Delete\" style=\"float: right; \" 
/>\n");
+                                       buf.append("</li>\n");
+                               }
+                               buf.append("</ul>\n");
+                       }
+                       buf.append("<input type=\"hidden\" 
name=\"managebookmarks\" value=\"yes\" />\n");
+                       buf.append("</div>\n");
+                       buf.append("</form>\n");
+                       
+                       // new bookmark
+                       buf.append("<form action=\".\" method=\"post\">\n");
+                       buf.append("<div class=\"infobox\">\n");
+                       buf.append("<h2>New Bookmark</h2>\n");
+                       buf.append("Key: \n");
+                       buf.append("<input type=\"text\" name=\"newbookmark\" 
style=\"width: 100%; \"/>\n");
+                       buf.append("Description: \n");
+                       buf.append("<input type=\"text\" name=\"name\" 
style=\"width: 100%; \"/>\n");
+                       buf.append("<input type=\"submit\" value=\"Add 
Bookmark\"/>\n");
+                       buf.append("</div>\n");
+                       buf.append("</form>\n");
+                       
+                       ctx.getPageMaker().makeTail(buf);
+               
+                       this.writeReply(ctx, 200, "text/html", "OK", 
buf.toString());
+                       return;
                }


@@ -153,27 +214,20 @@
                Enumeration e = bookmarks.getBookmarks();
                if (!e.hasMoreElements()) {
                        buf.append("<i>You currently have no bookmarks 
defined</i>");
+               } else {
+                       buf.append("<ul id=\"bookmarks\">\n");
+                       while (e.hasMoreElements()) {
+                               Bookmark b = (Bookmark)e.nextElement();
+                               
+                               buf.append("<li><a 
href=\"/"+HTMLEncoder.encode(b.getKey())+"\">");
+                               buf.append(HTMLEncoder.encode(b.getDesc()));
+                               buf.append("</a></li>\n");
+                       }
+                       buf.append("</ul>\n");
                }
-               while (e.hasMoreElements()) {
-                       Bookmark b = (Bookmark)e.nextElement();
-                       
-                       buf.append("<a 
href=\"/"+HTMLEncoder.encode(b.getKey())+"\">");
-                       buf.append(HTMLEncoder.encode(b.getDesc()));
-                       buf.append("</a><br />\n");
-               }
-               
-               buf.append("<br />\n");
-               buf.append("<div>\n");
-               buf.append("<form action=\".\" method=\"post\">\n");
-               buf.append("<b>New Bookmark</b>\n");
-               buf.append("<br />\n");
-               buf.append("Key: \n");
-               buf.append("<input type=\"text\" name=\"newbookmark\" 
style=\"width: 100%; \"/>\n");
-               buf.append("Description: \n");
-               buf.append("<input type=\"text\" name=\"name\" style=\"width: 
100%; \"/>\n");
-               buf.append("<input type=\"submit\" value=\"Add Bookmark\"/>\n");
+               buf.append("<div id=\"bookmarkedit\">\n");
+               buf.append("<a href=\"?managebookmarks\" 
class=\"interfacelink\">Edit My Bookmarks</a>\n");
                buf.append("</div>\n");
-               buf.append("</form>\n");
                buf.append("</div>\n");

                // Version info

Modified: 
trunk/freenet/src/freenet/clients/http/staticfiles/themes/aqua/theme.css
===================================================================
--- trunk/freenet/src/freenet/clients/http/staticfiles/themes/aqua/theme.css    
2006-03-24 22:57:51 UTC (rev 8307)
+++ trunk/freenet/src/freenet/clients/http/staticfiles/themes/aqua/theme.css    
2006-03-24 23:28:57 UTC (rev 8308)
@@ -76,6 +76,10 @@
        font-size: 110%;
 }

+.interfacelink {
+       color: black;
+}
+
 #activity {
        list-style-position: inside;
 }

Modified: 
trunk/freenet/src/freenet/clients/http/staticfiles/themes/clean/theme.css
===================================================================
--- trunk/freenet/src/freenet/clients/http/staticfiles/themes/clean/theme.css   
2006-03-24 22:57:51 UTC (rev 8307)
+++ trunk/freenet/src/freenet/clients/http/staticfiles/themes/clean/theme.css   
2006-03-24 23:28:57 UTC (rev 8308)
@@ -3,6 +3,7 @@
        padding:0;
        background-color:#f0f0f0;
        position: relative;
+       font-family:Arial;
 }

 #topbar {
@@ -35,7 +36,6 @@
 }

 #navbar a {
-       font-family:Arial;
        color:#000000;
        text-decoration:underline;
 }
@@ -46,6 +46,7 @@

 #content {
        float:left;
+       max-width: 80%;
 }

 pre, textarea {
@@ -70,6 +71,11 @@
        background-color:#e8e8e8;
 }

+.interfacelink {
+       color:#000000;
+       text-decoration:underline;
+}
+
 #activity {
        list-style-position: inside;
 }

Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-03-24 22:57:51 UTC (rev 
8307)
+++ trunk/freenet/src/freenet/node/Version.java 2006-03-24 23:28:57 UTC (rev 
8308)
@@ -20,7 +20,7 @@
        public static final String protocolVersion = "1.0";

        /** The build number of the current revision */
-       private static final int buildNumber = 569;
+       private static final int buildNumber = 570;

        /** Oldest build of Fred we will talk to */
        private static final int lastGoodBuild = 507;


Reply via email to