From ece28443855fac92ee08cb7fecaa6d513561f67e Mon Sep 17 00:00:00 2001 From: allo Date: Mon, 26 Dec 2005 15:40:09 +0000 Subject: [PATCH] bookmarkManager tagView, Public Flag, next-page git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1249 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/Bookmarks_p.html | 13 ++++++++- htroot/Bookmarks_p.java | 40 ++++++++++++++++++++++---- source/de/anomic/data/bookmarksDB.java | 21 ++++++++++++-- 3 files changed, 66 insertions(+), 8 deletions(-) diff --git a/htroot/Bookmarks_p.html b/htroot/Bookmarks_p.html index 24dd6bccd..51972729f 100644 --- a/htroot/Bookmarks_p.html +++ b/htroot/Bookmarks_p.html @@ -16,6 +16,10 @@ Url:
Title:
Tags(comma separated):
+Public: @@ -23,15 +27,22 @@ Tags(comma separated):
#{bookmarks}# #[title]#
-Tagged with #[tags]# +Tagged with #[tags]#.
+Delete

#{/bookmarks}# +

+#(next-page)# +::next page +#(/next-page)#   +All
#{tags}# #[name]#
#{/tags}# +   diff --git a/htroot/Bookmarks_p.java b/htroot/Bookmarks_p.java index 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 -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);