Skip to content

Commit

Permalink
- added stealth button to navigation menu
Browse files Browse the repository at this point in the history
- more fixes to progress bar
  • Loading branch information
Orbiter committed Mar 21, 2014
1 parent f0f22e6 commit d1091e7
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 33 deletions.
13 changes: 0 additions & 13 deletions htroot/yacysearch.html
Expand Up @@ -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";
Expand Down
5 changes: 2 additions & 3 deletions htroot/yacysearch.java
Expand Up @@ -157,9 +157,8 @@ public static serverObjects respond(
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");
Expand Down Expand Up @@ -762,7 +761,7 @@ public static serverObjects respond(
"html",
0,
theQuery,
suggestion).toString());
suggestion, true).toString());
prop.put("didYouMean_suggestions_" + meanCount + "_sep", "|");
meanCount++;
} catch (final ConcurrentModificationException e) {
Expand Down
2 changes: 1 addition & 1 deletion htroot/yacysearchitem.java
Expand Up @@ -105,7 +105,7 @@ public static serverObjects respond(final RequestHeader header, final serverObje
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);
Expand Down
2 changes: 1 addition & 1 deletion htroot/yacysearchlatestinfo.java
Expand Up @@ -41,7 +41,7 @@ public static serverObjects respond(@SuppressWarnings("unused") final RequestHea
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;
}
Expand Down
30 changes: 30 additions & 0 deletions 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', '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Peer-to-Peer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
$("[name='resource-switch']").bootstrapSwitch('offText', '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Stealth&nbsp;Mode&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');</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', '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Peer-to-Peer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
$("[name='resource-switch']").bootstrapSwitch('offText', '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Stealth&nbsp;Mode&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');</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]#">
Expand Down
25 changes: 17 additions & 8 deletions htroot/yacysearchtrailer.java
Expand Up @@ -39,6 +39,7 @@
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;
Expand Down Expand Up @@ -68,6 +69,14 @@ public static serverObjects respond(final RequestHeader header, final serverObje
}
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
Expand Down Expand Up @@ -99,7 +108,7 @@ public static serverObjects respond(final RequestHeader header, final serverObje
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++;
Expand Down Expand Up @@ -141,7 +150,7 @@ public static serverObjects respond(final RequestHeader header, final serverObje
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++;
Expand Down Expand Up @@ -184,7 +193,7 @@ public static serverObjects respond(final RequestHeader header, final serverObje
}
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++;
Expand Down Expand Up @@ -225,7 +234,7 @@ public static serverObjects respond(final RequestHeader header, final serverObje
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++;
Expand Down Expand Up @@ -270,7 +279,7 @@ public static serverObjects respond(final RequestHeader header, final serverObje
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));
Expand Down Expand Up @@ -311,7 +320,7 @@ public static serverObjects respond(final RequestHeader header, final serverObje
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++;
Expand Down Expand Up @@ -354,7 +363,7 @@ public static serverObjects respond(final RequestHeader header, final serverObje
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++;
Expand Down Expand Up @@ -398,7 +407,7 @@ public static serverObjects respond(final RequestHeader header, final serverObje
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++;
Expand Down
21 changes: 14 additions & 7 deletions source/net/yacy/search/query/QueryParams.java
Expand Up @@ -598,9 +598,9 @@ public String id(final boolean anonymized) {
* @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());
Expand All @@ -619,20 +619,27 @@ public static StringBuilder navurl(final String ext, final int page, final Query
* - 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);
}
}
}

Expand Down

0 comments on commit d1091e7

Please sign in to comment.