Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
added option to have exception search result windows
Michael Peter Christen4c5edab1ec1b
diff --git a/defaults/yacy.init b/defaults/yacy.initindex 4a08e86f1..b4190c581 100644--- a/defaults/yacy.init+++ b/defaults/yacy.init@@ -734,7 +734,10 @@ search.items = 10# possible values:# "_blank" (new window), "_self" (same window), "_parent" (the parent frame of a frameset),# "_top" (top of all frames), "searchresult" (a default custom page name for search results)+# a special pattern can be given for exceptions to the default target according to urlssearch.target = _self+search.target.special = _self+search.target.special.pattern =# search result lines may show additional information for each search hit# these information pieces may be switched on or offdiff --git a/htroot/ConfigPortal.html b/htroot/ConfigPortal.htmlindex ba4b86885..7cdd4af7f 100644--- a/htroot/ConfigPortal.html+++ b/htroot/ConfigPortal.html@@ -101,14 +101,26 @@<dt>Target for Click on Search Results</dt><dd><select name="target">- <option value="_blank" #(selected_blank)#::selected="selected"#(/selected_blank)#>"_blank" (new window)</option>- <option value="_self" #(selected_self)#::selected="selected"#(/selected_self)#>"_self" (same window)</option>- <option value="_parent" #(selected_parent)#::selected="selected"#(/selected_parent)#>"_parent" (the parent frame of a frameset)</option>- <option value="_top" #(selected_top)#::selected="selected"#(/selected_top)#>"_top" (top of all frames)</option>- <option value="searchresult" #(selected_searchresult)#::selected="selected"#(/selected_searchresult)#>"searchresult" (a default custom page name for search results)</option>+ <option value="_blank" #(target_selected_blank)#::selected="selected"#(/target_selected_blank)#>"_blank" (new window)</option>+ <option value="_self" #(target_selected_self)#::selected="selected"#(/target_selected_self)#>"_self" (same window)</option>+ <option value="_parent" #(target_selected_parent)#::selected="selected"#(/target_selected_parent)#>"_parent" (the parent frame of a frameset)</option>+ <option value="_top" #(target_selected_top)#::selected="selected"#(/target_selected_top)#>"_top" (top of all frames)</option>+ <option value="searchresult" #(target_selected_searchresult)#::selected="selected"#(/target_selected_searchresult)#>"searchresult" (a default custom page name for search results)</option></select></dd>+ <dt>Special Target as Exception for an URL-Pattern</dt>+ <dd>+ <select name="target_special">+ <option value="_blank" #(target_selected_special_blank)#::selected="selected"#(/target_selected_special_blank)#>"_blank" (new window)</option>+ <option value="_self" #(target_selected_special_self)#::selected="selected"#(/target_selected_special_self)#>"_self" (same window)</option>+ <option value="_parent" #(target_selected_special_parent)#::selected="selected"#(/target_selected_special_parent)#>"_parent" (the parent frame of a frameset)</option>+ <option value="_top" #(target_selected_special_top)#::selected="selected"#(/target_selected_special_top)#>"_top" (top of all frames)</option>+ <option value="searchresult" #(target_selected_special_searchresult)#::selected="selected"#(/target_selected_special_searchresult)#>"searchresult" (a default custom page name for search results)</option>+ </select>+ Pattern:<input type="text" name="target_special_pattern" value="#[target_special_pattern]#" size="30" />+ </dd>+<dt>Exclude Hosts</dt><dd>List of hosts that shall be excluded from search results by default but can be included using the site:<host> operator:<br/><input type="text" name="search.excludehosts" value="#[search.excludehosts]#" size="60" /><br/>diff --git a/htroot/ConfigPortal.java b/htroot/ConfigPortal.javaindex fe61eb69d..8c6052737 100644--- a/htroot/ConfigPortal.java+++ b/htroot/ConfigPortal.java@@ -68,7 +68,9 @@ public class ConfigPortal {sb.setConfig(SwitchboardConstants.GREETING_HOMEPAGE, post.get(SwitchboardConstants.GREETING_HOMEPAGE, ""));sb.setConfig(SwitchboardConstants.GREETING_LARGE_IMAGE, post.get(SwitchboardConstants.GREETING_LARGE_IMAGE, ""));sb.setConfig(SwitchboardConstants.GREETING_SMALL_IMAGE, post.get(SwitchboardConstants.GREETING_SMALL_IMAGE, ""));- sb.setConfig(SwitchboardConstants.SEARCH_TARGET, post.get("target", "_self"));+ sb.setConfig(SwitchboardConstants.SEARCH_TARGET_DEFAULT, post.get("target", "_self"));+ sb.setConfig(SwitchboardConstants.SEARCH_TARGET_SPECIAL, post.get("target_special", "_self"));+ sb.setConfig(SwitchboardConstants.SEARCH_TARGET_SPECIAL_PATTERN, post.get("target_special_pattern", "_self"));sb.setConfig(SwitchboardConstants.SEARCH_ITEMS, post.getInt("maximumRecords", 10));sb.setConfig(SwitchboardConstants.INDEX_FORWARD, post.get(SwitchboardConstants.INDEX_FORWARD, ""));HTTPDFileHandler.indexForward = post.get(SwitchboardConstants.INDEX_FORWARD, "");@@ -87,17 +89,17 @@ public class ConfigPortal {sb.setConfig("search.result.show.metadata", post.getBoolean("search.result.show.metadata", false));sb.setConfig("search.result.show.parser", post.getBoolean("search.result.show.parser", false));sb.setConfig("search.result.show.pictures", post.getBoolean("search.result.show.pictures", false));-+sb.setConfig(SwitchboardConstants.SEARCH_VERIFY, post.get("search.verify", "ifexist"));sb.setConfig(SwitchboardConstants.SEARCH_VERIFY_DELETE, post.getBoolean("search.verify.delete", false));sb.setConfig("about.headline", post.get("about.headline", ""));sb.setConfig("about.body", post.get("about.body", ""));-+String excludehosts = post.get("search.excludehosts", "");sb.setConfig("search.excludehosts", excludehosts);sb.setConfig("search.excludehosth", DigestURI.hosthashes(excludehosts));-+// construct navigation StringString nav = "";if (post.getBoolean("search.navigation.hosts", false)) nav += "hosts,";@@ -114,7 +116,9 @@ public class ConfigPortal {sb.setConfig(SwitchboardConstants.BROWSER_POP_UP_PAGE, "Status.html");sb.setConfig(SwitchboardConstants.INDEX_FORWARD, "");HTTPDFileHandler.indexForward = "";- sb.setConfig(SwitchboardConstants.SEARCH_TARGET, "_self");+ sb.setConfig(SwitchboardConstants.SEARCH_TARGET_DEFAULT, "_self");+ sb.setConfig(SwitchboardConstants.SEARCH_TARGET_SPECIAL, "_self");+ sb.setConfig(SwitchboardConstants.SEARCH_TARGET_SPECIAL_PATTERN, "");sb.setConfig("publicTopmenu", true);sb.setConfig("publicSearchpage", true);sb.setConfig("search.navigation", "hosts,authors,namespace,topics");@@ -194,12 +198,20 @@ public class ConfigPortal {prop.put("maximumRecords", sb.getConfigInt(SwitchboardConstants.SEARCH_ITEMS, 10));- final String target = sb.getConfig(SwitchboardConstants.SEARCH_TARGET, "_self");- prop.put("selected_blank", "_blank".equals(target) ? 1 : 0);- prop.put("selected_self", "_self".equals(target) ? 1 : 0);- prop.put("selected_parent", "_parent".equals(target) ? 1 : 0);- prop.put("selected_top", "_top".equals(target) ? 1 : 0);- prop.put("selected_searchresult", "searchresult".equals(target) ? 1 : 0);+ final String target = sb.getConfig(SwitchboardConstants.SEARCH_TARGET_DEFAULT, "_self");+ prop.put("target_selected_blank", "_blank".equals(target) ? 1 : 0);+ prop.put("target_selected_self", "_self".equals(target) ? 1 : 0);+ prop.put("target_selected_parent", "_parent".equals(target) ? 1 : 0);+ prop.put("target_selected_top", "_top".equals(target) ? 1 : 0);+ prop.put("target_selected_searchresult", "searchresult".equals(target) ? 1 : 0);++ final String target_special = sb.getConfig(SwitchboardConstants.SEARCH_TARGET_SPECIAL, "_self");+ prop.put("target_selected_special_blank", "_blank".equals(target_special) ? 1 : 0);+ prop.put("target_selected_special_self", "_self".equals(target_special) ? 1 : 0);+ prop.put("target_selected_special_parent", "_parent".equals(target_special) ? 1 : 0);+ prop.put("target_selected_special_top", "_top".equals(target_special) ? 1 : 0);+ prop.put("target_selected_special_searchresult", "searchresult".equals(target_special) ? 1 : 0);+ prop.put("target_special_pattern", sb.getConfig(SwitchboardConstants.SEARCH_TARGET_SPECIAL_PATTERN, ""));String myaddress = (sb.peers == null) ? null : sb.peers.mySeed() == null ? null : sb.peers.mySeed().getPublicAddress();if (myaddress == null) {diff --git a/htroot/yacysearchitem.java b/htroot/yacysearchitem.javaindex dde0c94c5..089556392 100644--- a/htroot/yacysearchitem.java+++ b/htroot/yacysearchitem.java@@ -102,16 +102,18 @@ public class yacysearchitem {prop.put("remoteIndexCount", Formatter.number(theSearch.getRankingResult().getRemoteIndexCount(), true));prop.put("remotePeerCount", Formatter.number(theSearch.getRankingResult().getRemotePeerCount(), true));prop.put("navurlBase", QueryParams.navurlBase("html", theQuery, null, theQuery.urlMask.toString(), theQuery.navigators).toString());+ final String target_special_pattern = sb.getConfig(SwitchboardConstants.SEARCH_TARGET_SPECIAL_PATTERN, "");- final String target = sb.getConfig(SwitchboardConstants.SEARCH_TARGET, "_self");if (theQuery.contentdom == ContentDomain.TEXT) {// text search// generate result objectfinal ResultEntry result = theSearch.oneResult(item, theQuery.isLocal() ? 1000 : 5000);if (result == null) return prop; // no content-+ final String resultUrlstring = result.urlstring();final DigestURI resultURL = result.url();+ final String target = sb.getConfig(resultUrlstring.matches(target_special_pattern) ? SwitchboardConstants.SEARCH_TARGET_SPECIAL : SwitchboardConstants.SEARCH_TARGET_DEFAULT, "_self");+final int port = resultURL.getPort();DigestURI faviconURL = null;if ((fileType == FileType.HTML || fileType == FileType.JSON) && !sb.isIntranetMode() && !resultURL.isLocal()) try {@@ -131,7 +133,7 @@ public class yacysearchitem {final String urlhash = ASCII.String(result.hash());prop.put("content_authorized_bookmark", sb.tables.bookmarks.hasBookmark("admin", urlhash) ? "0" : "1");prop.putHTML("content_authorized_bookmark_bookmarklink", "/yacysearch.html?query=" + theQuery.queryString.replace(' ', '+') + "&Enter=Search&count=" + theQuery.displayResults() + "&offset=" + (theQuery.neededResults() - theQuery.displayResults()) + "&order=" + crypt.simpleEncode(theQuery.ranking.toExternalString()) + "&resource=" + resource + "&time=3&bookmarkref=" + urlhash + "&urlmaskfilter=.*");- prop.put("content_authorized_recommend", (sb.peers.newsPool.getSpecific(NewsPool.OUTGOING_DB, NewsPool.CATEGORY_SURFTIPP_ADD, "url", result.urlstring()) == null) ? "1" : "0");+ prop.put("content_authorized_recommend", (sb.peers.newsPool.getSpecific(NewsPool.OUTGOING_DB, NewsPool.CATEGORY_SURFTIPP_ADD, "url", resultUrlstring) == null) ? "1" : "0");prop.putHTML("content_authorized_recommend_deletelink", "/yacysearch.html?query=" + theQuery.queryString.replace(' ', '+') + "&Enter=Search&count=" + theQuery.displayResults() + "&offset=" + (theQuery.neededResults() - theQuery.displayResults()) + "&order=" + crypt.simpleEncode(theQuery.ranking.toExternalString()) + "&resource=" + resource + "&time=3&deleteref=" + urlhash + "&urlmaskfilter=.*");prop.putHTML("content_authorized_recommend_recommendlink", "/yacysearch.html?query=" + theQuery.queryString.replace(' ', '+') + "&Enter=Search&count=" + theQuery.displayResults() + "&offset=" + (theQuery.neededResults() - theQuery.displayResults()) + "&order=" + crypt.simpleEncode(theQuery.ranking.toExternalString()) + "&resource=" + resource + "&time=3&recommendref=" + urlhash + "&urlmaskfilter=.*");prop.put("content_authorized_urlhash", urlhash);@@ -139,8 +141,8 @@ public class yacysearchitem {prop.putHTML("content_title", result.title());prop.putXML("content_title-xml", result.title());prop.putJSON("content_title-json", result.title());- prop.putHTML("content_link", result.urlstring());- prop.putHTML("content_showPictures_link", result.urlstring());+ prop.putHTML("content_link", resultUrlstring);+ prop.putHTML("content_showPictures_link", resultUrlstring);prop.putHTML("content_target", target);if (faviconURL != null && fileType == FileType.HTML) sb.loader.loadIfNotExistBackground(faviconURL, 1024 * 1024 * 10);prop.putHTML("content_faviconCode", sb.licensedURLs.aquireLicense(faviconURL)); // acquire license for favicon url loading@@ -216,10 +218,13 @@ public class yacysearchitem {if (ms == null) {prop.put("content_item", "0");} else {+ final String resultUrlstring = ms.href.toNormalform(true, false);+ final String target = sb.getConfig(resultUrlstring.matches(target_special_pattern) ? SwitchboardConstants.SEARCH_TARGET_SPECIAL : SwitchboardConstants.SEARCH_TARGET_DEFAULT, "_self");+final String license = sb.licensedURLs.aquireLicense(ms.href);sb.loader.loadIfNotExistBackground(ms.href, 1024 * 1024 * 10);- prop.putHTML("content_item_hrefCache", (auth) ? "/ViewImage.png?url=" + ms.href.toNormalform(true, false) : ms.href.toNormalform(true, false));- prop.putHTML("content_item_href", ms.href.toNormalform(true, false));+ prop.putHTML("content_item_hrefCache", (auth) ? "/ViewImage.png?url=" + resultUrlstring : resultUrlstring);+ prop.putHTML("content_item_href", resultUrlstring);prop.putHTML("content_item_target", target);prop.put("content_item_code", license);prop.putHTML("content_item_name", shorten(ms.name, MAX_NAME_LENGTH));@@ -254,8 +259,11 @@ public class yacysearchitem {if (media != null) {int c = 0;for (final MediaSnippet ms : media) {- prop.putHTML("content_items_" + c + "_href", ms.href.toNormalform(true, false));- prop.putHTML("content_items_" + c + "_hrefshort", nxTools.shortenURLString(ms.href.toNormalform(true, false), MAX_URL_LENGTH));+ final String resultUrlstring = ms.href.toNormalform(true, false);+ final String target = sb.getConfig(resultUrlstring.matches(target_special_pattern) ? SwitchboardConstants.SEARCH_TARGET_SPECIAL : SwitchboardConstants.SEARCH_TARGET_DEFAULT, "_self");++ prop.putHTML("content_items_" + c + "_href", resultUrlstring);+ prop.putHTML("content_items_" + c + "_hrefshort", nxTools.shortenURLString(resultUrlstring, MAX_URL_LENGTH));prop.putHTML("content_items_" + c + "_target", target);prop.putHTML("content_items_" + c + "_name", shorten(ms.name, MAX_NAME_LENGTH));prop.put("content_items_" + c + "_col", (col) ? "0" : "1");diff --git a/source/net/yacy/search/SwitchboardConstants.java b/source/net/yacy/search/SwitchboardConstants.javaindex 6af1a5b91..5da3c6a21 100644--- a/source/net/yacy/search/SwitchboardConstants.java+++ b/source/net/yacy/search/SwitchboardConstants.java@@ -436,7 +436,9 @@ public final class SwitchboardConstants {public static final String UPNP_REMOTEHOST = "upnp.remoteHost";public static final String SEARCH_ITEMS = "search.items";- public static final String SEARCH_TARGET = "search.target";+ public static final String SEARCH_TARGET_DEFAULT = "search.target";+ public static final String SEARCH_TARGET_SPECIAL = "search.target.special"; // exceptions to the search target+ public static final String SEARCH_TARGET_SPECIAL_PATTERN = "search.target.special.pattern"; // ie 'own' addresses in topframe, 'other' in iframepublic static final String SEARCH_VERIFY = "search.verify";public static final String SEARCH_VERIFY_DELETE = "search.verify.delete";