- separated sidebars in new search interface and placed them in their own files which can be put in into the search page like plug-ins git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4529 6c8d7289-2bf4-0310-a012-ef5d649a1542pull/1/head
parent
a8f54dd244
commit
bfed9c2da6
@ -0,0 +1,14 @@
|
|||||||
|
#(history)#::
|
||||||
|
<div id="partners" class="boxed">
|
||||||
|
<h2 class="title">Recent Searches</h2>
|
||||||
|
<div class="content">
|
||||||
|
<ul>
|
||||||
|
#{list}#
|
||||||
|
<li><a href="/yacy/user/ysearch.html?search=#[querystring]#&resource=#[searchdom]#&contentdom=#[contentdom]#">#[querystring]#</a></li>
|
||||||
|
#{/list}#
|
||||||
|
</ul>
|
||||||
|
<p>The search history is only visible for users from host #[host]#</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
#(/history)#
|
||||||
|
|
@ -0,0 +1,68 @@
|
|||||||
|
// sidebar_history.java
|
||||||
|
// (C) 2008 by Michael Peter Christen; mc@yacy.net, Frankfurt a. M., Germany
|
||||||
|
// first published 03.03.2008 on http://yacy.net
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import de.anomic.http.httpHeader;
|
||||||
|
import de.anomic.plasma.plasmaSearchQuery;
|
||||||
|
import de.anomic.plasma.plasmaSwitchboard;
|
||||||
|
import de.anomic.server.serverObjects;
|
||||||
|
import de.anomic.server.serverSwitch;
|
||||||
|
|
||||||
|
public class sidebar_history {
|
||||||
|
|
||||||
|
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
|
||||||
|
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
|
||||||
|
final serverObjects prop = new serverObjects();
|
||||||
|
|
||||||
|
// list search history
|
||||||
|
Iterator<plasmaSearchQuery> i = sb.localSearches.iterator();
|
||||||
|
String client = (String) header.get(httpHeader.CONNECTION_PROP_CLIENTIP);
|
||||||
|
plasmaSearchQuery query;
|
||||||
|
int c = 0;
|
||||||
|
HashSet<String> visibleQueries = new HashSet<String>();
|
||||||
|
while (i.hasNext()) {
|
||||||
|
query = i.next();
|
||||||
|
if (query.resultcount == 0) continue;
|
||||||
|
if (query.offset != 0) continue;
|
||||||
|
if (!query.host.equals(client)) continue; // the search history should only be visible from the user who initiated the search
|
||||||
|
if (visibleQueries.contains(query.queryString)) continue; // avoid doubles
|
||||||
|
visibleQueries.add(query.queryString);
|
||||||
|
prop.put("history_list_" + c + "_querystring", query.queryString);
|
||||||
|
prop.put("history_list_" + c + "_searchdom", query.searchdom());
|
||||||
|
prop.put("history_list_" + c + "_contentdom", query.contentdom());
|
||||||
|
c++;
|
||||||
|
if (c >= 10) break;
|
||||||
|
}
|
||||||
|
prop.put("history_list", c);
|
||||||
|
prop.put("history_host", client);
|
||||||
|
if (c == 0) prop.put("history", 0); else prop.put("history", 1); // switch on if there is anything to see
|
||||||
|
|
||||||
|
return prop;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
#(rssreferences)#::
|
||||||
|
<yacyTopwords:topwords>
|
||||||
|
#{words}#
|
||||||
|
<yacyTopwords:item><yacyTopwords:word>#[word]#</yacyTopwords:word></yacyTopwords:item>
|
||||||
|
#{/words}#
|
||||||
|
</yacyTopwords:topwords>
|
||||||
|
#(/rssreferences)#
|
||||||
|
#(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 onchange="window.location.href=this.options[this.selectedIndex].value">
|
||||||
|
<option selected="selected">-select-</option>
|
||||||
|
#{words}#
|
||||||
|
<option value="/yacy/user/ysearch.html?search=#[newsearch]#&Enter=Search&count=#[count]#&offset=#[offset]#&resource=#[resource]#&contentdom=#[contentdom]#&zone=#[zonecode]#">#[word]#</option>
|
||||||
|
#{/words}#
|
||||||
|
</select>
|
||||||
|
</p>
|
||||||
|
#(/topwords)#
|
||||||
|
#(languagezone)#::
|
||||||
|
<p><strong>Language Zone</strong>:
|
||||||
|
<select onchange="window.location.href=this.options[this.selectedIndex].value">
|
||||||
|
<option selected="selected">-select-</option>
|
||||||
|
#{zones}#
|
||||||
|
<option value="/yacy/user/ysearch.html?search=#[search]#&Enter=Search&count=#[count]#&offset=#[offset]#&resource=#[resource]#&contentdom=#[contentdom]#&zone=#[zonecode]#">#[zone]#</option>
|
||||||
|
#{/zones}#
|
||||||
|
</select>
|
||||||
|
</p>
|
||||||
|
#(/languagezone)#
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
#(/navigation)#
|
@ -0,0 +1,173 @@
|
|||||||
|
// sidebar_navigation.java
|
||||||
|
// (C) 2008 by Michael Peter Christen; mc@yacy.net, Frankfurt a. M., Germany
|
||||||
|
// first published 03.03.2008 on http://yacy.net
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
import de.anomic.http.httpHeader;
|
||||||
|
import de.anomic.kelondro.kelondroMSetTools;
|
||||||
|
import de.anomic.kelondro.kelondroNaturalOrder;
|
||||||
|
import de.anomic.plasma.plasmaSearchEvent;
|
||||||
|
import de.anomic.plasma.plasmaSearchQuery;
|
||||||
|
import de.anomic.plasma.plasmaSwitchboard;
|
||||||
|
import de.anomic.server.serverObjects;
|
||||||
|
import de.anomic.server.serverSwitch;
|
||||||
|
|
||||||
|
public class sidebar_navigation {
|
||||||
|
|
||||||
|
private static final int MAX_TOPWORDS = 24;
|
||||||
|
|
||||||
|
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
|
||||||
|
final serverObjects prop = new serverObjects();
|
||||||
|
|
||||||
|
String eventID = post.get("eventID", "");
|
||||||
|
boolean rss = post.get("rss", "false").equals("true");
|
||||||
|
|
||||||
|
// default settings for blank item
|
||||||
|
prop.put("navigation", "0");
|
||||||
|
prop.put("rssreferences", "0");
|
||||||
|
|
||||||
|
// find search event
|
||||||
|
plasmaSearchEvent theSearch = plasmaSearchEvent.getEvent(eventID);
|
||||||
|
if (theSearch == null) {
|
||||||
|
// the event does not exist, show empty page
|
||||||
|
return prop;
|
||||||
|
}
|
||||||
|
plasmaSearchQuery theQuery = theSearch.getQuery();
|
||||||
|
int offset = theQuery.neededResults() - theQuery.displayResults();
|
||||||
|
int totalcount = theSearch.getRankingResult().getLocalResourceSize() + theSearch.getRankingResult().getRemoteResourceSize();
|
||||||
|
|
||||||
|
// attach the bottom line with search references (topwords)
|
||||||
|
final Set<String> references = theSearch.references(20);
|
||||||
|
if (references.size() > 0) {
|
||||||
|
// get the topwords
|
||||||
|
final TreeSet<String> topwords = new TreeSet<String>(kelondroNaturalOrder.naturalComparator);
|
||||||
|
String tmp = "";
|
||||||
|
Iterator<String> i = references.iterator();
|
||||||
|
while (i.hasNext()) {
|
||||||
|
tmp = i.next();
|
||||||
|
if (tmp.matches("[a-z]+")) {
|
||||||
|
topwords.add(tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// filter out the badwords
|
||||||
|
final TreeSet<String> filteredtopwords = kelondroMSetTools.joinConstructive(topwords, plasmaSwitchboard.badwords);
|
||||||
|
if (filteredtopwords.size() > 0) {
|
||||||
|
kelondroMSetTools.excludeDestructive(topwords, plasmaSwitchboard.badwords);
|
||||||
|
}
|
||||||
|
|
||||||
|
// avoid stopwords being topwords
|
||||||
|
if (env.getConfig("filterOutStopwordsFromTopwords", "true").equals("true")) {
|
||||||
|
if ((plasmaSwitchboard.stopwords != null) && (plasmaSwitchboard.stopwords.size() > 0)) {
|
||||||
|
kelondroMSetTools.excludeDestructive(topwords, plasmaSwitchboard.stopwords);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rss) {
|
||||||
|
String word;
|
||||||
|
int hintcount = 0;
|
||||||
|
final Iterator<String> iter = topwords.iterator();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
word = (String) iter.next();
|
||||||
|
if (word != null) {
|
||||||
|
prop.putHTML("rssreferences_words_" + hintcount + "_word", word);
|
||||||
|
}
|
||||||
|
prop.put("rssreferences_words", hintcount);
|
||||||
|
if (hintcount++ > MAX_TOPWORDS) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
prop.put("rssreferences", "1");
|
||||||
|
} else {
|
||||||
|
String word;
|
||||||
|
int hintcount = 0;
|
||||||
|
final Iterator<String> iter = topwords.iterator();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
word = (String) iter.next();
|
||||||
|
if ((theQuery == null) || (theQuery.queryString == null)) break;
|
||||||
|
if (word != null) {
|
||||||
|
prop.putHTML("navigation_topwords_words_" + hintcount + "_word", word);
|
||||||
|
prop.putHTML("navigation_topwords_words_" + hintcount + "_newsearch", theQuery.queryString.replace(' ', '+') + "+" + word);
|
||||||
|
prop.put("navigation_topwords_words_" + hintcount + "_count", theQuery.displayResults());
|
||||||
|
prop.put("navigation_topwords_words_" + hintcount + "_offset", "0");
|
||||||
|
prop.put("navigation_topwords_words_" + hintcount + "_contentdom", theQuery.contentdom());
|
||||||
|
prop.put("navigation_topwords_words_" + hintcount + "_resource", theQuery.searchdom());
|
||||||
|
prop.put("navigation_topwords_words_" + hintcount + "_zonecode", theQuery.zonecode);
|
||||||
|
}
|
||||||
|
prop.put("navigation_topwords_words", hintcount);
|
||||||
|
if (hintcount++ > MAX_TOPWORDS) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
prop.put("navigation_topwords", "1");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// compose page navigation
|
||||||
|
StringBuffer resnav = new StringBuffer();
|
||||||
|
int thispage = offset / theQuery.displayResults();
|
||||||
|
if (thispage == 0) resnav.append("< "); else {
|
||||||
|
resnav.append(navurla(thispage - 1, theQuery));
|
||||||
|
resnav.append("<strong><</strong></a> ");
|
||||||
|
}
|
||||||
|
int numberofpages = Math.min(10, Math.max(thispage + 2, totalcount / theQuery.displayResults()));
|
||||||
|
for (int j = 0; j < numberofpages; j++) {
|
||||||
|
if (j == thispage) {
|
||||||
|
resnav.append("<strong>");
|
||||||
|
resnav.append(j + 1);
|
||||||
|
resnav.append("</strong> ");
|
||||||
|
} else {
|
||||||
|
resnav.append(navurla(j, theQuery));
|
||||||
|
resnav.append(j + 1);
|
||||||
|
resnav.append("</a> ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (thispage >= numberofpages) resnav.append(">"); else {
|
||||||
|
resnav.append(navurla(thispage + 1, theQuery));
|
||||||
|
resnav.append("<strong>></strong></a>");
|
||||||
|
}
|
||||||
|
prop.put("navigation_resnav", resnav.toString());
|
||||||
|
prop.put("navigation", "1");
|
||||||
|
|
||||||
|
return prop;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String navurla(int page, plasmaSearchQuery theQuery) {
|
||||||
|
return
|
||||||
|
"<a href=\"ysearch.html?search=" + theQuery.queryString() +
|
||||||
|
"&count="+ theQuery.displayResults() +
|
||||||
|
"&offset=" + (page * theQuery.displayResults()) +
|
||||||
|
"&resource=" + theQuery.searchdom() +
|
||||||
|
"&urlmaskfilter=" + theQuery.urlMask +
|
||||||
|
"&prefermaskfilter=" + theQuery.prefer +
|
||||||
|
"&cat=href&constraint=" + ((theQuery.constraint == null) ? "" : theQuery.constraint.exportB64()) +
|
||||||
|
"&contentdom=" + theQuery.contentdom() +
|
||||||
|
"&former=" + theQuery.queryString() + "\">";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue