Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
- added stealth button to navigation menu - more fixes to progress bar
Michael Peter Christend1091e79f835
diff --git a/htroot/yacysearch.html b/htroot/yacysearch.htmlindex c10fcb6b2..a4daf9532 100644--- a/htroot/yacysearch.html+++ b/htroot/yacysearch.html@@ -58,19 +58,6 @@#(topmenu)##%env/templates/embeddedheader.template%#::--#(resource-select)#::-<div id="searchmode">-<img src="env/grafics/searchmode_p2p_activated_32.png" width="91" height="32"/><br/>-<a href="yacysearch.html?resource=local"><img src="env/grafics/searchmode_stealth_deactivated_32.png" width="91" height="32"/></a>-<span>Your search is done using peers in the YaCy P2P network. You can switch to 'Stealth Mode' which will switch off P2P, giving you full privacy. Expect less results then, because then only your own search index is used.</span>-</div>::-<div id="searchmode">-<a href="yacysearch.html?resource=global"><img src="env/grafics/searchmode_p2p_deactivated_32.png" width="91" height="32"/></a><br/>-<img src="env/grafics/searchmode_stealth_activated_32.png" width="91" height="32"/>-<span>Your search is done using only your own peer, locally. You can switch to 'Peer-to-Peer Mode' which will cause that your search is done using the other peers in the YaCy network.</span>-</div>#(/resource-select)#-#%env/templates/simpleheader.template%#<script type="text/javascript">document.getElementById("header_websearch").className += " active";diff --git a/htroot/yacysearch.java b/htroot/yacysearch.javaindex 9444e1558..b6c4a19f0 100644--- a/htroot/yacysearch.java+++ b/htroot/yacysearch.java@@ -157,9 +157,8 @@ public class yacysearch {final boolean clustersearch = sb.isRobinsonMode() && sb.getConfig(SwitchboardConstants.CLUSTER_MODE, "").equals(SwitchboardConstants.CLUSTER_MODE_PUBLIC_CLUSTER);final boolean indexReceiveGranted = sb.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW_SEARCH, true) || clustersearch;boolean p2pmode = sb.peers != null && sb.peers.sizeConnected() > 0 && indexReceiveGranted;- boolean global = post == null || (post.get("resource", "local").equals("global") && p2pmode);+ boolean global = post == null || (post.get("resource-switch", post.get("resource", "local")).equals("global") && p2pmode);boolean stealthmode = p2pmode && !global;- prop.put("topmenu_resource-select", !authorized ? 0 : stealthmode ? 2 : global ? 1 : 0);if ( post == null || indexSegment == null || env == null || !searchAllowed ) {if (indexSegment == null) ConcurrentLog.info("yacysearch", "indexSegment == null");@@ -762,7 +761,7 @@ public class yacysearch {"html",0,theQuery,- suggestion).toString());+ suggestion, true).toString());prop.put("didYouMean_suggestions_" + meanCount + "_sep", "|");meanCount++;} catch (final ConcurrentModificationException e) {diff --git a/htroot/yacysearchitem.java b/htroot/yacysearchitem.javaindex cdbbca0b4..f5a49e7ee 100644--- a/htroot/yacysearchitem.java+++ b/htroot/yacysearchitem.java@@ -105,7 +105,7 @@ public class yacysearchitem {prop.put("remoteResourceSize", Formatter.number(theSearch.remote_rwi_stored.get() + theSearch.remote_solr_stored.get(), true));prop.put("remoteIndexCount", Formatter.number(theSearch.remote_rwi_available.get() + theSearch.remote_solr_available.get(), true));prop.put("remotePeerCount", Formatter.number(theSearch.remote_rwi_peerCount.get() + theSearch.remote_solr_peerCount.get(), true));- prop.put("navurlBase", QueryParams.navurlBase("html", theSearch.query, null).toString());+ prop.put("navurlBase", QueryParams.navurlBase("html", theSearch.query, null, false).toString());final String target_special_pattern = sb.getConfig(SwitchboardConstants.SEARCH_TARGET_SPECIAL_PATTERN, "");long timeout = item == 0 ? 10000 : (theSearch.query.isLocal() ? 1000 : 3000);diff --git a/htroot/yacysearchlatestinfo.java b/htroot/yacysearchlatestinfo.javaindex 95ebeb956..d1895fd8b 100644--- a/htroot/yacysearchlatestinfo.java+++ b/htroot/yacysearchlatestinfo.java@@ -41,7 +41,7 @@ public class yacysearchlatestinfo {prop.put("remoteResourceSize", Formatter.number(theSearch.remote_rwi_stored.get() + theSearch.remote_solr_stored.get(), true));prop.put("remoteIndexCount", Formatter.number(theSearch.remote_rwi_available.get() + theSearch.remote_solr_available.get(), true));prop.put("remotePeerCount", Formatter.number(theSearch.remote_rwi_peerCount.get() + theSearch.remote_solr_peerCount.get(), true));- prop.putJSON("navurlBase", QueryParams.navurlBase("html", theSearch.query, null).toString());+ prop.putJSON("navurlBase", QueryParams.navurlBase("html", theSearch.query, null, false).toString());return prop;}diff --git a/htroot/yacysearchtrailer.html b/htroot/yacysearchtrailer.htmlindex 5da16fdb5..874a4dea3 100644--- a/htroot/yacysearchtrailer.html+++ b/htroot/yacysearchtrailer.html@@ -1,3 +1,33 @@+<script>+ if (document.getElementById("progressbar").getAttribute('class') != "progress-bar progress-bar-success") {+ document.getElementById("progressbar").setAttribute('style',"width:100%");+ document.getElementById("progressbar").setAttribute('style',"transition:transform 0s;");+ document.getElementById("progressbar").setAttribute('class',"progress-bar progress-bar-success");+ window.setTimeout(fadeOutBar, 500);+ }+</script>++#(resource-select)#::+<form action="yacysearch.html" method="get" accept-charset="UTF-8">+<input type="checkbox" name="resource-switch" value="local" data-size="large" style="width:100%" checked="checked" onchange="this.form.submit()">+<script>$("[name='resource-switch']").bootstrapSwitch();+$("[name='resource-switch']").bootstrapSwitch('onText', ' Peer-to-Peer ');+$("[name='resource-switch']").bootstrapSwitch('offText', ' Stealth Mode ');</script>+</form>+<!--+<span>Your search is done using peers in the YaCy P2P network. You can switch to 'Stealth Mode' which will switch off P2P, giving you full privacy. Expect less results then, because then only your own search index is used.</span>+-->+::+<form action="yacysearch.html" method="get" accept-charset="UTF-8">+<input type="checkbox" name="resource-switch" value="global" data-size="large" onchange="this.form.submit()">+<script>$("[name='resource-switch']").bootstrapSwitch();+$("[name='resource-switch']").bootstrapSwitch('onText', ' Peer-to-Peer ');+$("[name='resource-switch']").bootstrapSwitch('offText', ' Stealth Mode ');</script>+</form>+<!--+<span>Your search is done using only your own peer, locally. You can switch to 'Peer-to-Peer Mode' which will cause that your search is done using the other peers in the YaCy network.</span>+-->+#(/resource-select)##(cat-location)#::<a href="yacysearch_location.html?query=#[queryenc]#">diff --git a/htroot/yacysearchtrailer.java b/htroot/yacysearchtrailer.javaindex 5d3e3fa17..3c0cebb33 100644--- a/htroot/yacysearchtrailer.java+++ b/htroot/yacysearchtrailer.java@@ -39,6 +39,7 @@ import net.yacy.kelondro.util.ISO639;import net.yacy.peers.graphics.ProfilingGraph;import net.yacy.search.EventTracker;import net.yacy.search.Switchboard;+import net.yacy.search.SwitchboardConstants;import net.yacy.search.query.QueryParams;import net.yacy.search.query.SearchEvent;import net.yacy.search.query.SearchEventCache;@@ -68,6 +69,14 @@ public class yacysearchtrailer {}final RequestHeader.FileType fileType = header.fileType();+ final boolean authorized = sb.verifyAuthentication(header);+ final boolean clustersearch = sb.isRobinsonMode() && sb.getConfig(SwitchboardConstants.CLUSTER_MODE, "").equals(SwitchboardConstants.CLUSTER_MODE_PUBLIC_CLUSTER);+ final boolean indexReceiveGranted = sb.getConfigBool(SwitchboardConstants.INDEX_RECEIVE_ALLOW_SEARCH, true) || clustersearch;+ boolean p2pmode = sb.peers != null && sb.peers.sizeConnected() > 0 && indexReceiveGranted;+ boolean global = post == null || (post.get("resource-switch", post.get("resource", "local")).equals("global") && p2pmode);+ boolean stealthmode = p2pmode && !global;+ prop.put("resource-select", !authorized ? 0 : stealthmode ? 2 : global ? 1 : 0);+// compose search navigation// namespace navigators@@ -99,7 +108,7 @@ public class yacysearchtrailer {nav="";}prop.put(fileType, "nav-namespace_element_" + i + "_name", name);- prop.put(fileType, "nav-namespace_element_" + i + "_url", QueryParams.navurl(fileType.name().toLowerCase(), 0, theSearch.query, nav).toString());+ prop.put(fileType, "nav-namespace_element_" + i + "_url", QueryParams.navurl(fileType.name().toLowerCase(), 0, theSearch.query, nav, false).toString());prop.put("nav-namespace_element_" + i + "_count", count);prop.put("nav-namespace_element_" + i + "_nl", 1);i++;@@ -141,7 +150,7 @@ public class yacysearchtrailer {nav="";}prop.put(fileType, "nav-domains_element_" + i + "_name", name);- prop.put(fileType, "nav-domains_element_" + i + "_url", QueryParams.navurl(fileType.name().toLowerCase(), 0, theSearch.query, nav).toString());+ prop.put(fileType, "nav-domains_element_" + i + "_url", QueryParams.navurl(fileType.name().toLowerCase(), 0, theSearch.query, nav, false).toString());prop.put("nav-domains_element_" + i + "_count", count);prop.put("nav-domains_element_" + i + "_nl", 1);i++;@@ -184,7 +193,7 @@ public class yacysearchtrailer {}String longname = ISO639.country(name);prop.put(fileType, "nav-languages_element_" + i + "_name", longname == null ? name : longname);- prop.put(fileType, "nav-languages_element_" + i + "_url", QueryParams.navurl(fileType.name().toLowerCase(), 0, theSearch.query, nav).toString());+ prop.put(fileType, "nav-languages_element_" + i + "_url", QueryParams.navurl(fileType.name().toLowerCase(), 0, theSearch.query, nav, false).toString());prop.put("nav-languages_element_" + i + "_count", count);prop.put("nav-languages_element_" + i + "_nl", 1);i++;@@ -225,7 +234,7 @@ public class yacysearchtrailer {nav="";}prop.put(fileType, "nav-authors_element_" + i + "_name", name);- prop.put(fileType, "nav-authors_element_" + i + "_url", QueryParams.navurl(fileType.name().toLowerCase(), 0, theSearch.query, nav).toString());+ prop.put(fileType, "nav-authors_element_" + i + "_url", QueryParams.navurl(fileType.name().toLowerCase(), 0, theSearch.query, nav, false).toString());prop.put("nav-authors_element_" + i + "_count", count);prop.put("nav-authors_element_" + i + "_nl", 1);i++;@@ -270,7 +279,7 @@ public class yacysearchtrailer {prop.put("nav-topics_element_" + i + "_on", 1);prop.put(fileType, "nav-topics_element_" + i + "_modifier", name);prop.put(fileType, "nav-topics_element_" + i + "_name", name);- prop.put(fileType, "nav-topics_element_" + i + "_url", QueryParams.navurl(fileType.name().toLowerCase(), 0, theSearch.query, name).toString());+ prop.put(fileType, "nav-topics_element_" + i + "_url", QueryParams.navurl(fileType.name().toLowerCase(), 0, theSearch.query, name, false).toString());prop.put("nav-topics_element_" + i + "_count", count);int fontsize = TOPWORDS_MINSIZE + (TOPWORDS_MAXSIZE - TOPWORDS_MINSIZE) * (count - mincount) / (maxcount / mincount);fontsize = Math.max(TOPWORDS_MINSIZE, fontsize - (name.length() - 5));@@ -311,7 +320,7 @@ public class yacysearchtrailer {nav="";}prop.put(fileType, "nav-protocols_element_" + i + "_name", name);- prop.put(fileType, "nav-protocols_element_" + i + "_url", QueryParams.navurl(fileType.name().toLowerCase(), 0, theSearch.query, nav).toString());+ prop.put(fileType, "nav-protocols_element_" + i + "_url", QueryParams.navurl(fileType.name().toLowerCase(), 0, theSearch.query, nav, false).toString());prop.put("nav-protocols_element_" + i + "_count", count);prop.put("nav-protocols_element_" + i + "_nl", 1);i++;@@ -354,7 +363,7 @@ public class yacysearchtrailer {nav="";}prop.put(fileType, "nav-filetypes_element_" + i + "_name", name);- prop.put(fileType, "nav-filetypes_element_" + i + "_url", QueryParams.navurl(fileType.name().toLowerCase(), 0, theSearch.query, nav).toString());+ prop.put(fileType, "nav-filetypes_element_" + i + "_url", QueryParams.navurl(fileType.name().toLowerCase(), 0, theSearch.query, nav, false).toString());prop.put("nav-filetypes_element_" + i + "_count", count);prop.put("nav-filetypes_element_" + i + "_nl", 1);i++;@@ -398,7 +407,7 @@ public class yacysearchtrailer {nav="";}prop.put(fileType, "nav-vocabulary_" + navvoccount + "_element_" + i + "_name", name);- prop.put(fileType, "nav-vocabulary_" + navvoccount + "_element_" + i + "_url", QueryParams.navurl(fileType.name().toLowerCase(), 0, theSearch.query, nav).toString());+ prop.put(fileType, "nav-vocabulary_" + navvoccount + "_element_" + i + "_url", QueryParams.navurl(fileType.name().toLowerCase(), 0, theSearch.query, nav, false).toString());prop.put("nav-vocabulary_" + navvoccount + "_element_" + i + "_count", count);prop.put("nav-vocabulary_" + navvoccount + "_element_" + i + "_nl", 1);i++;diff --git a/source/net/yacy/search/query/QueryParams.java b/source/net/yacy/search/query/QueryParams.javaindex b0a5023d2..448260fae 100644--- a/source/net/yacy/search/query/QueryParams.java+++ b/source/net/yacy/search/query/QueryParams.java@@ -598,9 +598,9 @@ public final class QueryParams {* @param addToQuery* @return*/- public static StringBuilder navurl(final String ext, final int page, final QueryParams theQuery, final String newQueryString) {+ public static StringBuilder navurl(final String ext, final int page, final QueryParams theQuery, final String newQueryString, boolean newModifierReplacesOld) {- final StringBuilder sb = navurlBase(ext, theQuery, newQueryString);+ final StringBuilder sb = navurlBase(ext, theQuery, newQueryString, newModifierReplacesOld);sb.append("&startRecord=");sb.append(page * theQuery.itemsPerPage());@@ -619,20 +619,27 @@ public final class QueryParams {* - if isEmpty overwrites (clears) existing modifier* @return url to new search result page*/- public static StringBuilder navurlBase(final String ext, final QueryParams theQuery, final String newModifier) {+ public static StringBuilder navurlBase(final String ext, final QueryParams theQuery, final String newModifier, boolean newModifierReplacesOld) {final StringBuilder sb = new StringBuilder(120);sb.append("/yacysearch.");sb.append(ext);sb.append("?query=");- sb.append(theQuery.getQueryGoal().getQueryString(true));if (newModifier == null) {+ sb.append(theQuery.getQueryGoal().getQueryString(true));if (!theQuery.modifier.isEmpty()) sb.append("+" + theQuery.modifier.toString());} else {- if(!newModifier.isEmpty()) {- if (!theQuery.modifier.isEmpty()) sb.append("+" + theQuery.modifier.toString());- sb.append("+" + newModifier);+ if (newModifier.isEmpty()) {+ sb.append(theQuery.getQueryGoal().getQueryString(true));+ } else {+ if (newModifierReplacesOld) {+ sb.append(newModifier);+ } else {+ sb.append(theQuery.getQueryGoal().getQueryString(true));+ if (!theQuery.modifier.isEmpty()) sb.append("+" + theQuery.modifier.toString());+ sb.append("+" + newModifier);+ }}}