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
pull/5/head
reger 10 years ago
parent 7224209486
commit 8a5b8f8789

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

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

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

@ -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 folder
bmk.addTag("searchresult"); // add tag
String urlhash = post.get("bookmarkref");

@ -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 result
private 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");

@ -166,12 +166,12 @@ public class AutoSearch extends AbstractBusyThread {
if (bmk.getFoldersString().startsWith("/search")) {
// take only new created or edited bookmarks
if (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);
}
}
}

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

Loading…
Cancel
Save