diff --git a/htroot/Bookmarks_p.html b/htroot/Bookmarks_p.html index cbbbc4443..87141f4b9 100644 --- a/htroot/Bookmarks_p.html +++ b/htroot/Bookmarks_p.html @@ -11,23 +11,28 @@
-Add Bookmark+#(edit)#Add Bookmark::Edit Bookmark#(/edit)# | |
#{bookmarks}#
-#[title]# +#[title]# Tagged with #[tags]#. +Edit / Delete #{/bookmarks}# @@ -39,9 +44,9 @@ Tagged with #[tags]#. |
All -#{tags}# +#{taglist}# #[name]# -#{/tags}# +#{/taglist}# |
diff --git a/htroot/Bookmarks_p.java b/htroot/Bookmarks_p.java
index 9a3f5486f..c80a21cfc 100644
--- a/htroot/Bookmarks_p.java
+++ b/htroot/Bookmarks_p.java
@@ -49,7 +49,6 @@ import java.util.Iterator;
import java.util.Vector;
import de.anomic.data.bookmarksDB;
-import de.anomic.data.bookmarksDB.Bookmark;
import de.anomic.http.httpHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects;
@@ -62,8 +61,13 @@ public class Bookmarks_p {
int MAX_COUNT=10; //TODO: Changeable per Interface
String tag="";
int start=0;
- Vector tagUrlHashes=null;
+ //defaultvalues
+ prop.put("edit", 0);
+ prop.put("title", "");
+ prop.put("url", "");
+ prop.put("tags", "");
+ prop.put("public", 1); //1=is public
if(post != null){
if(post.containsKey("add")){ //add an Entry
String url=(String) post.get("url");
@@ -82,13 +86,25 @@ public class Bookmarks_p {
if(bookmark != null){
bookmark.setProperty(bookmarksDB.Bookmark.BOOKMARK_TITLE, title);
bookmark.setProperty(bookmarksDB.Bookmark.BOOKMARK_PUBLIC, (String) post.get("public"));
- bookmark.setProperty(bookmarksDB.Bookmark.BOOKMARK_TIMESTAMP, String.valueOf(System.currentTimeMillis()));
bookmark.setTags(tags);
bookmark.setBookmarksTable();
}else{
//ERROR
}
}
+ if(post.containsKey("edit")){
+ String urlHash=(String) post.get("edit");
+ bookmarksDB.Bookmark bookmark = switchboard.bookmarksDB.getBookmark(urlHash);
+ prop.put("edit", 1); //edit mode
+ prop.put("title", bookmark.getTitle());
+ prop.put("url", bookmark.getUrl());
+ prop.put("tags", bookmark.getTags());
+ if(bookmark.getPublic()){
+ prop.put("public", 1);
+ }else{
+ prop.put("public", 0);
+ }
+ }
if(post.containsKey("delete")){
String urlHash=(String) post.get("delete");
switchboard.bookmarksDB.removeBookmark(urlHash);
@@ -103,10 +119,10 @@ public class Bookmarks_p {
Iterator it=switchboard.bookmarksDB.tagIterator(true);
int count=0;
while(it.hasNext()){
- prop.put("tags_"+count+"_name", ((bookmarksDB.Tag)it.next()).getTagName());
+ prop.put("taglist_"+count+"_name", ((bookmarksDB.Tag)it.next()).getTagName());
count++;
}
- prop.put("tags", count);
+ prop.put("taglist", count);
count=0;
if(!tag.equals("")){
it=switchboard.bookmarksDB.getBookmarksIterator(tag);
diff --git a/source/de/anomic/data/bookmarksDB.java b/source/de/anomic/data/bookmarksDB.java
index a3d95c9b1..bf869e115 100644
--- a/source/de/anomic/data/bookmarksDB.java
+++ b/source/de/anomic/data/bookmarksDB.java
@@ -49,7 +49,6 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
-import java.util.TreeMap;
import java.util.TreeSet;
import java.util.Vector;
@@ -241,7 +240,6 @@ public class bookmarksDB {
return tagName;
}
public Vector getUrlHashes(){
- System.out.println(this.mem.get(URL_HASHES));
return string2vector((String)this.mem.get(URL_HASHES));
}
public void add(String urlHash){
@@ -303,6 +301,14 @@ public class bookmarksDB {
this.urlHash=plasmaURL.urlHash(url);
mem=new HashMap();
mem.put(BOOKMARK_URL, url);
+ try {
+ Map oldmap= bookmarksTable.get(this.urlHash);
+ mem.put(BOOKMARK_TIMESTAMP, oldmap.get(BOOKMARK_TIMESTAMP)); //preserve timestamp on edit
+ removeBookmark(this.urlHash); //prevent empty tags
+ } catch (IOException e) {
+ //entry not yet present (normal case)
+ mem.put(BOOKMARK_TIMESTAMP, String.valueOf(System.currentTimeMillis()));
+ }
}
public Bookmark(String urlHash, URL url){
this.urlHash=urlHash;
@@ -332,6 +338,13 @@ public class bookmarksDB {
}
return (String) this.mem.get(BOOKMARK_URL);
}
+ public boolean getPublic(){
+ if(this.mem.containsKey(BOOKMARK_PUBLIC)){
+ return ((String) this.mem.get(BOOKMARK_PUBLIC)).equals("public");
+ }else{
+ return false;
+ }
+ }
public void setProperty(String name, String value){
mem.put(name, value);
//setBookmarksTable();