diff --git a/htroot/api/bookmarks/tags/addTag.java b/htroot/api/bookmarks/tags/addTag.java
new file mode 100644
index 000000000..fecc05e56
--- /dev/null
+++ b/htroot/api/bookmarks/tags/addTag.java
@@ -0,0 +1,30 @@
+
+import de.anomic.http.httpRequestHeader;
+import de.anomic.plasma.plasmaSwitchboard;
+import de.anomic.server.serverObjects;
+import de.anomic.server.serverSwitch;
+import de.anomic.data.bookmarksDB.Bookmark;
+
+
+public class addTag {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch> env) {
+ // return variable that accumulates replacements
+ final plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
+ final serverObjects prop = new serverObjects();
+ prop.put("result", "0");//error
+ //rename tags
+ if(post != null) {
+ if (post.containsKey("selectTag") && post.containsKey("addTag")) {
+ switchboard.bookmarksDB.addTag(post.get("selectTag"), post.get("addTag"));
+ prop.put("result", "1");//success
+ } else if (post.containsKey("urlhash") && post.containsKey("addTag")) {
+ final Bookmark bm = switchboard.bookmarksDB.getBookmark(post.get("urlhash"));
+ bm.addTag(post.get("addTag"));
+ prop.put("result", "1");//success
+ }
+ }
+ // return rewrite properties
+ return prop;
+ }
+
+}
\ No newline at end of file
diff --git a/htroot/api/bookmarks/tags/addTag.xml b/htroot/api/bookmarks/tags/addTag.xml
new file mode 100644
index 000000000..ec81dd621
--- /dev/null
+++ b/htroot/api/bookmarks/tags/addTag.xml
@@ -0,0 +1,2 @@
+
+#(result)#something went wrong::done#(/result)#
\ No newline at end of file
diff --git a/htroot/api/bookmarks/tags/editTag.java b/htroot/api/bookmarks/tags/editTag.java
new file mode 100755
index 000000000..ab41d1e7a
--- /dev/null
+++ b/htroot/api/bookmarks/tags/editTag.java
@@ -0,0 +1,22 @@
+
+import de.anomic.http.httpRequestHeader;
+import de.anomic.plasma.plasmaSwitchboard;
+import de.anomic.server.serverObjects;
+import de.anomic.server.serverSwitch;
+
+public class editTag {
+ public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch> env) {
+ // return variable that accumulates replacements
+ final plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
+ final serverObjects prop = new serverObjects();
+ prop.put("result", "0");//error
+ //rename tags
+ if(post != null && post.containsKey("old") && post.containsKey("new")){
+ if(switchboard.bookmarksDB.renameTag(post.get("old"), post.get("new")))
+ prop.put("result", "1");//success
+ }
+ // return rewrite properties
+ return prop;
+ }
+
+}
diff --git a/htroot/api/bookmarks/tags/editTag.xml b/htroot/api/bookmarks/tags/editTag.xml
new file mode 100644
index 000000000..a9a7241c5
--- /dev/null
+++ b/htroot/api/bookmarks/tags/editTag.xml
@@ -0,0 +1,2 @@
+
+#(result)#something went wrong::done#(/result)#
diff --git a/htroot/yacy/ui/css/base.css b/htroot/yacy/ui/css/base.css
index beacd0d77..3d673a4bd 100644
--- a/htroot/yacy/ui/css/base.css
+++ b/htroot/yacy/ui/css/base.css
@@ -158,6 +158,15 @@ img.help {
.flexigrid div.fbutton .load {
background: url(../img/flexigrid/load.png) no-repeat center left;
}
+.flexigrid div.fbutton .addTag {
+ background: url(../img/tags/tag_blue_add.png) no-repeat center left;
+}
+.flexigrid div.fbutton .editTag {
+ background: url(../img/tags/tag_blue_edit.png) no-repeat center left;
+}
+.flexigrid div.fbutton .deleteTag {
+ background: url(../img/tags/tag_blue_delete.png) no-repeat center left;
+}
/* YaCy Bookmarks ---------------------------*/
.url {
diff --git a/htroot/yacy/ui/index.html b/htroot/yacy/ui/index.html
index dd62c897a..55c8c17d9 100644
--- a/htroot/yacy/ui/index.html
+++ b/htroot/yacy/ui/index.html
@@ -40,12 +40,22 @@
diff --git a/htroot/yacy/ui/yacyui-welcome.html b/htroot/yacy/ui/yacyui-welcome.html
index c3b6e3ff6..8589a4123 100644
--- a/htroot/yacy/ui/yacyui-welcome.html
+++ b/htroot/yacy/ui/yacyui-welcome.html
@@ -8,6 +8,7 @@
apfelmaennchen
Change Log
+ - 27-01-2009: added two dialogs for managing tags (finally fixed the renameTag() method in bookmarksDB)
- 26-01-2009: reworked search interface, still has timing problems, but now uses yacysearch.json and has full support for flexigrid
- 25-01-2009: bookmark folders sidebar is now directly linked to flexigrid if bookmark tab is selected
- 25-01-2009: successfully migrated bookmark folders to treeview.async mode (==> new json api)
diff --git a/source/de/anomic/data/bookmarksDB.java b/source/de/anomic/data/bookmarksDB.java
index 0b02ecc41..c1f1005ea 100644
--- a/source/de/anomic/data/bookmarksDB.java
+++ b/source/de/anomic/data/bookmarksDB.java
@@ -719,32 +719,35 @@ public class bookmarksDB {
// -------------------------------------
public boolean renameTag(final String oldName, final String newName){
-
- final String oldHash=tagHash(oldName);
- //String newHash=tagHash(newName);
- final Tag tag=getTag(oldHash); // set tag to oldHash
- if (tag != null) {
- final Set urlHashes = tag.getUrlHashes(); // preserve urlHashes of tag
- removeTag(oldHash);
- final Iterator it = urlHashes.iterator();
- Bookmark bookmark;
- Set tags;
- String tagsString;
- while (it.hasNext()) { // looping through all bookmarks which were tagged with oldName
+
+ final Tag oldTag=getTag(tagHash(oldName));
+ if (oldTag != null) {
+ final Set urlHashes = oldTag.getUrlHashes(); // preserve urlHashes of oldTag
+ removeTag(tagHash(oldName)); // remove oldHash from TagsDB
+ final Iterator it = urlHashes.iterator();
+ Bookmark bookmark;
+ Set tags = new TreeSet(String.CASE_INSENSITIVE_ORDER);
+ while (it.hasNext()) { // looping through all bookmarks which were tagged with oldName
bookmark = getBookmark(it.next());
- tagsString = bookmark.getTagsString();
- // Set tags is difficult with case sensitivity, so I tried
- // Set tags = new TreeSet(String.CASE_INSENSITIVE_ORDER), but it didn't do the trick :-(
- // so I chose the tagsString and replaceAll() as workaround
- // unfortunately doing the replaceAll with Patterns (regexp) really costs performance
- tags=listManager.string2set(Pattern.compile(oldName,66).matcher(tagsString).replaceAll(newName)); // TODO: need better solution for renaming tags
- bookmark.setTags(tags, true); // I had to adjust setTags() for this to work
+ tags = bookmark.getTags();
+ tags.remove(oldName);
+ bookmark.setTags(tags, true); // might not be needed, but doesn't hurt
+ if(!newName.equals("")) bookmark.addTag(newName);
saveBookmark(bookmark);
}
return true;
}
return false;
}
+ public void addTag(final String selectTag, final String newTag){
+ final Iterator it = getTag(tagHash(selectTag)).getUrlHashes().iterator(); // get urlHashes for selectTag
+ Bookmark bookmark;
+ while (it.hasNext()) { // looping through all bookmarks which were tagged with selectTag
+ bookmark = getBookmark(it.next());
+ bookmark.addTag(newTag);
+ }
+ }
+
// --------------------------------------
// bookmarksDB's Import/Export functions
@@ -1071,11 +1074,10 @@ public class bookmarksDB {
public Bookmark(final String urlHash, final Map map) {
this.entry = map;
- this.urlHash=urlHash;
+ this.urlHash=urlHash;
+ tags=new TreeSet(String.CASE_INSENSITIVE_ORDER);
if(map.containsKey(BOOKMARK_TAGS))
- tags=listManager.string2set(map.get(BOOKMARK_TAGS));
- else
- tags=new HashSet();
+ tags.addAll(listManager.string2set(map.get(BOOKMARK_TAGS)));
loadTimestamp();
}
@@ -1230,8 +1232,9 @@ public class bookmarksDB {
//setBookmarksTable();
}
- public void addTag(final String tag){
- tags.add(tag);
+ public void addTag(final String tagName){
+ tags.add(tagName);
+ setTags(tags);
}
/**