From 3f321ece7deb94c6bc3e04255fbef24fec5790a5 Mon Sep 17 00:00:00 2001 From: orbiter Date: Mon, 25 Feb 2008 21:26:49 +0000 Subject: [PATCH] added a search history to the new search page the history distinguishes between different users and identifies them by their ip a history is only shown to the user who submitted the search git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4510 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/CrawlProfileEditor_p.html | 2 +- htroot/yacy/user/ysearch.html | 40 ------------------- htroot/yacy/user/ysearchitem.html | 16 +++++++- htroot/yacy/user/ysearchitem.java | 24 +++++++++++ .../htmlFilter/htmlFilterContentScraper.java | 4 +- source/de/anomic/http/httpSSI.java | 18 ++++----- source/de/anomic/http/httpdFileHandler.java | 12 +++--- source/de/anomic/yacy/yacyClient.java | 1 + 8 files changed, 56 insertions(+), 61 deletions(-) diff --git a/htroot/CrawlProfileEditor_p.html b/htroot/CrawlProfileEditor_p.html index ba36674b8..226857b8d 100644 --- a/htroot/CrawlProfileEditor_p.html +++ b/htroot/CrawlProfileEditor_p.html @@ -108,8 +108,8 @@ type="text" value="#[value]#"#(/type)# />:: #(type)##(checked)#false::true#(/checked)#::#[value]#::#[value]##(/type)##(/readonly)# #{/entries}# +
 
- #(/edit)# diff --git a/htroot/yacy/user/ysearch.html b/htroot/yacy/user/ysearch.html index 10fdad8f9..f9d5a8c3d 100755 --- a/htroot/yacy/user/ysearch.html +++ b/htroot/yacy/user/ysearch.html @@ -142,46 +142,6 @@ var progressbar = new Progressbar(#[results]#, document.getElementById("results" diff --git a/htroot/yacy/user/ysearchitem.html b/htroot/yacy/user/ysearchitem.html index e911c3f0d..29ad7765e 100644 --- a/htroot/yacy/user/ysearchitem.html +++ b/htroot/yacy/user/ysearchitem.html @@ -9,7 +9,7 @@ :: #{items}#
- + #[name]# @@ -70,6 +70,18 @@ progressbar.step(1); #(/topwords)#
- #(/navigation)# +#(history)#:: +
+

Recent Searches

+
+ +

The search history is only visible for users from host #[host]#

+
+
+#(/history)# diff --git a/htroot/yacy/user/ysearchitem.java b/htroot/yacy/user/ysearchitem.java index 65202a012..b2fbc7706 100644 --- a/htroot/yacy/user/ysearchitem.java +++ b/htroot/yacy/user/ysearchitem.java @@ -28,6 +28,7 @@ import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URLEncoder; import java.util.ArrayList; +import java.util.HashSet; import java.util.Iterator; import java.util.Set; import java.util.TreeSet; @@ -189,6 +190,29 @@ public class ysearchitem { prop.put("navigation_resnav", resnav.toString()); prop.put("navigation", "1"); + // list search history + Iterator i = sb.localSearches.iterator(); + String client = (String) header.get(httpHeader.CONNECTION_PROP_CLIENTIP); + plasmaSearchQuery query; + int c = 0; + HashSet visibleQueries = new HashSet(); + 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; } diff --git a/source/de/anomic/htmlFilter/htmlFilterContentScraper.java b/source/de/anomic/htmlFilter/htmlFilterContentScraper.java index 18e5b2956..94d56e914 100644 --- a/source/de/anomic/htmlFilter/htmlFilterContentScraper.java +++ b/source/de/anomic/htmlFilter/htmlFilterContentScraper.java @@ -240,8 +240,8 @@ public class htmlFilterContentScraper extends htmlFilterAbstractScraper implemen // System.out.println("ScrapeTag1: tagname=" + tagname + ", opts=" + tagopts.toString() + ", text=" + new String(text)); if ((tagname.equalsIgnoreCase("a")) && (text.length < 2048)) { String href = tagopts.getProperty("href", ""); - if (href.length() > 0) { - yacyURL url = absolutePath(href); + yacyURL url; + if ((href.length() > 0) && ((url = absolutePath(href)) != null)) { String f = url.getFile(); int p = f.lastIndexOf('.'); String type = (p < 0) ? "" : f.substring(p + 1); diff --git a/source/de/anomic/http/httpSSI.java b/source/de/anomic/http/httpSSI.java index f2fa36bc5..4cae78c22 100644 --- a/source/de/anomic/http/httpSSI.java +++ b/source/de/anomic/http/httpSSI.java @@ -35,11 +35,11 @@ import de.anomic.server.serverByteBuffer; public class httpSSI { - public static void writeSSI(serverByteBuffer in, OutputStream out, String authorization) throws IOException { - writeSSI(in, 0, out, authorization); + public static void writeSSI(serverByteBuffer in, OutputStream out, String authorization, String requesthost) throws IOException { + writeSSI(in, 0, out, authorization, requesthost); } - public static void writeSSI(serverByteBuffer in, int off, OutputStream out, String authorization) throws IOException { + public static void writeSSI(serverByteBuffer in, int off, OutputStream out, String authorization, String requesthost) throws IOException { int p = in.indexOf("".getBytes(), p + 10); @@ -48,8 +48,8 @@ public class httpSSI { } else { out.write(in.getBytes(off, p - off)); } - parseSSI(in, p, q + 3 - p, out, authorization); - writeSSI(in, q + 3, out, authorization); + parseSSI(in, p, q + 3 - p, out, authorization, requesthost); + writeSSI(in, q + 3, out, authorization, requesthost); } else /* p < 0 */ { if (out instanceof httpChunkedOutputStream) { ((httpChunkedOutputStream) out).write(in, off, in.length() - off); @@ -59,17 +59,17 @@ public class httpSSI { } } - private static void parseSSI(serverByteBuffer in, int off, int len, OutputStream out, String authorization) { + private static void parseSSI(serverByteBuffer in, int off, int len, OutputStream out, String authorization, String requesthost) { if (in.startsWith("