Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

Tokenize result entry keywords and add some styling for display

reger632354e2ff75
diff --git a/htroot/env/base.css b/htroot/env/base.css
index 0f83fe938..6c8ed186c 100644
--- a/htroot/env/base.css
+++ b/htroot/env/base.css
@@ -419,6 +419,10 @@ p.info {
text-align:center;
}
+p.tags {
+ line-height: 1.4;
+}
+
div.bookmark p {
margin:1px;
}
diff --git a/htroot/yacysearchitem.html b/htroot/yacysearchitem.html
index d44347bfb..03c7417f8 100644
--- a/htroot/yacysearchitem.html
+++ b/htroot/yacysearchitem.html
@@ -25,7 +25,7 @@
</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: #[subject]#</p>#(/showKeywords)#
+ #(showKeywords)#::<p class="tags">Tags: #{keywords}#<span class="tag label label-default">#[tagword]#</span> #{/keywords}#</p>#(/showKeywords)#
<p class="urlinfo">
#(showDate)#::#[date]##(/showDate)#
#(showEvent)#::on #[date]##(/showEvent)#
diff --git a/htroot/yacysearchitem.java b/htroot/yacysearchitem.java
index 7cbdcea58..431ce4030 100644
--- a/htroot/yacysearchitem.java
+++ b/htroot/yacysearchitem.java
@@ -33,6 +33,7 @@ import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
+import java.util.StringTokenizer;
import net.yacy.cora.date.GenericFormatter;
import net.yacy.cora.date.ISO8601Formatter;
@@ -205,7 +206,8 @@ public class yacysearchitem {
prop.put("content_showEvent", showEvent ? 1 : 0);
Collection<File> snapshotPaths = sb.getConfigBool("search.result.show.snapshots", true) ? Transactions.findPaths(result.url(), null, State.ANY) : null;
if (fileType == FileType.HTML) { // html template specific settings
- prop.put("content_showKeywords", (sb.getConfigBool("search.result.show.keywords", false) && !result.dc_subject().isEmpty()) ? 1 : 0);
+ boolean showKeywords = (sb.getConfigBool("search.result.show.keywords", false) && !result.dc_subject().isEmpty());
+ prop.put("content_showKeywords", showKeywords);
prop.put("content_showDate", sb.getConfigBool("search.result.show.date", true) && !showEvent ? 1 : 0);
prop.put("content_showSize", sb.getConfigBool("search.result.show.size", true) ? 1 : 0);
prop.put("content_showMetadata", sb.getConfigBool("search.result.show.metadata", true) ? 1 : 0);
@@ -220,7 +222,16 @@ public class yacysearchitem {
prop.put("content_showRanking", sb.getConfigBool("search.result.show.ranking", false) ? 1 : 0);
if (showEvent) prop.put("content_showEvent_date", GenericFormatter.RFC1123_SHORT_FORMATTER.format(events[0]));
- prop.putHTML("content_showKeywords_subject", result.dc_subject());
+ if (showKeywords) { // tokenize keywords
+ StringTokenizer stoc = new StringTokenizer(result.dc_subject()," ");
+ int i = 0;
+ while (stoc.hasMoreTokens()) {
+ String word = stoc.nextToken();
+ prop.putHTML("content_showKeywords_keywords_" + i + "_tagword", word);
+ i++;
+ }
+ prop.put("content_showKeywords_keywords", i);
+ }
prop.put("content_showDate_date", GenericFormatter.RFC1123_SHORT_FORMATTER.format(result.moddate()));
prop.putHTML("content_showSize_sizename", RSSMessage.sizename(result.filesize()));
prop.put("content_showMetadata_urlhash", urlhash);