Tokenize result entry keywords and add some styling for display

pull/122/head
reger 8 years ago
parent c42d17f607
commit 632354e2ff

@ -419,6 +419,10 @@ p.info {
text-align:center;
}
p.tags {
line-height: 1.4;
}
div.bookmark p {
margin:1px;
}

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

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

Loading…
Cancel
Save