Skip to content

Commit

Permalink
introduced search navigation column on new search page
Browse files Browse the repository at this point in the history
An alle JavaScript-Profis: die Anwahl einer neuen Suchseite über die Selectbox (hinter Category)
funktioniert bei mir nur mit Firefox, nicht aber mit Safari oder Camino. Kann da mal jemand
gucken woran das liegt?

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4508 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
orbiter committed Feb 25, 2008
1 parent 87a8747 commit bd2d9f7
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 167 deletions.
24 changes: 7 additions & 17 deletions htroot/yacy/user/ysearch.html
Expand Up @@ -43,13 +43,12 @@ <h2><a href="http://yacy.net">A Peer-to-Peer Search Network</a></h2>
<div id="content">
<div id="main">
<div id="welcome">
<h2>Welcome to YaCy P2P Web Search!</h2>

#(input)#
::
<form class="search small" action="ysearch.html" method="get" accept-charset="UTF-8">
<fieldset class="yacys">
<input id="searchtext" name="search" type="text" size="50" maxlength="80" value="#[former]#" onclick="document.getElementById('Enter').value = 'Search'" />
Search: <input id="searchtext" name="search" type="text" size="50" maxlength="80" value="#[former]#" onclick="document.getElementById('Enter').value = 'Search'" />
<input id="searchbutton" id="Enter" type="submit" name="Enter" value="Search" />
<input type="hidden" name="contentdom" value="#[contentdom]#" />
<input type="hidden" name="former" value="#[former]#" />
Expand All @@ -69,9 +68,8 @@ <h2>Welcome to YaCy P2P Web Search!</h2>
::
<form class="search small" action="ysearch.html" method="get" accept-charset="UTF-8">
<fieldset class="yacys">
<input id="searchtext" name="search" type="text" size="50" maxlength="80" value="#[former]#" onclick="document.getElementById('Enter').value = 'Search'" />
<input id="searchbutton" type="submit" name="Enter" value="Search" /> &nbsp;
<a href="index.html?display=#[display]#&amp;input=#[input]#&amp;searchoptions=1&amp;count=#[count]#&amp;resource=#[resource]#&amp;time=#[time]#&amp;urlmaskfilter=#[urlmaskfilter]#&amp;prefermaskfilter=#[prefermaskfilter]#&amp;cat=#[cat]#&amp;constraint=#[constraint]#&amp;contentdom=#[contentdom]#&amp;former=#[former]#">more options</a>
Search: <input id="searchtext" name="search" type="text" size="50" maxlength="80" value="#[former]#" onclick="document.getElementById('Enter').value = 'Search'" />
<input id="searchbutton" type="submit" name="Enter" value="Search" />
<div class="ysearch">
<input type="radio" id="text" name="contentdom" value="text"#(contentdomCheckText)#:: checked="checked"#(/contentdomCheckText)# />
<label for="text">Text</label>&nbsp;&nbsp;
Expand All @@ -88,7 +86,6 @@ <h2>Welcome to YaCy P2P Web Search!</h2>
<input type="hidden" name="count" value="#[count]#" />
<input type="hidden" name="offset" value="#[offset]#" />
<input type="hidden" name="resource" value="#[resource]#" />
<input type="hidden" name="time" value="#[time]#" />
<input type="hidden" name="urlmaskfilter" value="#[urlmaskfilter]#" />
<input type="hidden" name="prefermaskfilter" value="#[prefermaskfilter]#" />
<input type="hidden" name="depth" value="#[depth]#" />
Expand Down Expand Up @@ -123,7 +120,7 @@ <h2>Welcome to YaCy P2P Web Search!</h2>
::
<div id="results"></div>
<span id="resCounter" style="display: inline;">Results <strong id="resultsOffset">#[offset]#</strong>-<strong id="itemscount">#[itemscount]#</strong> from <strong id="totalcount">#[totalcount]#</strong> total#(globalresults)#.:: (<strong id="localResourceSize">#[localResourceSize]#</strong> local, <strong id="remoteResourceSize">#[remoteResourceSize]#</strong> remote), <strong id="remoteIndexCount">#[remoteIndexCount]#</strong> links from <strong id="remotePeerCount">#[remotePeerCount]#</strong> other YaCy peers.#(/globalresults)#</span>
<span id="resNav" style="display: inline;">#[resnav]#</span>
<span id="resNav" style="display: inline;"></span>
::
<p>Searching the web with this peer is disabled for unauthorized users. Please <a href="Status.html?login=">log in</a> as administrator to use the search function</p>
#(/num-results)#
Expand All @@ -143,16 +140,9 @@ <h2>Welcome to YaCy P2P Web Search!</h2>
</div>

<div id="sidebar">
<div id="navigate" class="boxed">
<h2 class="title">Navigate</h2>
<div class="content">
<form id="form1" method="post" action="#">
<fieldset>
<input id="inputsubmit1" type="submit" name="inputsubmit1" value="Sign In" />
</fieldset>
</form>
</div>
</div>
<!-- attach the bottomline -->
<!--#include virtual="/yacy/user/ysearchitem.html?bottomline=true&eventID=#[eventID]#" -->

<!--
<div id="updates" class="boxed">
<h2 class="title">News</h2>
Expand Down
149 changes: 25 additions & 124 deletions htroot/yacy/user/ysearch.java
@@ -1,14 +1,15 @@
// ysearch.java
// -----------------------
// part of the AnomicHTTPD caching proxy
// (C) by Michael Peter Christen; mc@anomic.de
// first published on http://www.anomic.de
// Frankfurt, Germany, 2004
// ysearchitem.java
// (C) 2004-2008 by Michael Peter Christen; mc@yacy.net, Frankfurt a. M., Germany
// first published 2004 on http://yacy.net
//
// $LastChangedDate: 2008-02-07 22:16:36 +0000 (Do, 07 Feb 2008) $
// $LastChangedRevision: 4459 $
// This is a part of YaCy, a peer-to-peer based web search engine
//
// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $
// $LastChangedRevision: 1986 $
// $LastChangedBy: orbiter $
//
// LICENSE
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
Expand All @@ -22,52 +23,23 @@
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Using this software in any meaning (reading, learning, copying, compiling,
// running) means that you agree that the Author(s) is (are) not responsible
// for cost, loss of data or any harm that may be caused directly or indirectly
// by usage of this softare or this documentation. The usage of this software
// is on your own risk. The installation and usage (starting/running) of this
// software may allow other people or application to access your computer and
// any attached devices and is highly dependent on the configuration of the
// software which must be done by the user of the software; the author(s) is
// (are) also not responsible for proper configuration and usage of the
// software, even if provoked by documentation provided together with
// the software.
//
// Any changes to this file according to the GPL as documented in the file
// gpl.txt aside this file in the shipment you received can be done to the
// lines that follows this copyright notice here, but changes must not be
// done inside the copyright notive above. A re-distribution must contain
// the intact and unchanged copyright notice.
// Contributions and changes to the program code must be marked as such.
//
// You must compile this file with
// javac -classpath .:../classes yacysearch.java
// if the shell's current path is HTROOT

import java.util.HashMap;
import java.util.TreeSet;

import de.anomic.http.httpHeader;
import de.anomic.index.indexURLEntry;
import de.anomic.kelondro.kelondroBitfield;
import de.anomic.kelondro.kelondroMSetTools;
import de.anomic.plasma.plasmaCondenser;
import de.anomic.plasma.plasmaParserDocument;
import de.anomic.plasma.plasmaSearchEvent;
import de.anomic.plasma.plasmaSearchQuery;
import de.anomic.plasma.plasmaSearchRankingProfile;
import de.anomic.plasma.plasmaSnippetCache;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCore;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.server.logging.serverLog;
import de.anomic.tools.yFormatter;
import de.anomic.yacy.yacyCore;
import de.anomic.yacy.yacyNewsPool;
import de.anomic.yacy.yacyNewsRecord;
import de.anomic.yacy.yacyURL;

public class ysearch {
Expand All @@ -77,7 +49,6 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
sb.localSearchLastAccess = System.currentTimeMillis();

boolean searchAllowed = sb.getConfigBool("publicSearchpage", true) || sb.verifyAuthentication(header, false);

boolean authenticated = sb.adminAuthenticated(header) >= 2;
int display = (post == null) ? 0 : post.getInt("display", 0);
if ((display == 1) && (!authenticated)) display = 0;
Expand All @@ -88,11 +59,11 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve

// get query
String querystring = (post == null) ? "" : post.get("search", "").trim();
final serverObjects prop = new serverObjects();

boolean rss = (post == null) ? false : post.get("rss", "false").equals("true");
if ((post == null) || (env == null) || (querystring.length() == 0) || (!searchAllowed)) {
// we create empty entries for template strings
final serverObjects prop = new serverObjects();
prop.put("searchagain", "0");
prop.put("input", input);
prop.put("display", display);
Expand Down Expand Up @@ -168,7 +139,6 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
// patch until better search profiles are available
if ((contentdomCode != plasmaSearchQuery.CONTENTDOM_TEXT) && (itemsPerPage <= 32)) itemsPerPage = 32;

serverObjects prop = new serverObjects();
if (post.get("cat", "href").equals("href")) {

final TreeSet<String>[] query = plasmaSearchQuery.cleanQuery(querystring); // converts also umlaute
Expand All @@ -187,51 +157,6 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
kelondroMSetTools.excludeDestructive(query[0], plasmaSwitchboard.stopwords);
}

// if a minus-button was hit, remove a special reference first
if (post.containsKey("deleteref")) {
if (!sb.verifyAuthentication(header, true)) {
prop.put("AUTHENTICATE", "admin log-in"); // force log-in
return prop;
}

// delete the index entry locally
final String delHash = post.get("deleteref", ""); // urlhash
sb.wordIndex.removeWordReferences(query[0], delHash);

// make new news message with negative voting
HashMap<String, String> map = new HashMap<String, String>();
map.put("urlhash", delHash);
map.put("vote", "negative");
map.put("refid", "");
yacyCore.newsPool.publishMyNews(yacyNewsRecord.newRecord(yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, map));
}

// if a plus-button was hit, create new voting message
if (post.containsKey("recommendref")) {
if (!sb.verifyAuthentication(header, true)) {
prop.put("AUTHENTICATE", "admin log-in"); // force log-in
return prop;
}
final String recommendHash = post.get("recommendref", ""); // urlhash
indexURLEntry urlentry = sb.wordIndex.loadedURL.load(recommendHash, null, 0);
if (urlentry != null) {
indexURLEntry.Components comp = urlentry.comp();
plasmaParserDocument document;
document = plasmaSnippetCache.retrieveDocument(comp.url(), true, 5000, true);
if (document != null) {
// create a news message
HashMap<String, String> map = new HashMap<String, String>();
map.put("url", comp.url().toNormalform(false, true).replace(',', '|'));
map.put("title", comp.dc_title().replace(',', ' '));
map.put("description", ((document == null) ? comp.dc_title() : document.dc_title()).replace(',', ' '));
map.put("author", ((document == null) ? "" : document.dc_creator()));
map.put("tags", ((document == null) ? "" : document.dc_subject(' ')));
yacyCore.newsPool.publishMyNews(yacyNewsRecord.newRecord(yacyNewsPool.CATEGORY_SURFTIPP_ADD, map));
document.close();
}
}
}

// prepare search properties
final boolean yacyonline = ((yacyCore.seedDB != null) && (yacyCore.seedDB.mySeed() != null) && (yacyCore.seedDB.mySeed().getPublicAddress() != null));
final boolean globalsearch = (global) && (yacyonline) && (sb.getConfigBool(plasmaSwitchboard.INDEX_RECEIVE_ALLOW, false));
Expand Down Expand Up @@ -261,7 +186,7 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve


// tell all threads to do nothing for a specific time
sb.intermissionAllThreads(10000);
sb.intermissionAllThreads(3000);

// filter out words that appear in bluelist
theQuery.filterOut(plasmaSwitchboard.blueList);
Expand Down Expand Up @@ -300,7 +225,6 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
handles.add(theQuery.handle);
sb.localSearchTracker.put(client, handles);

prop = new serverObjects();
int totalcount = theSearch.getRankingResult().getLocalResourceSize() + theSearch.getRankingResult().getRemoteResourceSize();
prop.put("num-results_offset", offset);
prop.put("num-results_itemscount", "0");
Expand All @@ -311,31 +235,6 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
prop.put("num-results_globalresults_remoteResourceSize", yFormatter.number(theSearch.getRankingResult().getRemoteResourceSize(), !rss));
prop.put("num-results_globalresults_remoteIndexCount", yFormatter.number(theSearch.getRankingResult().getRemoteIndexCount(), !rss));
prop.put("num-results_globalresults_remotePeerCount", yFormatter.number(theSearch.getRankingResult().getRemotePeerCount(), !rss));

// compose page navigation
StringBuffer resnav = new StringBuffer();
int thispage = offset / theQuery.displayResults();
if (thispage == 0) resnav.append("&lt;&nbsp;"); else {
resnav.append(navurla(thispage - 1, display, theQuery));
resnav.append("<strong>&lt;</strong></a>&nbsp;");
}
int numberofpages = Math.min(10, Math.max(thispage + 2, totalcount / theQuery.displayResults()));
for (int i = 0; i < numberofpages; i++) {
if (i == thispage) {
resnav.append("<strong>");
resnav.append(i + 1);
resnav.append("</strong>&nbsp;");
} else {
resnav.append(navurla(i, display, theQuery));
resnav.append(i + 1);
resnav.append("</a>&nbsp;");
}
}
if (thispage >= numberofpages) resnav.append("&gt;"); else {
resnav.append(navurla(thispage + 1, display, theQuery));
resnav.append("<strong>&gt;</strong></a>");
}
prop.put("num-results_resnav", resnav.toString());

// generate the search result lines; they will be produced by another servlet
for (int i = 0; i < theQuery.displayResults(); i++) {
Expand Down Expand Up @@ -405,18 +304,20 @@ public static serverObjects respond(httpHeader header, serverObjects post, serve
// return rewrite properties
return prop;
}

private static String navurla(int page, int display, plasmaSearchQuery theQuery) {
/*
private static String navhidden(int page, int display, plasmaSearchQuery theQuery) {
return
"<a href=\"ysearch.html?display=" + display +
"&amp;search=" + theQuery.queryString() +
"&amp;count="+ theQuery.displayResults() +
"&amp;offset=" + (page * theQuery.displayResults()) +
"&amp;resource=" + theQuery.searchdom() +
"&amp;urlmaskfilter=" + theQuery.urlMask +
"&amp;prefermaskfilter=" + theQuery.prefer +
"&amp;cat=href&amp;constraint=" + ((theQuery.constraint == null) ? "" : theQuery.constraint.exportB64()) +
"&amp;contentdom=" + theQuery.contentdom() +
"&amp;former=" + theQuery.queryString() + "\">";
"<input type=\"hidden\" name=\"display\" value=\"" + display + "\" />" +
"<input type=\"hidden\" name=\"search\" value=\"" + theQuery.queryString() + "\" />" +
"<input type=\"hidden\" name=\"count\" value=\"" + theQuery.displayResults() + "\" />" +
"<input type=\"hidden\" name=\"offset\" value=\"" + (page * theQuery.displayResults()) + "\" />" +
"<input type=\"hidden\" name=\"resource\" value=\"" + theQuery.searchdom() + "\" />" +
"<input type=\"hidden\" name=\"urlmaskfilter\" value=\"" + theQuery.urlMask + "\" />" +
"<input type=\"hidden\" name=\"prefermaskfilter\" value=\"" + theQuery.prefer + "\" />" +
"<input type=\"hidden\" name=\"cat\" value=\"href\" />" +
"<input type=\"hidden\" name=\"constraint\" value=\"" + ((theQuery.constraint == null) ? "" : theQuery.constraint.exportB64()) + "\" />" +
"<input type=\"hidden\" name=\"contentdom\" value=\"" + theQuery.contentdom() + "\" />" +
"<input type=\"hidden\" name=\"former\" value=\"" + theQuery.queryString() + "\" />";
}
*/
}
26 changes: 21 additions & 5 deletions htroot/yacy/user/ysearchitem.html
Expand Up @@ -38,11 +38,6 @@ <h3 class="linktitle">
<guid isPermaLink="false">#[urlhash]#</guid>
</item>
#(/rss)#
#(references)#::
<p><strong>Topwords</strong>:
#{words}#&nbsp;<a href="ysearch.html?search=#[newsearch]#&amp;Enter=Search&amp;count=#[count]#&amp;offset=#[offset]#&amp;resource=#[resource]#&amp;contentdom=#[contentdom]#&amp;time=#[time]#">#[word]#</a>&nbsp;|#{/words}#
</p>
#(/references)#
#(rssreferences)#::
<yacyTopwords:topwords>
#{words}#
Expand All @@ -56,4 +51,25 @@ <h3 class="linktitle">
progressbar.step(1);
</script>
#(/dynamic)#
#(navigation)#::
<div id="navigate" class="boxed">
<h2 class="title">Navigate</h2>
<div class="content">
<p><Strong>Page</strong>:
#[resnav]#
</p>
#(topwords)#::
<p><strong>Category</strong>:
<select id="count" name="count">
<option selected="selected">-select-</option>
#{words}#
<option onclick="window.location.href='/yacy/user/ysearch.html?search=#[newsearch]#&amp;Enter=Search&amp;count=#[count]#&amp;offset=#[offset]#&amp;resource=#[resource]#&amp;contentdom=#[contentdom]#'">#[word]#</option>
#{/words}#
</select>
</p>
#(/topwords)#
</div>
</div>

#(/navigation)#

0 comments on commit bd2d9f7

Please sign in to comment.