Permalink
Browse files

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)
  • Loading branch information...
reger24 committed Sep 27, 2017
1 parent fc28c58 commit dd82f85953479aa7d25b2552f6b076a856747ff7
Showing with 11 additions and 1 deletion.
  1. +1 −1 htroot/yacysearchitem.html
  2. +10 −0 htroot/yacysearchitem.java
@@ -25,7 +25,7 @@ <h4 class="linktitle">
</div>
<p class="snippet"><span class="snippetLoaded" id="h#[urlhash]#">#[description]#</span></p>
<p class="url"><a href="#[link]#" id="url#[urlhash]#" target="#[target]#" #(noreferrer)#::rel="noreferrer"#(/noreferrer)#>#[urlname]#</a></p>
#(showKeywords)#::<p class="tags">Tags: #{keywords}#<span class="tag label label-default">#[tagword]#</span> #{/keywords}#</p>#(/showKeywords)#
#(showKeywords)#::<p class="tags">Tags: #{keywords}#<span class="tag label label-default"><a href="#[tagurl]#" style="color: inherit; text-decoration: inherit;">#[tagword]#</a></span> #{/keywords}#</p>#(/showKeywords)#
<p class="urlinfo">
#(showDate)#::#[date]##(/showDate)#
#(showEvent)#::on #[date]##(/showEvent)#
@@ -62,6 +62,7 @@
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 static serverObjects respond(final RequestHeader header, final serverObje
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);

0 comments on commit dd82f85

Please sign in to comment.