Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
on bookmaring of search result, remember orig. query in separate bookmark property (instead of using the description field) - adjust display and autosearch - don't overwrite existing bookmark but combine info
reger8a5b8f878996
diff --git a/htroot/Bookmarks.html b/htroot/Bookmarks.htmlindex 22701bf1f..d983920a2 100644--- a/htroot/Bookmarks.html+++ b/htroot/Bookmarks.html@@ -251,6 +251,7 @@ To see a list of all APIs, please visit the <a href="http://www.yacy-websuche.de<a href="#[link]#" class="bookmarkTitle">#[title]#</a></h4><p class="bookmarkDescription">#[description]#</p>+ #(hasquery)#::<p class="bookmarkDescription">query=#[query]#</p>#(/hasquery)#<p class="tags">Tagged with | #{tags}#<a href="Bookmarks.html?tag=#[tag]#" class="bookmarkTags">#[tag]#</a> | #{/tags}#</p><p class="bookmarkActions"><a href="Bookmarks.html?edit=#[hash]#" class="bookmarkAction">Edit</a>@@ -258,6 +259,10 @@ To see a list of all APIs, please visit the <a href="http://www.yacy-websuche.de<a href="Bookmarks.html?delete=#[hash]#" class="bookmarkAction" onclick="return confirm('Confirm deletion')">Delete</a>/<a href="api/getpageinfo_p.xml?url=#[link]#" class="bookmarkAction">Info</a>+ #(hasquery)#::+ /+ <a href="yacysearch.html?query=#[query]#" class="bookmarkAction">search</a>+ #(/hasquery)#</p></div>#{/bookmarks}#diff --git a/htroot/Bookmarks.java b/htroot/Bookmarks.javaindex d7fc531e6..097f59f97 100644--- a/htroot/Bookmarks.java+++ b/htroot/Bookmarks.java@@ -152,7 +152,7 @@ public class Bookmarks {}tagsString = tagsString + "," + pathString;final Set<String> tags=ListManager.string2set(BookmarkHelper.cleanTagsString(tagsString));- final BookmarksDB.Bookmark bookmark = sb.bookmarksDB.createBookmark(url, username);+ final BookmarksDB.Bookmark bookmark = sb.bookmarksDB.createorgetBookmark(url, username);if (bookmark != null) {bookmark.setProperty(BookmarksDB.Bookmark.BOOKMARK_TITLE, title);@@ -326,6 +326,12 @@ public class Bookmarks {}prop.putHTML("display_bookmarks_"+count+"_title", bookmark.getTitle());prop.putHTML("display_bookmarks_"+count+"_description", bookmark.getDescription());+ if (bookmark.getQuery() == null) {+ prop.put("display_bookmarks_"+count+"_hasquery", false);+ } else {+ prop.put("display_bookmarks_"+count+"_hasquery", true);+ prop.put("display_bookmarks_"+count+"_hasquery_query", bookmark.getQuery());+ }prop.put("display_bookmarks_"+count+"_date", ISO8601Formatter.FORMATTER.format(new Date(bookmark.getTimeStamp())));prop.put("display_bookmarks_"+count+"_rfc822date", HeaderFramework.formatRFC1123(new Date(bookmark.getTimeStamp())));prop.put("display_bookmarks_"+count+"_public", (bookmark.getPublic() ? "1" : "0"));@@ -477,7 +483,7 @@ public class Bookmarks {bookmark = sb.bookmarksDB.getBookmark(bit.next());} catch (final IOException e) {}- if (bookmark == null) break;+ if (bookmark == null) break;prop.put("display_folderlist_" + count + "_folder", "<li><a href=\"" + bookmark.getUrl() + "\" title=\"" + bookmark.getDescription() + "\">" + bookmark.getTitle() + "</a></li>");count++;}diff --git a/htroot/api/bookmarks/posts/add_p.java b/htroot/api/bookmarks/posts/add_p.javaindex 0fd74debd..d41a4357c 100644--- a/htroot/api/bookmarks/posts/add_p.java+++ b/htroot/api/bookmarks/posts/add_p.java@@ -47,7 +47,7 @@ public class add_p {final String pathString = post.get("path","/unsorted");tagsString= tagsString + "," + pathString;final Set<String> tags = ListManager.string2set(BookmarkHelper.cleanTagsString(tagsString));- final BookmarksDB.Bookmark bookmark = sb.bookmarksDB.createBookmark(url, username);+ final BookmarksDB.Bookmark bookmark = sb.bookmarksDB.createorgetBookmark(url, username);if(bookmark != null){bookmark.setProperty(BookmarksDB.Bookmark.BOOKMARK_TITLE, title);bookmark.setProperty(BookmarksDB.Bookmark.BOOKMARK_DESCRIPTION, description);diff --git a/htroot/yacysearch.java b/htroot/yacysearch.javaindex 8494ab05e..31740bcdb 100644--- a/htroot/yacysearch.java+++ b/htroot/yacysearch.java@@ -594,9 +594,8 @@ public class yacysearch {final String urlstr = crypt.simpleDecode(post.get("bookmarkurl"));if (urlstr != null) {try {- final Bookmark bmk = sb.bookmarksDB.createBookmark(urlstr, YMarkTables.USER_ADMIN);- bmk.setProperty(Bookmark.BOOKMARK_DESCRIPTION, "query="+querystring);- //bmk.setProperty(Bookmark.BOOKMARK_QUERY, originalquerystring);+ final Bookmark bmk = sb.bookmarksDB.createorgetBookmark(urlstr, YMarkTables.USER_ADMIN);+ bmk.setProperty(Bookmark.BOOKMARK_QUERY, querystring);bmk.addTag("/search"); // add to bookmark folderbmk.addTag("searchresult"); // add tagString urlhash = post.get("bookmarkref");diff --git a/source/net/yacy/data/BookmarksDB.java b/source/net/yacy/data/BookmarksDB.javaindex f6a394afd..8560dd5f3 100644--- a/source/net/yacy/data/BookmarksDB.java+++ b/source/net/yacy/data/BookmarksDB.java@@ -35,6 +35,8 @@ import java.util.Map;import java.util.Set;import java.util.TreeSet;import java.util.concurrent.ConcurrentHashMap;+import java.util.logging.Level;+import java.util.logging.Logger;import net.yacy.cora.document.encoding.ASCII;import net.yacy.cora.document.encoding.UTF8;@@ -126,11 +128,25 @@ public class BookmarksDB {// bookmarksDB's functions for bookmarksTable / bookmarkCache// ------------------------------------------------------------ public Bookmark createBookmark(final String url, final String user){+ /**+ * create or get existing bookmark+ * @param url+ * @param user+ * @return+ */+ public Bookmark createorgetBookmark(final String url, final String user){if (url == null || url.isEmpty()) return null;Bookmark bk;try {- bk = new Bookmark(url);+ try {+ DigestURL durl = new DigestURL((url.indexOf("://") < 0) ? "http://" + url : url);+ bk = this.getBookmark(ASCII.String(durl.hash()));+ } catch (IOException ex) {+ bk = null;+ }+ if (bk == null) {+ bk = new Bookmark(url);+ }bk.setOwner(user);return (bk.getUrlHash() == null || bk.toMap() == null) ? null : bk;} catch (final MalformedURLException e) {@@ -461,6 +477,7 @@ public class BookmarksDB {private static final String BOOKMARK_TIMESTAMP = "bookmarkTimestamp";private static final String BOOKMARK_OWNER = "bookmarkOwner";private static final String BOOKMARK_IS_FEED = "bookmarkIsFeed";+ public static final String BOOKMARK_QUERY = "bookmarkQuery"; // tag for original search string if bookmark was created from search resultprivate final String urlHash;private Set<String> tagNames;private long timestamp;@@ -587,6 +604,18 @@ public class BookmarksDB {return false;}+ /**+ * get the original query string (if bookmark was created from a search result original query is stored as a bookmark property)+ * or null if not exist+ * @return query-string or null+ */+ public String getQuery() {+ if (this.entry.containsKey(BOOKMARK_QUERY)) {+ return this.entry.get(BOOKMARK_QUERY);+ }+ return null;+ }+public void setPublic(final boolean isPublic){if(isPublic){this.entry.put(BOOKMARK_PUBLIC, "public");diff --git a/source/net/yacy/search/AutoSearch.java b/source/net/yacy/search/AutoSearch.javaindex bd0a071de..2f42ac65e 100644--- a/source/net/yacy/search/AutoSearch.java+++ b/source/net/yacy/search/AutoSearch.java@@ -166,12 +166,12 @@ public class AutoSearch extends AbstractBusyThread {if (bmk.getFoldersString().startsWith("/search")) {// take only new created or edited bookmarksif (bmk.getTimeStamp() >= this.lastInitTime) {- final String query = bmk.getDescription();- if (!query.isEmpty() && query.startsWith("query=")) {+ final String query = bmk.getQuery();+ if (query != null && !query.isEmpty()) {{- querystack.add(query.substring(6));+ querystack.add(query);added++;- ConcurrentLog.info(AutoSearch.class.getName(), "add query from Bookmarks " + query);+ ConcurrentLog.info(AutoSearch.class.getName(), "add query from Bookmarks: query=" + query);}}}diff --git a/source/net/yacy/search/Switchboard.java b/source/net/yacy/search/Switchboard.javaindex a26cd725c..404cf574b 100644--- a/source/net/yacy/search/Switchboard.java+++ b/source/net/yacy/search/Switchboard.java@@ -3113,11 +3113,10 @@ public final class Switchboard extends serverSwitch {if (tagStr.length() > 2 && tagStr.startsWith("[") && tagStr.endsWith("]")) tagStr = tagStr.substring(1, tagStr.length() - 2);// we will create always a bookmark to use this to track crawled hosts- final BookmarksDB.Bookmark bookmark = this.bookmarksDB.createBookmark(url.toNormalform(true), "admin");+ final BookmarksDB.Bookmark bookmark = this.bookmarksDB.createorgetBookmark(url.toNormalform(true), "admin");if (bookmark != null) {bookmark.setProperty(BookmarksDB.Bookmark.BOOKMARK_TITLE, title);bookmark.setProperty(BookmarksDB.Bookmark.BOOKMARK_DESCRIPTION, description);- bookmark.setOwner("admin");bookmark.setPublic(false);bookmark.setTags(tags, true);this.bookmarksDB.saveBookmark(bookmark);