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.
pull/137/head
luccioman 7 years ago
parent 0082b5ab2a
commit 35826a3091

@ -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

@ -233,9 +233,18 @@ var solr= $.getJSON("solr/collection1/select?q=*:*&defType=edismax&start=0&rows=
</script>
<fieldset>
<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">

@ -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)));
@ -224,6 +228,10 @@ public class ConfigSearchPage_p {
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,
SwitchboardConstants.SEARCH_RESULT_SHOW_KEYWORDS_DEFAULT) ? 1 : 0);

@ -222,7 +222,11 @@ 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())) {
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) {

@ -643,6 +643,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
*/

Loading…
Cancel
Save