From dd82f85953479aa7d25b2552f6b076a856747ff7 Mon Sep 17 00:00:00 2001 From: reger Date: Thu, 28 Sep 2017 00:46:49 +0200 Subject: [PATCH] Add links to the optional keyword tags of search result If swichted on link (click) to the tag adds the keyword to the search query. If a keyword navigator is active the selected keyword adds or replaces a query keyword: modifier (currently replace was choosen as multiple keywords are not fully supported yet) --- htroot/yacysearchitem.html | 2 +- htroot/yacysearchitem.java | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/htroot/yacysearchitem.html b/htroot/yacysearchitem.html index 668e23c18..1b5107df3 100644 --- a/htroot/yacysearchitem.html +++ b/htroot/yacysearchitem.html @@ -25,7 +25,7 @@

#[description]#

#[urlname]#

- #(showKeywords)#::

Tags: #{keywords}##[tagword]# #{/keywords}#

#(/showKeywords)# + #(showKeywords)#::

Tags: #{keywords}##[tagword]# #{/keywords}#

#(/showKeywords)#

#(showDate)#::#[date]##(/showDate)# #(showEvent)#::on #[date]##(/showEvent)# diff --git a/htroot/yacysearchitem.java b/htroot/yacysearchitem.java index bdbd9fc51..722169944 100644 --- a/htroot/yacysearchitem.java +++ b/htroot/yacysearchitem.java @@ -62,6 +62,7 @@ import net.yacy.peers.graphics.ProfilingGraph; import net.yacy.search.EventTracker; import net.yacy.search.Switchboard; import net.yacy.search.SwitchboardConstants; +import net.yacy.search.navigator.Navigator; import net.yacy.search.query.HeuristicResult; import net.yacy.search.query.QueryParams; import net.yacy.search.query.SearchEvent; @@ -242,10 +243,19 @@ public class yacysearchitem { if (showEvent) prop.put("content_showEvent_date", GenericFormatter.RFC1123_SHORT_FORMATTER.format(events[0])); if (showKeywords) { // tokenize keywords StringTokenizer stoc = new StringTokenizer(result.dc_subject()," "); + String rawNavQueryModifier; + Navigator navi = theSearch.navigatorPlugins.get("keywords"); + boolean naviAvail = navi != null; int i = 0; while (stoc.hasMoreTokens()) { String word = stoc.nextToken(); prop.putHTML("content_showKeywords_keywords_" + i + "_tagword", word); + if (naviAvail) { // use query modifier if navigator available + rawNavQueryModifier = navi.getQueryModifier(word); + } else { // otherwise just use the keyword as additional query word + rawNavQueryModifier = word; + } + prop.put("content_showKeywords_keywords_" + i + "_tagurl", QueryParams.navurl(fileType, 0, theSearch.query, rawNavQueryModifier, naviAvail).toString()); i++; } prop.put("content_showKeywords_keywords", i);