Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
bookmarkManager tagView, Public Flag, next-page
alloece28443855f
diff --git a/htroot/Bookmarks_p.html b/htroot/Bookmarks_p.htmlindex 24dd6bccd..51972729f 100644--- a/htroot/Bookmarks_p.html+++ b/htroot/Bookmarks_p.html@@ -16,6 +16,10 @@Url: <input type="text" name="url"><br />Title: <input type="text" name="title"><br />Tags(comma separated): <input type="text" name="tags"><br />+Public: <select name="public">+<option value="public ">yes</option>+<option value="private" selected>no</option>+</select><input type="submit" name="add" value="create"></form></td></tr>@@ -23,15 +27,22 @@ Tags(comma separated): <input type="text" name="tags"><br /><td width="100%">#{bookmarks}#<a href="#[link]#">#[title]#</a><br />-Tagged with #[tags]#+Tagged with #[tags]#. <br />+<a href="Bookmarks_p.html?delete=#[hash]#">Delete</a><p />#{/bookmarks}#+<p />+#(next-page)#+::<a href="Bookmarks_p.html?tag=#[tag]#&start=#[start]#">next page</a>+#(/next-page)# </td><td>+<a href="Bookmarks_p.html">All</a><br />#{tags}#<a href="Bookmarks_p.html?tag=#[name]#">#[name]#</a><br />#{/tags}#+ </td></tr>diff --git a/htroot/Bookmarks_p.java b/htroot/Bookmarks_p.javaindex 8ce884d08..1a96120d3 100644--- a/htroot/Bookmarks_p.java+++ b/htroot/Bookmarks_p.java@@ -59,6 +59,9 @@ public class Bookmarks_p {public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {serverObjects prop = new serverObjects();plasmaSwitchboard switchboard = (plasmaSwitchboard) env;+ int MAX_COUNT=10; //TODO: Changeable per Interface+ String tag="";+ int start=0;if(post != null){if(post.containsKey("add")){ //add an Entry@@ -71,9 +74,20 @@ public class Bookmarks_p {}bookmarksDB.Bookmark bookmark = switchboard.bookmarksDB.createBookmark(url);- bookmark.setProperty("title", title);- bookmark.setTags(tags);- bookmark.setBookmarksTable();+ if(bookmark != null){+ bookmark.setProperty(bookmarksDB.Bookmark.BOOKMARK_TITLE, title);+ bookmark.setProperty(bookmarksDB.Bookmark.BOOKMARK_PUBLIC, (String) post.get("public"));+ bookmark.setTags(tags);+ bookmark.setBookmarksTable();+ }else{+ //ERROR+ }+ }+ if(post.containsKey("tag")){+ tag=(String) post.get("tag");+ }+ if(post.containsKey("start")){+ start=Integer.parseInt((String) post.get("start"));}}Iterator it=switchboard.bookmarksDB.tagIterator(true);@@ -84,9 +98,20 @@ public class Bookmarks_p {}prop.put("tags", count);count=0;- it=switchboard.bookmarksDB.bookmarkIterator(true);+ if(!tag.equals("")){+ it=switchboard.bookmarksDB.getTag(tag).iterator();+ }else{+ it=switchboard.bookmarksDB.bookmarkIterator(true);+ }bookmarksDB.Bookmark bookmark;- while(it.hasNext() && count<10){+ //skip the first entries (display next page)+ count=0;+ while(count < start && it.hasNext()){+ it.next();+ count++;+ }+ count=0;+ while(count<MAX_COUNT && it.hasNext()){bookmark=(Bookmark) it.next();if(bookmark!=null){prop.put("bookmarks_"+count+"_link", bookmark.getUrl());@@ -95,6 +120,11 @@ public class Bookmarks_p {count++;}}+ if(it.hasNext()){+ prop.put("next-page", 1);+ prop.put("next-page_start", start+10);+ prop.put("next-page_tag", tag);+ }prop.put("bookmarks", count);return prop;}diff --git a/source/de/anomic/data/bookmarksDB.java b/source/de/anomic/data/bookmarksDB.javaindex d469c808f..9cf8458e1 100644--- a/source/de/anomic/data/bookmarksDB.java+++ b/source/de/anomic/data/bookmarksDB.java@@ -122,7 +122,11 @@ public class bookmarksDB {}private Vector string2vector(String string){Vector ret=new Vector();- ret.copyInto(string.split(","));+ if(string.indexOf(",") > -1){+ ret.copyInto(string.split(","));+ }else{+ ret = new Vector();+ }return ret;}public Tag getTag(String tagName){@@ -213,7 +217,13 @@ public class bookmarksDB {return string2vector((String)this.mem.get(URL_HASHES));}public void add(String urlHash){- Vector list=string2vector((String)this.mem.get(URL_HASHES));+ String urlHashes = (String)this.mem.get(URL_HASHES);+ Vector list;+ if(urlHashes != null){+ list=string2vector(urlHashes);+ }else{+ list=new Vector();+ }list.add(urlHash);this.mem.put(URL_HASHES, vector2string(list));}@@ -229,6 +239,9 @@ public class bookmarksDB {bookmarksDB.this.tagsTable.set(getTagName(), mem);} catch (IOException e) {}}+ public Iterator iterator(){+ return string2vector((String) this.mem.get(URL_HASHES)).iterator();+ }}/*** Subclass, which stores the bookmark@@ -238,6 +251,7 @@ public class bookmarksDB {public static final String BOOKMARK_URL="bookmarkUrl";public static final String BOOKMARK_TITLE="bookmarkTitle";public static final String BOOKMARK_TAGS="bookmarkTags";+ public static final String BOOKMARK_PUBLIC="bookmarkPublic";private String urlHash;private Map mem;public Bookmark(String urlHash, Map map){@@ -245,6 +259,9 @@ public class bookmarksDB {this.mem=map;}public Bookmark(String url){+ if(!url.toLowerCase().startsWith("http://")){+ url="http://"+url;+ }this.urlHash=plasmaURL.urlHash(url);mem=new HashMap();mem.put(BOOKMARK_URL, url);