Permalink
Browse files

Added new graphical setting for browser JS/On demand results resorting.

  • Loading branch information...
luccioman committed Sep 15, 2017
1 parent d00a355 commit 57a1007772238344b001d1df9cfa0f8b6a055418
Showing with 32 additions and 0 deletions.
  1. +10 −0 htroot/ConfigPortal_p.html
  2. +22 −0 htroot/ConfigPortal_p.java
@@ -52,6 +52,16 @@ <h2>Integration of a Search Portal</h2>
<input type="radio" name="search.options" value="false" #(search.options)#checked="checked"::#(/search.options)# />do not show Advanced Search
</dd>
<dt>Remote results resorting</dt>
<dd>
<label title="Remote results resorting can be triggered once the 'Refresh sorting' button (near the 'Search' button) becomes available.">
<input type="radio" name="search.jsresort" value="false" #(search.jsresort)#checked="checked"::#(/search.jsresort)# />On demand, server-side
</label>
<label title="This usually improves ranking accuracy, but doesn't work well for users who have Javascript disabled, are using screen readers, or are on slow computers.">
<input type="radio" name="search.jsresort" value="true" #(search.jsresort)#::checked="checked"#(/search.jsresort)# />Automated, with JavaScript in the browser.
</label>
</dd>
<dt>Snippet Fetch Strategy &amp; Link Verification</dt>
<dd>
<img src="env/grafics/idea.png" width="32" height="32" alt="idea" align="center"/>Speed up search results with this option! (use CACHEONLY or FALSE to switch off verification)<br/>
@@ -40,6 +40,7 @@
import net.yacy.http.servlets.YaCyDefaultServlet;
import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants;
import net.yacy.search.query.SearchEventCache;
import net.yacy.server.serverObjects;
import net.yacy.server.serverSwitch;
import net.yacy.server.http.HTTPDFileHandler;
@@ -54,6 +55,8 @@ public static serverObjects respond(final RequestHeader header, final serverObje
/* Check this is a valid transaction */
TransactionManager.checkPostTransaction(header, post);
boolean cleanSearchCache = false;
if (post.containsKey("popup")) {
final String popup = post.get("popup", "status");
if ("front".equals(popup)) {
@@ -87,6 +90,12 @@ public static serverObjects respond(final RequestHeader header, final serverObje
sb.setConfig("publicTopmenu", !post.containsKey("publicTopmenu") || post.getBoolean("publicTopmenu"));
sb.setConfig(SwitchboardConstants.PUBLIC_SEARCHPAGE, !post.containsKey(SwitchboardConstants.PUBLIC_SEARCHPAGE) || post.getBoolean(SwitchboardConstants.PUBLIC_SEARCHPAGE));
sb.setConfig("search.options", post.getBoolean("search.options"));
final boolean oldJsResort = sb.getConfigBool(SwitchboardConstants.SEARCH_JS_RESORT, SwitchboardConstants.SEARCH_JS_RESORT_DEFAULT);
final boolean newJsResort = post.getBoolean(SwitchboardConstants.SEARCH_JS_RESORT);
/* When this setting has changed we must clean up the search event cache as it affects how search results are retrieved */
cleanSearchCache = oldJsResort != newJsResort;
sb.setConfig(SwitchboardConstants.SEARCH_JS_RESORT, newJsResort);
sb.setConfig(SwitchboardConstants.GREEDYLEARNING_ACTIVE, post.getBoolean(SwitchboardConstants.GREEDYLEARNING_ACTIVE));
@@ -147,6 +156,14 @@ public static serverObjects respond(final RequestHeader header, final serverObje
sb.setConfig(SwitchboardConstants.PUBLIC_SEARCHPAGE, config.getProperty(SwitchboardConstants.PUBLIC_SEARCHPAGE,"true"));
sb.setConfig("search.navigation", config.getProperty("search.navigation","hosts,authors,namespace,topics"));
sb.setConfig("search.options", config.getProperty("search.options","true"));
final boolean oldJsResort = sb.getConfigBool(SwitchboardConstants.SEARCH_JS_RESORT, SwitchboardConstants.SEARCH_JS_RESORT_DEFAULT);
final boolean newJsResort = Boolean.parseBoolean(config.getProperty(SwitchboardConstants.SEARCH_JS_RESORT, String.valueOf(SwitchboardConstants.SEARCH_JS_RESORT_DEFAULT)));
/* When this setting has changed we must clean up the search event cache as it affects how search results are retrieved */
cleanSearchCache = oldJsResort != newJsResort;
sb.setConfig(SwitchboardConstants.SEARCH_JS_RESORT, newJsResort);
sb.setConfig(SwitchboardConstants.GREEDYLEARNING_ACTIVE, config.getProperty(SwitchboardConstants.GREEDYLEARNING_ACTIVE));
sb.setConfig(SwitchboardConstants.REMOTESEARCH_RESULT_STORE, config.getProperty(SwitchboardConstants.REMOTESEARCH_RESULT_STORE));
sb.setConfig(SwitchboardConstants.REMOTESEARCH_RESULT_STORE_MAXSIZE, config.getProperty(SwitchboardConstants.REMOTESEARCH_RESULT_STORE_MAXSIZE));
@@ -157,6 +174,10 @@ public static serverObjects respond(final RequestHeader header, final serverObje
sb.setConfig("search.excludehosts", config.getProperty("search.excludehosts",""));
sb.setConfig("search.excludehosth", config.getProperty("search.excludehosth",""));
}
if(cleanSearchCache) {
SearchEventCache.cleanupEvents(true);
}
}
/* Acquire a transaction token for the next POST form submission */
@@ -171,6 +192,7 @@ public static serverObjects respond(final RequestHeader header, final serverObje
prop.put("publicTopmenu", sb.getConfigBool("publicTopmenu", false) ? 1 : 0);
prop.put(SwitchboardConstants.PUBLIC_SEARCHPAGE, sb.getConfigBool(SwitchboardConstants.PUBLIC_SEARCHPAGE, false) ? 1 : 0);
prop.put("search.options", sb.getConfigBool("search.options", false) ? 1 : 0);
prop.put(SwitchboardConstants.SEARCH_JS_RESORT, sb.getConfigBool(SwitchboardConstants.SEARCH_JS_RESORT, SwitchboardConstants.SEARCH_JS_RESORT_DEFAULT) ? 1 : 0);
prop.put(SwitchboardConstants.GREEDYLEARNING_ACTIVE, sb.getConfigBool(SwitchboardConstants.GREEDYLEARNING_ACTIVE, false) ? 1 : 0);
prop.put(SwitchboardConstants.GREEDYLEARNING_LIMIT_DOCCOUNT, sb.getConfig(SwitchboardConstants.GREEDYLEARNING_LIMIT_DOCCOUNT, "0"));

0 comments on commit 57a1007

Please sign in to comment.