bookmarkManager

tagView, Public Flag, next-page

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1249 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
allo 19 years ago
parent 4ac0fd328a
commit ece2844385

@ -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)#
&nbsp;
</td>
<td>
<a href="Bookmarks_p.html">All</a><br />
#{tags}#
<a href="Bookmarks_p.html?tag=#[name]#">#[name]#</a><br />
#{/tags}#
&nbsp;
</td>
</tr>

@ -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;
}

@ -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);

Loading…
Cancel
Save