Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
added link to Snapshots in search results if the snapshot exists and option is set in ConfigSearchPage_p (this is a stub: we also need a visualization of pdf files!)
Michael Peter Christen9c12555be584
diff --git a/defaults/yacy.init b/defaults/yacy.initindex 33a4d25c2..9eab81b97 100644--- a/defaults/yacy.init+++ b/defaults/yacy.init@@ -831,6 +831,7 @@ search.result.show.proxy = falsesearch.result.show.hostbrowser = truesearch.result.show.vocabulary = falsesearch.result.show.vocabulary.omit =+search.result.show.snapshots = false# search navigators: comma-separated list of default values for search navigation.diff --git a/htroot/ConfigSearchPage_p.html b/htroot/ConfigSearchPage_p.htmlindex f326f7587..242ebd537 100644--- a/htroot/ConfigSearchPage_p.html+++ b/htroot/ConfigSearchPage_p.html@@ -245,6 +245,7 @@ var solr= $.getJSON("/solr/collection1/select?q=*:*&defType=edismax&start=0&rows<td> | <a href="CacheResource_p.html" target="LayouTest">Cache</a></td><td> | <a href="proxy.html" target="LayouTest">Augmented Browsing</a></td><td> | <a href="HostBrowser.html" target="LayouTest"><img src="env/grafics/minitree.png" width="15" height="8" /></a></td>+ <td> | <a href="yacysearch.html" target="LayouTest">Snapshots</a></td></tr><tr><td></td>@@ -263,6 +264,7 @@ var solr= $.getJSON("/solr/collection1/select?q=*:*&defType=edismax&start=0&rows</span></span></td><td align="center"><input type="checkbox" name="search.result.show.hostbrowser" value="true" #(search.result.show.hostbrowser)#::checked="checked" #(/search.result.show.hostbrowser)# /></td>+ <td align="center"><input type="checkbox" name="search.result.show.snapshots" value="true" #(search.result.show.snapshots)#::checked="checked" #(/search.result.show.snapshots)# /></td></tr></table></p>diff --git a/htroot/ConfigSearchPage_p.java b/htroot/ConfigSearchPage_p.javaindex 925764aa4..2fdf1ff1c 100644--- a/htroot/ConfigSearchPage_p.java+++ b/htroot/ConfigSearchPage_p.java@@ -35,7 +35,6 @@ import net.yacy.cora.date.GenericFormatter;import net.yacy.cora.protocol.RequestHeader;import net.yacy.cora.util.ConcurrentLog;import net.yacy.data.WorkTables;-import net.yacy.document.LibraryProvider;import net.yacy.search.Switchboard;import net.yacy.search.SwitchboardConstants;import net.yacy.server.serverObjects;@@ -78,6 +77,7 @@ public class ConfigSearchPage_p {sb.setConfig("search.result.show.cache", post.getBoolean("search.result.show.cache"));sb.setConfig("search.result.show.proxy", post.getBoolean("search.result.show.proxy"));sb.setConfig("search.result.show.hostbrowser", post.getBoolean("search.result.show.hostbrowser"));+ sb.setConfig("search.result.show.snapshots", post.getBoolean("search.result.show.snapshots"));// construct navigation StringString nav = "";@@ -134,6 +134,7 @@ public class ConfigSearchPage_p {sb.setConfig("search.result.show.cache", config.getProperty("search.result.show.cache","true"));sb.setConfig("search.result.show.proxy", config.getProperty("search.result.show.proxy","false"));sb.setConfig("search.result.show.hostbrowser", config.getProperty("search.result.show.hostbrowser","true"));+ sb.setConfig("search.result.show.snapshots", config.getProperty("search.result.show.snapshots","true"));}}@@ -160,6 +161,7 @@ public class ConfigSearchPage_p {prop.put("search.result.show.cache", sb.getConfigBool("search.result.show.cache", false) ? 1 : 0);prop.put("search.result.show.proxy", sb.getConfigBool("search.result.show.proxy", false) ? 1 : 0);prop.put("search.result.show.hostbrowser", sb.getConfigBool("search.result.show.hostbrowser", false) ? 1 : 0);+ prop.put("search.result.show.snapshots", sb.getConfigBool("search.result.show.snapshots", false) ? 1 : 0);prop.put("search.navigation.location", sb.getConfig("search.navigation", "").indexOf("location",0) >= 0 ? 1 : 0);prop.put("search.navigation.filetype", sb.getConfig("search.navigation", "").indexOf("filetype",0) >= 0 ? 1 : 0);diff --git a/htroot/yacysearchitem.html b/htroot/yacysearchitem.htmlindex 2bc81b6fc..afa3f3abf 100644--- a/htroot/yacysearchitem.html+++ b/htroot/yacysearchitem.html@@ -35,6 +35,7 @@#(showProxy)#:: | <a href="proxy.html?url=#[link]#" target="_blank">Augmented Browsing</a>#(/showProxy)##(showHostBrowser)#:: | <a href="HostBrowser.html?path=#[link]#"><img src="env/grafics/minitree.png" width="15" height="8"/></a>#(/showHostBrowser)##(showVocabulary)#::<br/>#{vocabulary}##[name]#:#[terms]# #{/vocabulary}##(/showVocabulary)#+ #(showSnapshots)#::<a href="#[link]#">Snapshots</a>#(/showSnapshots)#</p></div>::diff --git a/htroot/yacysearchitem.java b/htroot/yacysearchitem.javaindex 25b6d4780..c8a7521c8 100644--- a/htroot/yacysearchitem.java+++ b/htroot/yacysearchitem.java@@ -24,6 +24,7 @@// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+import java.io.File;import java.net.MalformedURLException;import java.util.Collection;import java.util.Date;@@ -43,6 +44,8 @@ import net.yacy.cora.protocol.RequestHeader.FileType;import net.yacy.cora.util.ConcurrentLog;import net.yacy.cora.util.Memory;import net.yacy.crawler.data.Cache;+import net.yacy.crawler.data.Transactions;+import net.yacy.crawler.data.Transactions.State;import net.yacy.crawler.retrieval.Response;import net.yacy.data.URLLicense;import net.yacy.kelondro.data.meta.URIMetadataNode;@@ -194,6 +197,7 @@ public class yacysearchitem {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);+ 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 settingsprop.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);@@ -204,6 +208,7 @@ public class yacysearchitem {prop.put("content_showCache", sb.getConfigBool("search.result.show.cache", true) && Cache.has(resultURL.hash()) ? 1 : 0);prop.put("content_showProxy", sb.getConfigBool("search.result.show.proxy", true) && sb.getConfigBool("proxyURL", false) ? 1 : 0);prop.put("content_showHostBrowser", sb.getConfigBool("search.result.show.hostbrowser", true) ? 1 : 0);+ prop.put("content_showSnapshots", snapshotPaths != null && snapshotPaths.size() > 0 && sb.getConfigBool("search.result.show.snapshots", 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]));@@ -220,7 +225,6 @@ public class yacysearchitem {int c = 0;for (String key: result.getFieldNames()) {if (key.startsWith("vocabulary_") && key.endsWith("_sxt")) {- @SuppressWarnings("unchecked")Collection<Object> terms = result.getFieldValues(key);prop.putHTML("content_showVocabulary_vocabulary_" + c + "_name", key.substring(11, key.length() - 4));prop.putHTML("content_showVocabulary_vocabulary_" + c + "_terms", terms.toString());@@ -233,6 +237,9 @@ public class yacysearchitem {prop.put("content_showVocabulary_vocabulary", 0);prop.put("content_showVocabulary", 0);}+ if (snapshotPaths != null && snapshotPaths.size() > 0) {+ prop.put("content_showSnapshots_link", snapshotPaths.iterator().next().getAbsolutePath());+ }}prop.put("content_urlhexhash", Seed.b64Hash2hexHash(urlhash));prop.putHTML("content_urlname", nxTools.shortenURLString(result.urlname(), MAX_URL_LENGTH));diff --git a/source/net/yacy/crawler/data/Transactions.java b/source/net/yacy/crawler/data/Transactions.javaindex 11d4180a7..ed5c29186 100644--- a/source/net/yacy/crawler/data/Transactions.java+++ b/source/net/yacy/crawler/data/Transactions.java@@ -57,8 +57,8 @@ public class Transactions {private final static String XML_PREFIX = "<response>\n<!--\n";private final static char[] WHITESPACE = new char[132];- private final static int WHITESPACE_START = XML_PREFIX.length();- private final static int WHITESPACE_LENGTH = WHITESPACE.length;+ //private final static int WHITESPACE_START = XML_PREFIX.length();+ //private final static int WHITESPACE_LENGTH = WHITESPACE.length;private static File transactionDir = null, inventoryDir = null, archiveDir = null;private static Snapshots inventory = null, archive = null;private static ExecutorService executor = Executors.newCachedThreadPool();@@ -348,7 +348,7 @@ public class Transactions {* This method is inefficient because it tests all different depths, it would be better to use* findPaths/3 with a given depth.* @param url- * @param ext+ * @param ext required extension or null if the extension must not be checked* @param state the wanted transaction state, State.INVENTORY, State.ARCHIVE or State.ANY* @return a set of files for snapshots of the url*/