From 35826a3091d8b0007103077b8c87657a14c864f9 Mon Sep 17 00:00:00 2001 From: luccioman Date: Fri, 25 May 2018 11:13:43 +0200 Subject: [PATCH] Added a search page customization setting to display or not favicons If not interested in displaying this on your search results and notably on a peer with limited resources this can help saving some CPU and outgoing network connections. --- defaults/yacy.init | 2 ++ htroot/ConfigSearchPage_p.html | 13 +++++++++++-- htroot/ConfigSearchPage_p.java | 8 ++++++++ htroot/yacysearchitem.java | 10 +++++++--- source/net/yacy/search/SwitchboardConstants.java | 8 ++++++++ 5 files changed, 36 insertions(+), 5 deletions(-) diff --git a/defaults/yacy.init b/defaults/yacy.init index 8f556d4ab..6f2b4601b 100644 --- a/defaults/yacy.init +++ b/defaults/yacy.init @@ -883,6 +883,8 @@ search.result.noreferrer=false # search result lines may show additional information for each search hit # these information pieces may be switched on or off +# When true the favicon (when available) of the website the URL belongs to is fetched and displayed +search.result.show.favicon = true search.result.show.keywords = false # Maximum number of keywords initially displayed. The eventual remaining ones can then be expanded. search.result.keywords.firstMaxCount = 100 diff --git a/htroot/ConfigSearchPage_p.html b/htroot/ConfigSearchPage_p.html index c323b72f2..3d7f3bcc7 100644 --- a/htroot/ConfigSearchPage_p.html +++ b/htroot/ConfigSearchPage_p.html @@ -233,9 +233,18 @@ var solr= $.getJSON("solr/collection1/select?q=*:*&defType=edismax&start=0&rows=
-
+ + + info + Not showing websites favicon can help you save some CPU time and network bandwidth. + + +

- + Title of Result

diff --git a/htroot/ConfigSearchPage_p.java b/htroot/ConfigSearchPage_p.java index c2ccb1990..159cb6d1c 100644 --- a/htroot/ConfigSearchPage_p.java +++ b/htroot/ConfigSearchPage_p.java @@ -74,6 +74,7 @@ public class ConfigSearchPage_p { sb.setConfig("search.video", post.getBoolean("search.video")); sb.setConfig("search.app", post.getBoolean("search.app")); + sb.setConfig(SwitchboardConstants.SEARCH_RESULT_SHOW_FAVICON, post.getBoolean(SwitchboardConstants.SEARCH_RESULT_SHOW_FAVICON)); sb.setConfig(SwitchboardConstants.SEARCH_RESULT_SHOW_KEYWORDS, post.getBoolean(SwitchboardConstants.SEARCH_RESULT_SHOW_KEYWORDS)); // maximum number of initially displayed keywords/tags @@ -176,6 +177,9 @@ public class ConfigSearchPage_p { sb.setConfig("search.audio", config.getProperty("search.audio","false")); sb.setConfig("search.video", config.getProperty("search.video","false")); sb.setConfig("search.app", config.getProperty("search.app","false")); + sb.setConfig(SwitchboardConstants.SEARCH_RESULT_SHOW_FAVICON, + config.getProperty(SwitchboardConstants.SEARCH_RESULT_SHOW_FAVICON, + Boolean.toString(SwitchboardConstants.SEARCH_RESULT_SHOW_FAVICON_DEFAULT))); sb.setConfig(SwitchboardConstants.SEARCH_RESULT_SHOW_KEYWORDS, config.getProperty(SwitchboardConstants.SEARCH_RESULT_SHOW_KEYWORDS, Boolean.toString(SwitchboardConstants.SEARCH_RESULT_SHOW_KEYWORDS_DEFAULT))); @@ -223,6 +227,10 @@ public class ConfigSearchPage_p { prop.put("search.audio", sb.getConfigBool("search.audio", false) ? 1 : 0); prop.put("search.video", sb.getConfigBool("search.video", false) ? 1 : 0); prop.put("search.app", sb.getConfigBool("search.app", false) ? 1 : 0); + + prop.put(SwitchboardConstants.SEARCH_RESULT_SHOW_FAVICON, + sb.getConfigBool(SwitchboardConstants.SEARCH_RESULT_SHOW_FAVICON, + SwitchboardConstants.SEARCH_RESULT_SHOW_FAVICON_DEFAULT)); prop.put(SwitchboardConstants.SEARCH_RESULT_SHOW_KEYWORDS, sb.getConfigBool(SwitchboardConstants.SEARCH_RESULT_SHOW_KEYWORDS, diff --git a/htroot/yacysearchitem.java b/htroot/yacysearchitem.java index 07eb89ce1..0312d8afc 100644 --- a/htroot/yacysearchitem.java +++ b/htroot/yacysearchitem.java @@ -222,9 +222,13 @@ public class yacysearchitem { String resultFileName = resultURL.getFileName(); prop.putHTML("content_target", target); DigestURL faviconURL = null; - if ((fileType == FileType.HTML || fileType == FileType.JSON) && (resultURL.isHTTP() || resultURL.isHTTPS())) { - faviconURL = getFaviconURL(result, new Dimension(16, 16)); - } + final boolean showFavicon = sb.getConfigBool(SwitchboardConstants.SEARCH_RESULT_SHOW_FAVICON, + SwitchboardConstants.SEARCH_RESULT_SHOW_FAVICON_DEFAULT); + + if (((fileType == FileType.HTML && showFavicon) || fileType == FileType.JSON) + && (resultURL.isHTTP() || resultURL.isHTTPS())) { + faviconURL = getFaviconURL(result, new Dimension(16, 16)); + } if(faviconURL == null) { prop.put("content_favicon", 0); } else { diff --git a/source/net/yacy/search/SwitchboardConstants.java b/source/net/yacy/search/SwitchboardConstants.java index f74d204cb..b5ae101ca 100644 --- a/source/net/yacy/search/SwitchboardConstants.java +++ b/source/net/yacy/search/SwitchboardConstants.java @@ -642,6 +642,14 @@ public final class SwitchboardConstants { /** Default setting value controlling the maximum number of tags/keywords initially displayed for each search result in the HTML results page (the eventual remaining ones can then be expanded) */ public static final int SEARCH_RESULT_KEYWORDS_FISRT_MAX_COUNT_DEFAULT = 100; + + /** Key of the setting controlling whether the eventual website favicon should be fetched and displayed for each search result in the HTML results page */ + public static final String SEARCH_RESULT_SHOW_FAVICON = "search.result.show.favicon"; + + /** Default setting value controlling whether the eventual website favicon should be fetched and displayed for each search result in the HTML results page */ + public static final boolean SEARCH_RESULT_SHOW_FAVICON_DEFAULT = true; + + /** * ranking+evaluation