Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
Show dates in the content of a document in the search result: - if an eventDate is given in the search result, replace the document date with the event date and prefix it with the string "on ". - the document date is omitted if a date from the cent is shown
Michael Peter Christenfd4e2c809ad4
diff --git a/htroot/yacysearch.rss b/htroot/yacysearch.rssindex 2a8a3a8f1..ded55e396 100644--- a/htroot/yacysearch.rss+++ b/htroot/yacysearch.rss@@ -7,6 +7,7 @@xmlns:atom="http://www.w3.org/2005/Atom"xmlns:dc="http://purl.org/dc/elements/1.1/"xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"+ xmlns:ev="http://purl.org/rss/1.0/modules/event/"><!-- YaCy Search Engine; http://yacy.net --><channel>diff --git a/htroot/yacysearchitem.html b/htroot/yacysearchitem.htmlindex 4e6a9a027..2bc81b6fc 100644--- a/htroot/yacysearchitem.html+++ b/htroot/yacysearchitem.html@@ -25,6 +25,7 @@<p class="url"><a href="#[link]#" id="url#[urlhash]#" target="#[target]#">#[urlname]#</a></p><p class="urlinfo">#(showDate)#::#[date]##(/showDate)#+ #(showEvent)#::on #[date]##(/showEvent)##(showSize)#:: | #[sizename]##(/showSize)##(showMetadata)#:: | <a href="solr/select?q=id:%22#[urlhash]#%22&defType=edismax&start=0&rows=1&core=collection1&wt=html" target="_blank" onclick="return hs.htmlExpand(this, { objectType: 'ajax'} )">Metadata</a>#(/showMetadata)##(showParser)#:: | <a href="ViewFile.html?urlHash=#[urlhash]#&words=#[words]#" target="_blank">Parser</a>#(/showParser)#diff --git a/htroot/yacysearchitem.java b/htroot/yacysearchitem.javaindex 9fd353c61..41980c540 100644--- a/htroot/yacysearchitem.java+++ b/htroot/yacysearchitem.java@@ -27,6 +27,7 @@import java.io.IOException;import java.net.MalformedURLException;import java.util.Collection;+import java.util.Date;import java.util.Iterator;import java.util.Map;@@ -195,8 +196,11 @@ public class yacysearchitem {prop.putHTML("content_faviconCode", URLLicense.aquireLicense(faviconURL)); // acquire license for favicon url loadingprop.put("content_urlhash", urlhash);prop.put("content_ranking", Float.toString(result.score()));+ Date[] events = result.events();+ boolean showEvent = events != null && events.length > 0 && sb.getConfig("search.navigation", "").indexOf("date",0) >= 0;+ prop.put("content_showEvent", showEvent ? 1 : 0);if (fileType == FileType.HTML) { // html template specific settings- prop.put("content_showDate", sb.getConfigBool("search.result.show.date", true) ? 1 : 0);+ 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);prop.put("content_showParser", sb.getConfigBool("search.result.show.parser", true) ? 1 : 0);@@ -207,6 +211,7 @@ public class yacysearchitem {prop.put("content_showHostBrowser", sb.getConfigBool("search.result.show.hostbrowser", true) ? 1 : 0);prop.put("content_showVocabulary", sb.getConfigBool("search.result.show.vocabulary", true) ? 1 : 0);+ if (showEvent) prop.put("content_showEvent_date", GenericFormatter.RFC1123_SHORT_FORMATTER.format(events[0]));prop.put("content_showDate_date", GenericFormatter.RFC1123_SHORT_FORMATTER.format(result.modified()));prop.putHTML("content_showSize_sizename", RSSMessage.sizename(result.filesize()));prop.put("content_showMetadata_urlhash", urlhash);@@ -239,6 +244,7 @@ public class yacysearchitem {prop.put("content_urlhexhash", Seed.b64Hash2hexHash(urlhash));prop.putHTML("content_urlname", nxTools.shortenURLString(result.urlname(), MAX_URL_LENGTH));prop.put("content_date822", isAtomFeed ? ISO8601Formatter.FORMATTER.format(result.modified()) : HeaderFramework.formatRFC1123(result.modified()));+ if (showEvent) prop.put("content_showEvent_date822", isAtomFeed ? ISO8601Formatter.FORMATTER.format(events[0]) : HeaderFramework.formatRFC1123(events[0]));//prop.put("content_ybr", RankingProcess.ybr(result.hash()));prop.putHTML("content_size", Integer.toString(result.filesize())); // we don't use putNUM here because that number shall be usable as sorting key. To print the size, use 'sizename'prop.putHTML("content_sizename", RSSMessage.sizename(result.filesize()));diff --git a/htroot/yacysearchitem.json b/htroot/yacysearchitem.jsonindex bde450962..a8bb2f413 100644--- a/htroot/yacysearchitem.json+++ b/htroot/yacysearchitem.json@@ -5,6 +5,7 @@"code": "#[code]#","description": "#[description-json]#","pubDate": "#[date822]#",+ #(showEvent)#::"eventDate": "#[date822]#",#(/showEvent)#"size": "#[size]#","sizename": "#[sizename]#","guid": "#[urlhash]#",diff --git a/htroot/yacysearchitem.xml b/htroot/yacysearchitem.xmlindex 5fc71a6a2..c8dfb7e87 100644--- a/htroot/yacysearchitem.xml+++ b/htroot/yacysearchitem.xml@@ -3,6 +3,7 @@<link>#[link]#</link><description>#[description-xml]#</description><pubDate>#[date822]#</pubDate>+#(showEvent)#::<ev:startdate>#[date822]#</ev:startdate><ev:enddate>#[date822]#</ev:enddate>#(/showEvent)#<dc:publisher><![CDATA[#[publisher]#]]></dc:publisher><dc:creator><![CDATA[#[creator]#]]></dc:creator><dc:subject><![CDATA[#[subject]#]]></dc:subject>diff --git a/source/net/yacy/kelondro/data/meta/URIMetadataNode.java b/source/net/yacy/kelondro/data/meta/URIMetadataNode.javaindex 4fa085932..c7dacc618 100644--- a/source/net/yacy/kelondro/data/meta/URIMetadataNode.java+++ b/source/net/yacy/kelondro/data/meta/URIMetadataNode.java@@ -213,6 +213,10 @@ public class URIMetadataNode extends SolrDocument {return getDate(CollectionSchema.last_modified);}+ public Date[] datesInContent() {+ return getDates(CollectionSchema.dates_in_content_dts);+ }+public DigestURL url() {return this.url;}@@ -596,6 +600,15 @@ public class URIMetadataNode extends SolrDocument {return x.after(now) ? now : x;}+ private Date[] getDates(CollectionSchema field) {+ assert field.isMultiValued();+ assert field.getType() == SolrType.date;+ @SuppressWarnings("unchecked")+ List<Date> x = (List<Date>) this.getFieldValue(field.getSolrFieldName());+ if (x == null) return new Date[0];+ return x.toArray(new Date[x.size()]);+ }+private String getString(CollectionSchema field) {assert !field.isMultiValued();assert field.getType() == SolrType.string || field.getType() == SolrType.text_general || field.getType() == SolrType.text_en_splitting_tight;diff --git a/source/net/yacy/search/snippet/ResultEntry.java b/source/net/yacy/search/snippet/ResultEntry.javaindex 4201416c1..e9f91d544 100644--- a/source/net/yacy/search/snippet/ResultEntry.java+++ b/source/net/yacy/search/snippet/ResultEntry.java@@ -170,6 +170,9 @@ public class ResultEntry implements Comparable<ResultEntry>, Comparator<ResultEnpublic Date modified() {return this.urlentry.moddate();}+ public Date[] events() {+ return this.urlentry.datesInContent();+ }public int filesize() {return this.urlentry.filesize();}