Skip to content

Commit

Permalink
*) added page to compare results of 2 search engines
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5144 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
low012 committed Sep 13, 2008
1 parent 1fb1665 commit dc56c35
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 0 deletions.
50 changes: 50 additions & 0 deletions htroot/Comparison_p.html
@@ -0,0 +1,50 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>YaCy '#[clientname]#': Websearch Comparison</title>
#%env/templates/metas.template%#
</head>
<body>
#%env/templates/header.template%#
<h2>Websearch Comparison</h2>
<p>This page lets you compare two search engines. Please select search engines
and enter your searchword(s) below.</p>
<fieldset>
<legend>Parameters</legend>
<form action="" method="get">
<dl>
<dt>Left Search Engine</dt>
<dd>
<select name="left">
#{searchengines}#
<option>#[searchengine]#</option>
#{/searchengines}#
</select>
</dd>
<dt>Right Search Engine</dt>
<dd>
<select name="right">
#{searchengines}#
<option>#[searchengine]#</option>
#{/searchengines}#
</select>
</dd>
<dt>Query</dt>
<dd>
<input type="text" name="query" size="60">
</dd>
</dl>
<input type="submit" />
</form>
</fieldset>
#(search)#
::
<fieldset>
<legend>Search Result</legend>
<iframe src="#[left]##[query]#" width="49%" height="300"></iframe>
<iframe src="#[right]##[query]#" width="49%" height="300"></iframe>
</fieldset>
#(/search)#
#%env/templates/footer.template%#
</body>
</html>
69 changes: 69 additions & 0 deletions htroot/Comparison_p.java
@@ -0,0 +1,69 @@
//Comparison_p.java
//-----------------------
//part of the AnomicHTTPD caching proxy
//(C) by Michael Peter Christen; mc@yacy.net
//first published on http://www.anomic.de
//Frankfurt, Germany, 2004
//
//This File is contributed by Marc Nause
//last major change: 13.09.2008
//
//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


//You must compile this file with
//javac -classpath .:../Classes Message.java
//if the shell's current path is HTROOT


import de.anomic.http.httpRequestHeader;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.server.servletProperties;
import java.util.Hashtable;
import java.util.Map;

public class Comparison_p{

public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final servletProperties prop = new servletProperties();

Map<String, String> searchengines = new Hashtable<String, String>();
searchengines.put("YaCy", "yacysearch.html?display=0&amp;query=");
searchengines.put("google.de", "http://www.google.de/?q=");
searchengines.put("metager.de", "http://www.metager.de/meta/cgi-bin/meta.ger1?eingabe=");

if (post != null) {
prop.put("search", 1);
prop.put("search_query", post.get("query", ""));
prop.put("search_left", searchengines.get(post.get("left", searchengines.get("YaCy"))));
prop.put("search_right", searchengines.get(post.get("right", searchengines.get("YaCy"))));
} else {

prop.put("search", 0);

}

prop.put("searchengines", searchengines.size());
int i = 0;
for(String name : searchengines.keySet()){
prop.put("searchengines_" + i + "_searchengine", name);
i++;
}

// return rewrite properties
return prop;
}
}

0 comments on commit dc56c35

Please sign in to comment.