changed protocol facet to show also all other counts if one facet is

selected
pull/1/head
Michael Peter Christen 11 years ago
parent 36e92e898f
commit cbdfef7ce1

@ -757,7 +757,7 @@ public class yacysearch {
prop.put(
"didYouMean_suggestions_" + meanCount + "_url",
QueryParams.navurl(
"html",
RequestHeader.FileType.HTML,
0,
theQuery,
suggestion, true).toString());

@ -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, false).toString());
prop.put("navurlBase", QueryParams.navurlBase(RequestHeader.FileType.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);

@ -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, false).toString());
prop.putJSON("navurlBase", QueryParams.navurlBase(RequestHeader.FileType.HTML, theSearch.query, null, false).toString());
return prop;
}

@ -81,7 +81,7 @@
<ul class="nav nav-sidebar menugroup">
<li><h3>Protocol Facet</h3></li>
#{element}#
<li><a href="#[url]#" class="MenuItemLink"><input type="checkbox" onchange="window.location.href='#[url]#'"#(on)# checked="checked"::#(/on)#/> #[name]# (#[count]#)</a></li>
<li><a href="#[url]#" class="MenuItemLink"><input type="radio" name="protocols" onchange="window.location.href='#[url]#'"#(on)# checked="checked"::#(/on)#/> #[name]# (#[count]#)</a></li>
#{/element}#</ul>
#(activate)#
<script type="text/javascript">

@ -125,7 +125,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, false).toString());
prop.put(fileType, "nav-namespace_element_" + i + "_url", QueryParams.navurl(fileType, 0, theSearch.query, nav, false).toString());
prop.put("nav-namespace_element_" + i + "_count", count);
prop.put("nav-namespace_element_" + i + "_nl", 1);
i++;
@ -167,7 +167,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, false).toString());
prop.put(fileType, "nav-domains_element_" + i + "_url", QueryParams.navurl(fileType, 0, theSearch.query, nav, false).toString());
prop.put("nav-domains_element_" + i + "_count", count);
prop.put("nav-domains_element_" + i + "_nl", 1);
i++;
@ -210,7 +210,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, false).toString());
prop.put(fileType, "nav-languages_element_" + i + "_url", QueryParams.navurl(fileType, 0, theSearch.query, nav, false).toString());
prop.put("nav-languages_element_" + i + "_count", count);
prop.put("nav-languages_element_" + i + "_nl", 1);
i++;
@ -251,7 +251,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, false).toString());
prop.put(fileType, "nav-authors_element_" + i + "_url", QueryParams.navurl(fileType, 0, theSearch.query, nav, false).toString());
prop.put("nav-authors_element_" + i + "_count", count);
prop.put("nav-authors_element_" + i + "_nl", 1);
i++;
@ -296,7 +296,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, false).toString());
prop.put(fileType, "nav-topics_element_" + i + "_url", QueryParams.navurl(fileType, 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));
@ -314,10 +314,18 @@ public class yacysearchtrailer {
prop.put("nav-protocols", 0);
} else {
prop.put("nav-protocols", 1);
//int httpCount = theSearch.protocolNavigator.delete("http");
//int httpsCount = theSearch.protocolNavigator.delete("https");
//theSearch.protocolNavigator.inc("http(s)", httpCount + httpsCount);
navigatorIterator = theSearch.protocolNavigator.keys(false);
int i = 0, pos = 0, neg = 0;
String nav;
boolean visible = false;
String oldQuery = theSearch.query.getQueryGoal().query_original; // prepare hack to make radio-button like navigation
String oldProtocolModifier = theSearch.query.modifier.protocol;
if (oldProtocolModifier != null && oldProtocolModifier.length() > 0) {theSearch.query.modifier.remove("/" + oldProtocolModifier); theSearch.query.modifier.remove(oldProtocolModifier);}
theSearch.query.modifier.protocol = "";
theSearch.query.getQueryGoal().query_original = oldQuery.replaceAll(" /https", "").replaceAll(" /http", "").replaceAll(" /ftp", "").replaceAll(" /smb", "").replaceAll(" /file", "");
while (i < 10 && navigatorIterator.hasNext()) {
name = navigatorIterator.next().trim();
count = theSearch.protocolNavigator.get(name);
@ -326,7 +334,7 @@ public class yacysearchtrailer {
}
visible = visible || "ftp,smb".indexOf(name) >= 0;
nav = "%2F" + name;
if (theSearch.query.modifier.protocol == null || !theSearch.query.modifier.protocol.contains(name)) {
if (oldProtocolModifier == null || !oldProtocolModifier.equals(name)) {
pos++;
prop.put("nav-protocols_element_" + i + "_on", 1);
prop.put(fileType, "nav-protocols_element_" + i + "_modifier", nav);
@ -337,11 +345,15 @@ 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, false).toString());
String url = QueryParams.navurl(fileType, 0, theSearch.query, nav, false).toString();
prop.put(fileType, "nav-protocols_element_" + i + "_url", url);
prop.put("nav-protocols_element_" + i + "_count", count);
prop.put("nav-protocols_element_" + i + "_nl", 1);
i++;
}
theSearch.query.modifier.protocol = oldProtocolModifier;
if (oldProtocolModifier != null && oldProtocolModifier.length() > 0) theSearch.query.modifier.add(oldProtocolModifier);
theSearch.query.getQueryGoal().query_original = oldQuery;
prop.put("nav-protocols_element", i);
prop.put("nav-protocols_activate", neg > 0 || visible ? 1 : 0); // by default off
i--;
@ -380,7 +392,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, false).toString());
prop.put(fileType, "nav-filetypes_element_" + i + "_url", QueryParams.navurl(fileType, 0, theSearch.query, nav, false).toString());
prop.put("nav-filetypes_element_" + i + "_count", count);
prop.put("nav-filetypes_element_" + i + "_nl", 1);
i++;
@ -424,7 +436,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, false).toString());
prop.put(fileType, "nav-vocabulary_" + navvoccount + "_element_" + i + "_url", QueryParams.navurl(fileType, 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++;

@ -54,7 +54,7 @@ public class QueryGoal {
private static char dq = '"';
private static String seps = ".:;#'*`,!$%()=?^<>/&_";
private String query_original;
public String query_original;
private HandleSet include_hashes, exclude_hashes;
private final NormalizedWords include_words, exclude_words;
private final ArrayList<String> include_strings, exclude_strings;

@ -170,6 +170,14 @@ public class QueryModifier {
if (m != null) modifier.append(m);
}
public void remove(String m) {
int p = modifier.indexOf(" " + m);
if (p >= 0) modifier.delete(p, p + m.length() + 1);
p = modifier.indexOf(m);
if (p == 0) modifier.delete(p, p + m.length());
if (modifier.length() > 0 && modifier.charAt(0) == ' ') modifier.delete(0, 1);
}
@Override
public String toString() {
return this.modifier.toString();

@ -49,6 +49,7 @@ import net.yacy.cora.federate.yacy.CacheStrategy;
import net.yacy.cora.geo.GeoLocation;
import net.yacy.cora.lod.vocabulary.Tagging;
import net.yacy.cora.order.Base64Order;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.cora.storage.HandleSet;
import net.yacy.cora.util.ConcurrentLog;
import net.yacy.cora.util.SpaceExceededException;
@ -414,7 +415,7 @@ public final class QueryParams {
params.setFacetLimit(this.maxfacets);
params.setFacetSort(FacetParams.FACET_SORT_COUNT);
params.setParam(FacetParams.FACET_METHOD, FacetParams.FACET_METHOD_fcs);
for (String field: this.facetfields) params.addFacetField(field);
for (String field: this.facetfields) params.addFacetField("{!ex=" + field + "}" + field);
} else {
params.setFacet(false);
}
@ -464,7 +465,7 @@ public final class QueryParams {
}
if (this.modifier.protocol != null) {
fq.append(" AND ").append(CollectionSchema.url_protocol_s.getSolrFieldName()).append(':').append(this.modifier.protocol);
fq.append(" AND {!tag=").append(CollectionSchema.url_protocol_s.getSolrFieldName()).append("}").append(CollectionSchema.url_protocol_s.getSolrFieldName()).append(':').append(this.modifier.protocol);
}
if (this.tld != null) {
@ -598,7 +599,7 @@ public final class QueryParams {
* @param addToQuery
* @return
*/
public static StringBuilder navurl(final String ext, final int page, final QueryParams theQuery, final String newQueryString, boolean newModifierReplacesOld) {
public static StringBuilder navurl(final RequestHeader.FileType ext, final int page, final QueryParams theQuery, final String newQueryString, boolean newModifierReplacesOld) {
final StringBuilder sb = navurlBase(ext, theQuery, newQueryString, newModifierReplacesOld);
@ -619,11 +620,11 @@ 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, boolean newModifierReplacesOld) {
public static StringBuilder navurlBase(final RequestHeader.FileType ext, final QueryParams theQuery, final String newModifier, boolean newModifierReplacesOld) {
final StringBuilder sb = new StringBuilder(120);
sb.append("/yacysearch.");
sb.append(ext);
sb.append(ext.name().toLowerCase());
sb.append("?query=");
if (newModifier == null) {
@ -636,7 +637,7 @@ public final class QueryParams {
if (newModifierReplacesOld) {
sb.append(newModifier);
} else {
sb.append(theQuery.getQueryGoal().getQueryString(true));
sb.append(theQuery.queryGoal.getQueryString(true));
if (!theQuery.modifier.isEmpty()) sb.append("+" + theQuery.modifier.toString());
sb.append("+" + newModifier);
}

Loading…
Cancel
Save