Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

Added a search page customization setting to display or not favicons

luccioman35826a3091d8
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=
</script>
<fieldset>
- <div class="searchresults">
+ <label>
+ <input type="checkbox" name="search.result.show.favicon" aria-describedby="faviconDesc" value="true" #(search.result.show.favicon)#::checked="checked"#(/search.result.show.favicon)# />
+ Show websites favicon
+ </label>
+ <span class="info" style="padding-left: 10px">
+ <img src="env/grafics/i16.gif" alt="info"/>
+ <span id="faviconDesc">Not showing websites favicon can help you save some CPU time and network bandwidth.
+ </span>
+ </span>
+ <div class="searchresults">
<h4 class="linktitle">
- <img width="16" height="16" src="env/grafics/dfltfvcn.ico" class="favicon" alt="" />
+ <img width="16" height="16" src="env/grafics/dfltfvcn.ico" class="favicon" alt="" title="Website favicon"/>
<a href="yacysearch.html" target="LayouTest">Title of Result</a>
</h4>
<p class="snippet">
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