Skip to content

Commit

Permalink
added a 'more options' link to yacysearch page
Browse files Browse the repository at this point in the history
(which referes to the index.html page with extended options activated)

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3031 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
orbiter committed Dec 1, 2006
1 parent 7cc4cec commit 1697fa3
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 27 deletions.
50 changes: 29 additions & 21 deletions htroot/index.java
Expand Up @@ -35,6 +35,7 @@
import de.anomic.http.httpHeader;
import de.anomic.net.URL;
import de.anomic.plasma.plasmaSearchPreOrder;
import de.anomic.plasma.plasmaSearchQuery;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCore;
import de.anomic.server.serverDate;
Expand All @@ -47,18 +48,24 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
final serverObjects prop = new serverObjects();

boolean authenticated = sb.adminAuthenticated(header) >= 2;
int display = ((post == null) || (!authenticated)) ? 0 : post.getInt("display", 0);

boolean global = (post == null) ? true : post.get("resource", "global").equals("global");
int searchoptions = (post == null) ? 0 : post.getInt("searchoptions", 0);
final boolean authenticated = sb.adminAuthenticated(header) >= 2;
final int display = ((post == null) || (!authenticated)) ? 0 : post.getInt("display", 0);
final int searchoptions = (post == null) ? 0 : post.getInt("searchoptions", 0);
final String former = (post == null) ? "" : post.get("former", "");
final int count = (post == null) ? 10 : post.getInt("count", 10);
final int time = (post == null) ? 10 : post.getInt("time", 6);
final String urlmaskfilter = (post == null) ? ".*" : post.get("urlmaskfilter", ".*");
final String prefermaskfilter = (post == null) ? "" : post.get("prefermaskfilter", "");
final String constraint = (post == null) ? plasmaSearchQuery.catchall_constraint.exportB64() : post.get("constraint", "______");
final String cat = (post == null) ? "href" : post.get("cat", "href");
final int type = (post == null) ? 0 : post.getInt("type", 0);

final boolean indexDistributeGranted = sb.getConfig("allowDistributeIndex", "true").equals("true");
final boolean indexReceiveGranted = sb.getConfig("allowReceiveIndex", "true").equals("true");
final String handover = (post == null) ? "" : post.get("handover", "");
if (!indexDistributeGranted || !indexReceiveGranted) { global = false; }

final String referer = (String) header.get("Referer");

if (referer != null) {
URL url;
try {
Expand All @@ -80,16 +87,16 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
String promoteSearchPageGreeting = env.getConfig("promoteSearchPageGreeting", "");
if (promoteSearchPageGreeting.length() == 0) promoteSearchPageGreeting = "P2P WEB SEARCH";
prop.put("promoteSearchPageGreeting", promoteSearchPageGreeting);
prop.put("former", handover);
prop.put("former", former);
prop.put("num-results", 0);
prop.put("excluded", 0);
prop.put("combine", 0);
prop.put("resultbottomline", 0);
prop.put("searchoptions", searchoptions);
prop.put("searchoptions_count-10", 1);
prop.put("searchoptions_count-50", 0);
prop.put("searchoptions_count-100", 0);
prop.put("searchoptions_count-1000", 0);
prop.put("searchoptions_count-10", (count == 10) ? 1 : 0);
prop.put("searchoptions_count-50", (count == 50) ? 1 : 0);
prop.put("searchoptions_count-100", (count == 100) ? 1 : 0);
prop.put("searchoptions_count-1000", (count == 1000) ? 1 : 0);
prop.put("searchoptions_order-ybr-date-quality", plasmaSearchPreOrder.canUseYBR() ? 1 : 0);
prop.put("searchoptions_order-ybr-quality-date", 0);
prop.put("searchoptions_order-date-ybr-quality", 0);
Expand All @@ -98,22 +105,23 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
prop.put("searchoptions_order-quality-date-ybr", 0);
prop.put("searchoptions_resource-global", ((global) ? 1 : 0));
prop.put("searchoptions_resource-local", ((global) ? 0 : 1));
prop.put("searchoptions_time-1", 0);
prop.put("searchoptions_time-3", 0);
prop.put("searchoptions_time-6", 1);
prop.put("searchoptions_time-10", 0);
prop.put("searchoptions_time-30", 0);
prop.put("searchoptions_time-60", 0);
prop.put("searchoptions_time-1", (time == 1) ? 1 : 0);
prop.put("searchoptions_time-3", (time == 3) ? 1 : 0);
prop.put("searchoptions_time-6", (time == 6) ? 1 : 0);
prop.put("searchoptions_time-10", (time == 10) ? 1 : 0);
prop.put("searchoptions_time-30", (time == 30) ? 1 : 0);
prop.put("searchoptions_time-60", (time == 60) ? 1 : 0);
prop.put("searchoptions_urlmaskoptions", 0);
prop.put("searchoptions_urlmaskoptions_urlmaskfilter", ".*");
prop.put("searchoptions_urlmaskoptions_urlmaskfilter", urlmaskfilter);
prop.put("searchoptions_prefermaskoptions", 0);
prop.put("searchoptions_prefermaskoptions_prefermaskfilter", "");
prop.put("searchoptions_prefermaskoptions_prefermaskfilter", prefermaskfilter);
prop.put("searchoptions_indexofChecked", "");
prop.put("results", "");
prop.put("cat", "href");
prop.put("type", "0");
prop.put("cat", cat);
prop.put("type", type);
prop.put("depth", "0");
prop.put("display", display);
prop.put("constraint", constraint);
prop.put("searchoptions_display", display);


Expand Down
7 changes: 6 additions & 1 deletion htroot/yacysearch.html
Expand Up @@ -22,8 +22,13 @@
<p class="yacylogo"><a href="http://yacy.net/yacy/" class="yacylogo"><img src="/env/grafics/yacy.png" alt="yacy" /></a></p>
<h2>#[promoteSearchPageGreeting]#</h2>
<fieldset class="maininput">
<input name="search" type="text" size="52" maxlength="80" value="#[former]#" onClick='document.searchform.Enter.value = "Search"' />
<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td width="80%">
<input name="search" type="text" size="50" maxlength="80" value="#[former]#" onClick='document.searchform.Enter.value = "Search"' />
<input type="submit" name="Enter" value="Search" />
</td><td width="20%">
<a href="index.html?display=#[display]#&searchoptions=1&count=#[count]#&order=#[order]#&resource=#[resource]#&time=#[time]#&urlmaskfilter=#[urlmaskfilter]#&prefermaskfilter=#[prefermaskfilter]#&cat=#[cat]#&type=#[type]#&constraint=#[constraint]#&former=#[former]#">more options<a>
</td></tr>
</table>
<input type="hidden" name="former" value="#[former]#" />
<input type="hidden" name="count" value="#[count]#" />
<input type="hidden" name="order" value="#[order]#" />
Expand Down
12 changes: 7 additions & 5 deletions htroot/yacysearch.java
Expand Up @@ -116,6 +116,7 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
prop.put("urlmaskfilter", ".*");
prop.put("prefermaskfilter", "");
prop.put("indexof", "off");
prop.put("constraint", plasmaSearchQuery.catchall_constraint.exportB64());
prop.put("cat", "href");
prop.put("depth", "0");
prop.put("type", 0);
Expand All @@ -128,8 +129,7 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
return prop;
}

// SEARCH
// process search words
// collect search attributes
int maxDistance = Integer.MAX_VALUE;
String querystring = post.get("search", "").trim();
if ((querystring.length() > 2) && (querystring.charAt(0) == '"') && (querystring.charAt(querystring.length() - 1) == '"')) {
Expand All @@ -141,9 +141,6 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
final int count = Integer.parseInt(post.get("count", "10"));
final String order = post.get("order", plasmaSearchPreOrder.canUseYBR() ? "YBR-Date-Quality" : "Date-Quality-YBR");
boolean global = (post == null) ? true : post.get("resource", "global").equals("global");
final boolean indexDistributeGranted = sb.getConfig("allowDistributeIndex", "true").equals("true");
final boolean indexReceiveGranted = sb.getConfig("allowReceiveIndex", "true").equals("true");
if (!indexDistributeGranted || !indexReceiveGranted) { global = false; }
final boolean indexof = post.get("indexof","").equals("on");
final long searchtime = 1000 * Long.parseLong(post.get("time", "10"));
String urlmask = "";
Expand All @@ -161,6 +158,11 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
constraint.set(plasmaCondenser.flag_cat_indexof, true);
}

// SEARCH
final boolean indexDistributeGranted = sb.getConfig("allowDistributeIndex", "true").equals("true");
final boolean indexReceiveGranted = sb.getConfig("allowReceiveIndex", "true").equals("true");
if (!indexDistributeGranted || !indexReceiveGranted) { global = false; }

serverObjects prop = new serverObjects();

if (post.get("cat", "href").equals("href")) {
Expand Down

0 comments on commit 1697fa3

Please sign in to comment.