- updated DetailedSearch and ViewFile

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3173 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
karlchenofhell 18 years ago
parent 00aa9472d6
commit 35fb671721

@ -4,14 +4,14 @@
<title>YaCy '#[clientname]#': Search Page</title>
#%env/templates/metas.template%#
</head>
<body id="DetailedSearch" onload="document.getElementById('search').focus()">
<body id="DetailedSearch"#(jumpToCursor)#:: onload="document.getElementById('search').focus()"#(/jumpToCursor)#>
#%env/templates/header.template%#
<h2>Detailed Search</h2>
#(num-results)#
::
<p><strong>#[linkcount]#</strong> results from <strong>#[orderedcount]#</strong> ordered links from <strong>#[filteredcount]#</strong> filtered links of a total number of <strong>#[totalcount]#</strong> known.</p>
#(/num-results)#
<form class="dsearch" action="DetailedSearch.html" method="get" enctype="multipart/form-data">
<form class="dsearch" action="DetailedSearch.html#Results" method="get" enctype="multipart/form-data">
<fieldset>
<input type="text" name="search" id="search" value="#[search]#" size="50" maxlength="250" />
<input type="submit" name="Enter" value="Search" />
@ -20,9 +20,9 @@
<legend>Query Attributes</legend>
<dl>
<dt><label for="global">Global:</label></dt>
<dd><input type="checkbox" name="global" id="global" #[globalChecked]# /></dd>
<dd><input type="checkbox" name="global" id="global"#(globalChecked)#:: checked="checked"#(/globalChecked)# /></dd>
<dt><label for="postsort">Post-Sort:</label></dt>
<dd><input type="checkbox" name="postsort" id="postsort" #[postsortChecked]# /></dd>
<dd><input type="checkbox" name="postsort" id="postsort"#(postsortChecked)#:: checked="checked"#(/postsortChecked)# /></dd>
<dt><label for="localCount">Max. number of results:</label></dt>
<dd><input type="text" name="localCount" id="localCount" value="#[localCount]#" size="4" maxlength="5" /></dd>
<dt><label for="localTime">Max. search time (seconds):</label></dt>
@ -64,6 +64,8 @@
<input type="submit" name="ResetRanking" value="Re-Set to Built-In Ranking" />
</fieldset>
</form>
<a name="Results"></a>
#(type)#
#(excluded)#
::
@ -81,9 +83,11 @@
#{results}#
<!-- link begin -->
<div class="searchresults">
#(authorized)#::
<div class="urlactions">
<a href="#[delete]#" title="delete" class="deletelink" ><img src="/env/grafics/empty.gif" title="delete" alt="delete" class="deleteIcon" /></a>
</div>
#(/authorized)#
<h4 class="linktitle"><a href="#[url]#">#[description]#</a></h4>
#(snippet)#::<p class="snippet"><em>#[text]#</em></p>#(/snippet)#
<p class="url"><a href="#[url]#" id="url#[urlhash]#">#[urlname]#</a></p>

@ -110,12 +110,13 @@ public class DetailedSearch {
prop.put("localCount", 10);
prop.put("localWDist", 999);
//prop.put("globalChecked", "checked");
prop.put("globalChecked", "");
prop.put("postsortChecked", "checked=\"checked\"");
prop.put("globalChecked", 0);
prop.put("postsortChecked", 1);
prop.put("localTime", 6);
prop.put("results", "");
prop.put("urlmaskoptions", 0);
prop.put("urlmaskoptions_urlmaskfilter", ".*");
prop.put("jumpToCursor", 1);
return prop;
}
@ -200,7 +201,8 @@ public class DetailedSearch {
if (filtered.size() > 0) {
kelondroMSetTools.excludeDestructive(query, plasmaSwitchboard.stopwords);
}
boolean authenticated = sb.adminAuthenticated(header) >= 2;
// if a minus-button was hit, remove a special reference first
if (post.containsKey("deleteref")) {
if (!sb.verifyAuthentication(header, true)) {
@ -235,6 +237,7 @@ public class DetailedSearch {
plasmaSearchTimingProfile remoteTiming = new plasmaSearchTimingProfile(6 * thisSearch.maximumTime / 10, thisSearch.wantedResults);
final serverObjects prop = sb.searchFromLocal(thisSearch, localRanking, localTiming, remoteTiming, postsort);
putRanking(prop, localRanking, "local");
// remember the last search expression
env.setConfig("last-search", querystring);
// process result of search
@ -276,13 +279,19 @@ public class DetailedSearch {
} else {
prop.put("urlmaskoptions", 1);
}
// if user is not authenticated, he may not vote for URLs
int linkcount = Integer.parseInt(prop.get("num-results_linkcount", "0"));
for (int i=0; i<linkcount; i++)
prop.put("type_results_" + i + "_authorized", (authenticated) ? 1 : 0);
prop.put("jumpToCursor", (linkcount > 0) ? 0 : 1);
prop.put("urlmaskoptions_urlmaskfilter", urlmask);
prop.put("type", "0");
prop.put("localCount", count);
prop.put("localWDist", wdist);
prop.put("globalChecked", (global) ? "checked=\"checked\"" : "");
prop.put("postsortChecked", (postsort) ? "checked=\"checked\"" : "");
prop.put("globalChecked", (global) ? 1 : 0);
prop.put("postsortChecked", (postsort) ? 1 : 0);
prop.put("localTime", searchtime/1000);
prop.put("search", post.get("search", ""));
prop.putAll(localRanking.toExternalMap("local"));

@ -1,103 +1,90 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>YaCy '#[clientname]#': View URL Content</title>
#%env/templates/metas.template%#
</head>
<body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0">
#%env/templates/header.template%#
<br><br>
<h2>View URL Content</h2>
<!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]#': View URL Content</title>
#%env/templates/metas.template%#
</head>
<body>
#%env/templates/header.template%#
<h2>View URL Content</h2>
<p><font color="red">
#(error)#
<table border="0" cellpadding="2" cellspacing="1">
<tr class="TableHeader">
<td>URL</td>
<td><a href="#[url]#">#[url]#</a></td>
</tr>
<tr class="TableCellDark">
<td>Hash</td>
<td><tt>#[hash]#</tt></td>
</tr>
<tr class="TableCellLight">
<td>Word Count</td>
<td><tt>#[wordCount]#</tt></td>
</tr>
<tr class="TableCellDark">
<td>Description</td>
<td><tt>#[desc]#</tt></td>
</tr>
<tr class="TableCellLight">
<td>Size</td>
<td><tt>#[size]#</tt></td>
</tr>
<tr class="TableCellDark">
<td>MimeType</td>
<td><tt>#[mimeType]#</tt></td>
</tr>
<tr class="TableCellLight">
<td>View as:</td>
<td>
<a href="?urlHash=#[hash]#&viewMode=iframe&words=#[words]#">Original</a> |
<a href="?urlHash=#[hash]#&viewMode=plain&words=#[words]#">Plain Text</a> |
<a href="?urlHash=#[hash]#&viewMode=parsed&words=#[words]#">Parsed Text</a> |
<a href="?urlHash=#[hash]#&viewMode=sentences&words=#[words]#">Parsed Sentences</a> |
<a href="?urlHash=#[hash]#&viewMode=links&words=#[words]#">Link List</a>
</td>
</tr>
</table>
#(error)#
<form method="get" action="ViewFile.html" accept-charset="ascii">
<fieldset><legend>View URL Content</legend>
<dl>
<dt>URL:</dt> <dd><a href="#[url]#">#[url]#</a></dd>
<dt>Hash:</dt> <dd>#[hash]#</dd>
<dt>Word Count:</dt> <dd>#[wordCount]#</dd>
<dt>Description:</dt><dd>#[desc]#</dd>
<dt>Size:</dt> <dd>#[size]#</dd>#(mimeTypeAvailable)#::
<dt>MimeType:</dt> <dd>#[mimeType]#</dd>#(/mimeTypeAvailable)#
<dt><label for="viewMode">View as</label>:</dt>
<dd>
<select id="viewMode" name="viewMode">
<option value="iframe"#(vMode-iframe)#:: selected="selected"#(/vMode-iframe)#>Original</option>
<option value="plain"#(vMode-plain)#:: selected="selected"#(/vMode-plain)#>Plain Text</option>
<option value="parsed"#(vMode-parsed)#:: selected="selected"#(/vMode-parsed)#>Parsed Text</option>
<option value="sentences"#(vMode-sentences)#:: selected="selected"#(/vMode-sentences)#>Parsed Sentences</option>
<option value="links"#(vMode-links)#:: selected="selected"#(/vMode-links)#>Link List</option>
</select>
<input type="submit" name="show" value="Show" />
</dd>
</dl>
<input type="hidden" name="words" value="#[words]#" />
<input type="hidden" name="urlHash" value="#[hash]#" />
</fieldset>
</form>
:: <!-- 1 -->
No URL hash submitted.
<span class="error">No URL hash submitted.</span>
:: <!-- 2 -->
Unable to find URL Entry in DB
<span class="error">Unable to find URL Entry in DB</span>
:: <!-- 3 -->
Invalid URL
<span class="error">Invalid URL</span>
:: <!-- 4 -->
Unable to download resource content.<br>
<p class="error">Unable to download resource content.</p>
<tt>#[errorText]#</tt>
:: <!-- 5 -->
Unable to parse resource content.<br>
<p class="error">Unable to parse resource content.</p>
<tt>#[errorText]#</tt>
:: <!-- 6 -->
Unsupported protocol.
<span class="error">Unsupported protocol.</span>
#(/error)#
</font>
</p>
<p>
#(viewMode)#
:: <!-- 1 -->
<h3>Plain Resource Content</h3><br>
<tt>#[plainText]#</tt>
<fieldset><legend>Plain Resource Content</legend>
<p class="tt">
#[plainText]#
</p>
</fieldset>
:: <!-- 2 -->
<h3>Parsed Resource Content</h3><br>
<tt>#[parsedText]#</tt>
<fieldset><legend>Parsed Resource Content</legend>
<p class="tt">
#[parsedText]#
</p>
</fieldset>
:: <!-- 3 -->
<h3>Parsed Resource Sentences</h3><br>
<table border="0" cellpadding="2" cellspacing="1">
#{sentences}#
<tr class="TableCell#(dark)#Light::Dark::Summary#(/dark)#" title="#[sessionName]#">
<td>#[nr]#</td>
<td><tt>#[text]#</tt></td>
</tr>
#{/sentences}#
</table>
<fieldset><legend>Parsed Resource Sentences</legend>
<ol>#{sentences}#
<li class="tt">#[text]#</li>#{/sentences}#
</ol>
</fieldset>
:: <!-- 4 -->
<h3>Original Resource Content</h3><br>
<iframe src="#[url]#" width="800" height="400">
</iframe>
<fieldset><legend>Original Resource Content</legend>
<iframe src="#[url]#" width="800" height="400" />
</fieldset>
:: <!-- 5 -->
<h3>Link List</h3><br>
<table border="0" cellpadding="2" cellspacing="1">
#{links}#
<tr class="TableCell#(dark)#Light::Dark::Summary#(/dark)#">
<td>#[nr]#</td>
<td><tt>#[type]#</tt></td>
<td><tt>#[text]#</tt></td>
<td><tt>#[link]#</tt></td>
<td><tt>#[attr]#</tt></td>
</tr>
#{/links}#
<tr class="TableCell#(dark)#Light::Dark::Summary#(/dark)#">
<td>#[nr]#</td>
<td class="tt">#[type]#</tt></td>
<td class="tt">#[text]#</tt></td>
<td class="tt">#[link]#</tt></td>
<td class="tt">#[attr]#</tt></td>
</tr>#{/links}#
</table>
#(/viewMode)#
</p>

@ -79,28 +79,26 @@ public class ViewFile {
public static final int VIEW_MODE_AS_PARSED_SENTENCES = 3;
public static final int VIEW_MODE_AS_IFRAME = 4;
public static final int VIEW_MODE_AS_LINKLIST = 5;
public static final String[] highlightingColors = new String[] {
"255,255,100",
"255,155,155",
"0,255,0",
"0,255,255",
"204,153,0",
"204,153,255"
};
private static final String HIGHLIGHT_CSS = "searchHighlight";
private static final int MAX_HIGHLIGHTS = 6;
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
serverObjects prop = new serverObjects();
plasmaSwitchboard sb = (plasmaSwitchboard)env;
if (post != null && post.containsKey("words")) try {
prop.put("error_words",URLEncoder.encode((String) post.get("words"), "UTF-8"));
} catch (UnsupportedEncodingException e1) {
// ignore this. this should not occure
if (post != null && post.containsKey("words"))
prop.put("error_words", wikiCode.replaceHTMLonly((String)post.get("words")));
else {
prop.put("error", 1);
prop.put("viewmode", 0);
return prop;
}
String viewMode = post.get("viewMode","sentences");
prop.put("error_vMode-" + viewMode, 1);
URL url = null;
String descr = "";
int wordCount = 0;
@ -203,7 +201,7 @@ public class ViewFile {
/* ignore this */
}
// if the metadata where not cached try to load it from web
// if the metadata was not cached try to load it from web
if (resInfo == null) {
String protocol = url.getProtocol();
if (!((protocol.equals("http") || protocol.equals("https")))) {
@ -265,16 +263,17 @@ public class ViewFile {
}
}
content = content.replaceAll("<", "&lt;").replaceAll(">", "&gt;")
.replaceAll("\"", "&quot;").replaceAll("\n", "<br>")
.replaceAll("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
content = wikiCode.replaceHTMLonly(
content.replaceAll("\n", "<br />").replaceAll("\t", "&nbsp;&nbsp;&nbsp;&nbsp;"));
prop.put("error", 0);
prop.put("viewMode", VIEW_MODE_AS_PLAIN_TEXT);
prop.put("viewMode_plainText", content);
} else if (viewMode.equals("iframe")) {
prop.put("viewMode", VIEW_MODE_AS_IFRAME);
prop.put("viewMode_url", url.toNormalform());
prop.put("viewMode_url", wikiCode.replaceHTMLonly(url.toNormalform()));
} else if (viewMode.equals("parsed") || viewMode.equals("sentences") || viewMode.equals("links")) {
// parsing the resource content
plasmaParserDocument document = null;
@ -301,37 +300,41 @@ public class ViewFile {
}
resMime = document.getMimeType();
String[] wordArray = wordArray(post.get("words", null));
if (viewMode.equals("parsed")) {
String content = new String(document.getTextBytes());
content = wikiCode.replaceHTML(content); // added by Marc Nause
content = content.replaceAll("\n", "<br>").replaceAll("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
content = content.replaceAll("\n", "<br />").replaceAll("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
prop.put("viewMode", VIEW_MODE_AS_PARSED_TEXT);
prop.put("viewMode_parsedText", content);
prop.put("viewMode_parsedText", markup(wordArray, content));
} else if (viewMode.equals("sentences")) {
prop.put("viewMode", VIEW_MODE_AS_PARSED_SENTENCES);
final Iterator sentences = document.getSentences(pre);
boolean dark = true;
int i = 0;
String sentence;
if (sentences != null) {
String[] wordArray = wordArray(post.get("words", null));
// Search word highlighting
while (sentences.hasNext()) {
prop.put("viewMode_sentences_" + i + "_nr", Integer.toString(i + 1));
prop.put("viewMode_sentences_" + i + "_text", markup(wordArray, (String) sentences.next()));
prop.put("viewMode_sentences_" + i + "_dark", ((dark) ? 1 : 0));
dark = !dark;
i++;
sentence = (String)sentences.next();
if (sentence.trim().length() > 0) {
prop.put("viewMode_sentences_" + i + "_nr", Integer.toString(i + 1));
prop.put("viewMode_sentences_" + i + "_text", markup(wordArray, (String) sentences.next()));
prop.put("viewMode_sentences_" + i + "_dark", ((dark) ? 1 : 0));
dark = !dark;
i++;
}
}
}
prop.put("viewMode_sentences", i);
} else if (viewMode.equals("links")) {
prop.put("viewMode", VIEW_MODE_AS_LINKLIST);
String[] wordArray = wordArray(post.get("words", null));
boolean dark = true;
int i = 0;
i += putMediaInfo(prop, wordArray, i, document.getVideolinks(), "video", (i % 2 == 0));
@ -359,13 +362,13 @@ public class ViewFile {
if (document != null) document.close();
}
prop.put("error", 0);
prop.put("error_url", url.toNormalform());
prop.put("error_url", wikiCode.replaceHTMLonly(url.toNormalform()));
prop.put("error_hash", urlHash);
prop.put("error_wordCount", Integer.toString(wordCount));
prop.put("error_desc", descr);
prop.put("error_size", size);
prop.put("error_mimeType", resMime);
prop.put("error_mimeTypeAvailable", (resMime == null) ? 0 : 1);
prop.put("error_mimeTypeAvailable_mimeType", resMime);
return prop;
}
@ -381,14 +384,14 @@ public class ViewFile {
private static final String markup(String[] wordArray, String message) {
message = wikiCode.replaceHTML(message);
if (wordArray != null) for (int j = 0; j < wordArray.length; j++) {
String currentWord = wordArray[j].trim();
message = message.replaceAll(currentWord,
"<b style=\"color: black; background-color: rgb("
+ highlightingColors[j % 6]
+ ");\">" + currentWord
+ "</b>");
}
if (wordArray != null)
for (int j = 0; j < wordArray.length; j++) {
String currentWord = wordArray[j].trim();
message = message.replaceAll(currentWord,
"<span class=\"" + HIGHLIGHT_CSS + ((j % MAX_HIGHLIGHTS) + 1) + "\">" +
currentWord +
"</span>");
}
return message;
}

@ -66,6 +66,12 @@ a.bookmarkAction { color: #999999; }
.searchresults .url a { color: #008000; }
.snippetLoading { color: #999999; }
.snippetError { color: red; }
.searchHighlight1 { font-weight: bold; color: #FFFF64; }
.searchHighlight2 { font-weight: bold; color: #FF9B9B; }
.searchHighlight3 { font-weight: bold; color: #0F0; }
.searchHighlight4 { font-weight: bold; color: #0FF; }
.searchHighlight5 { font-weight: bold; color: #C90; }
.searchHighlight6 { font-weight: bold; color: #C9F; }
/* other */
.settingsValue { color: #556699; }

@ -170,6 +170,13 @@ div.ProgressBarFill {
color:red;
}
.searchHighlight1 { font-weight: bold; color: #FFFF64; }
.searchHighlight2 { font-weight: bold; color: #FF9B9B; }
.searchHighlight3 { font-weight: bold; color: #0F0; }
.searchHighlight4 { font-weight: bold; color: #0FF; }
.searchHighlight5 { font-weight: bold; color: #C90; }
.searchHighlight6 { font-weight: bold; color: #C9F; }
/* other */
.settingsValue {

@ -171,6 +171,13 @@ div.ProgressBarFill {
color:red;
}
.searchHighlight1 { font-weight: bold; color: #FFFF64; }
.searchHighlight2 { font-weight: bold; color: #FF9B9B; }
.searchHighlight3 { font-weight: bold; color: #0F0; }
.searchHighlight4 { font-weight: bold; color: #0FF; }
.searchHighlight5 { font-weight: bold; color: #C90; }
/* other */
.settingsValue {

@ -164,6 +164,13 @@ a.bookmarkAction {
color:red;
}
.searchHighlight1 { font-weight: bold; color: #FFFF64; }
.searchHighlight2 { font-weight: bold; color: #FF9B9B; }
.searchHighlight3 { font-weight: bold; color: #0F0; }
.searchHighlight4 { font-weight: bold; color: #0FF; }
.searchHighlight5 { font-weight: bold; color: #C90; }
/* other */
.settingsValue {

@ -179,6 +179,13 @@ div.ProgressBarFill {
color:red;
}
.searchHighlight1 { font-weight: bold; color: #FFFF64; }
.searchHighlight2 { font-weight: bold; color: #FF9B9B; }
.searchHighlight3 { font-weight: bold; color: #0F0; }
.searchHighlight4 { font-weight: bold; color: #0FF; }
.searchHighlight5 { font-weight: bold; color: #C90; }
/* other */
.settingsValue {

@ -2178,9 +2178,9 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
if ((snippet != null) && (snippet.getSource() == plasmaSnippetCache.ERROR_NO_MATCH)) {
// suppress line: there is no match in that resource
} else {*/
prop.put("type_results_" + i + "_recommend", (yacyCore.newsPool.getSpecific(yacyNewsPool.OUTGOING_DB, "stippadd", "url", urlstring) == null) ? 1 : 0);
prop.put("type_results_" + i + "_recommend_deletelink", "/yacysearch.html?search=" + formerSearch + "&Enter=Search&count=" + query.wantedResults + "&order=" + crypt.simpleEncode(ranking.toExternalString()) + "&resource=local&time=3&deleteref=" + urlhash + "&urlmaskfilter=.*");
prop.put("type_results_" + i + "_recommend_recommendlink", "/yacysearch.html?search=" + formerSearch + "&Enter=Search&count=" + query.wantedResults + "&order=" + crypt.simpleEncode(ranking.toExternalString()) + "&resource=local&time=3&recommendref=" + urlhash + "&urlmaskfilter=.*");
prop.put("type_results_" + i + "_authorized_recommend", (yacyCore.newsPool.getSpecific(yacyNewsPool.OUTGOING_DB, "stippadd", "url", urlstring) == null) ? 1 : 0);
prop.put("type_results_" + i + "_authorized_recommend_deletelink", "/yacysearch.html?search=" + formerSearch + "&Enter=Search&count=" + query.wantedResults + "&order=" + crypt.simpleEncode(ranking.toExternalString()) + "&resource=local&time=3&deleteref=" + urlhash + "&urlmaskfilter=.*");
prop.put("type_results_" + i + "_authorized_recommend_recommendlink", "/yacysearch.html?search=" + formerSearch + "&Enter=Search&count=" + query.wantedResults + "&order=" + crypt.simpleEncode(ranking.toExternalString()) + "&resource=local&time=3&recommendref=" + urlhash + "&urlmaskfilter=.*");
prop.put("type_results_" + i + "_description", comp.descr());
prop.put("type_results_" + i + "_url", urlstring);
prop.put("type_results_" + i + "_urlhash", urlhash);

Loading…
Cancel
Save