- fixed some bugs in Table viewer

- added 'select all' feature in Tables_p
- enhanced ViewFile.html: has now an input field to load arbitrary resources from the web and analyze them (!!!)
- included the ViewFile servlet into the Index Administration menu
- show in ViewFile if ressource is in url-db and/or in Web cache
- bugfixes to BEncodedHeap and Tables management

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6713 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 15 years ago
parent 38d7a28cd2
commit 270fb38674

@ -8,22 +8,16 @@
#%env/templates/metas.template%#
<script>
<!--
function selectall(name){
function setall(name, check){
var selectForm = document.forms.namedItem(name);
var count = selectForm.elements["num"].value;
for(i = 0; i < count; i++){
selectForm.elements["item_" + i].checked = true;
}
}
function deselectall(name){
var selectForm = document.forms.namedItem(name);
var count = selectForm.elements["num"].value;
for(i = 0; i < count; i++){
selectForm.elements["item_" + i].checked = false;
selectForm.elements["item_" + i].checked = check;
}
}
-->
</script> </head>
</script>
</head>
<body id="Tables">
#%env/templates/header.template%#
@ -39,7 +33,7 @@
<legend><label for="table">Recorded Actions</label></legend>
<table border="0" cellpadding="2" cellspacing="1">
<tr class="TableHeader" valign="bottom">
<td><input type="checkbox" name="allswitch" onselect="selectall(this.form.name)" ondeselect="deselectall(this.form.name)"/></td>
<td><input type="checkbox" name="allswitch" onclick="setall(this.form.name, this.value)" /></td>
<td>Date</td>
<td>Type</td>
<td>Comment</td>
@ -57,8 +51,6 @@
</table>
<p>
<input type="hidden" name="num" value="#[num]#" />
<input type="button" onclick="selectall(this.form.name)" value="Select All" />
<input type="button" onclick="deselectall(this.form.name)" value="Deselect All" />&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" name="execrows" value="Execute Selected Actions" />
<input type="submit" name="deleterows" value="Delete Selected Actions" />
</p>

@ -6,6 +6,17 @@
<link rel="alternate" type="application/xml" title="Tables" href="Tables.rss?table=#[table]#" />
#(/showtable)#
#%env/templates/metas.template%#
<script>
<!--
function setall(name, check){
var selectForm = document.forms.namedItem(name);
var count = selectForm.elements["num"].value;
for(i = 0; i < count; i++){
selectForm.elements["item_" + i].checked = check;
}
}
-->
</script>
</head>
<body id="Tables">
#%env/templates/header.template%#
@ -28,12 +39,12 @@
</fieldset>
</form>
#(showtable)#::
<form action="Tables_p.html" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
<form action="Tables_p.html" method="post" enctype="multipart/form-data" accept-charset="UTF-8" name="tablelisting">
<fieldset>
<legend><label for="table">Table Editor: showing table '#[table]#'</label></legend>
<table border="0" cellpadding="2" cellspacing="1">
<tr class="TableHeader" valign="bottom">
<td>&nbsp;</td>
<td><input type="checkbox" name="allswitch" onclick="setall(this.form.name, this.value)" /></td>
<td>PK</td>
#{columns}#
<td>#[header]#</td>
@ -41,7 +52,7 @@
</tr>
#{list}#
<tr class="TableCell#(dark)#Light::Dark::Summary#(/dark)#">
<td align="left"><input type="checkbox" name="mark_#[pk]#" /></td>
<td align="left"><input type="checkbox" name="item_#[count]#" value="mark_#[pk]#" /></td>
<td>#[pk]#</td>
#{columns}#
<td align="left">#[cell]#</td>
@ -51,6 +62,7 @@
</table>
<p>
<input type="hidden" name="table" value="#[table]#" />
<input type="hidden" name="num" value="#[num]#" />
<input type="submit" name="editrow" value="Edit Selected Row" />
<input type="submit" name="addrow" value="Add a new Row" />&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" name="deleterows" value="Delete Selected Rows" />

@ -69,8 +69,8 @@ public class Tables_p {
if (post != null && post.get("deleterows", "").length() > 0) {
for (Map.Entry<String, String> entry: post.entrySet()) {
if (entry.getKey().startsWith("mark_") && entry.getValue().equals("on")) try {
sb.tables.delete(table, entry.getKey().substring(5).getBytes());
if (entry.getValue().startsWith("mark_")) try {
sb.tables.delete(table, entry.getValue().substring(5).getBytes());
} catch (IOException e) {
Log.logException(e);
}
@ -125,7 +125,8 @@ public class Tables_p {
row = mapIterator.next();
if (row == null) continue;
prop.put("showtable_list_" + count + "_dark", ((dark) ? 1 : 0) ); dark=!dark;
prop.put("showtable_list_" + count + "_pk", new String(row.getPK()));
prop.put("showtable_list_" + count + "_pk", new String(row.getPK()));
prop.put("showtable_list_" + count + "_count", count);
for (int i = 0; i < columns.size(); i++) {
cell = row.from(columns.get(i));
prop.putHTML("showtable_list_" + count + "_columns_" + i + "_cell", cell == null ? "" : new String(cell));
@ -138,6 +139,7 @@ public class Tables_p {
Log.logException(e);
}
prop.put("showtable_list", count);
prop.put("showtable_num", count);
}
if (post != null && table != null && post.containsKey("editrow")) {

@ -9,17 +9,29 @@
#%env/templates/simpleheader.template%#
::
#%env/templates/header.template%#
#%env/templates/submenuIndexControl.template%#
::
#%env/templates/embeddedheader.template%#
#(/display)#
<h2>View URL Content</h2>
<form method="get" action="ViewFile.html" accept-charset="ascii">
<fieldset><legend>Get URL Viewer</legend>
<dl>
<dt>URL:</dt><dd><input type="text" size="60" name="url" value="#[url]#" />&nbsp;<input type="submit" name="show" value="Show" /></dd>
</dd>
</dl>
<input type="hidden" name="display" value="#[display]#" />
</fieldset>
</form>
#(error)#
<form method="get" action="ViewFile.html" accept-charset="ascii">
<fieldset><legend>View URL Content</legend>
<fieldset><legend>URL Metadata</legend>
<dl>
<dt>URL:</dt> <dd><a href="#[url]#">#[url]#</a></dd>
<dt>Hash:</dt> <dd><a href="/api/yacydoc.html?urlhash=#[hash]#">#[hash]#</a></dd>
<dt>In URL-DB:</dt> <dd>#(inurldb)#no::yes#(/inurldb)#</dd>
<dt>In Cache:</dt> <dd>#(incache)#no::yes#(/incache)#</dd>
<dt>Word Count:</dt> <dd>#[wordCount]#</dd>
<dt>Description:</dt><dd>#[desc]#</dd>
<dt>Size:</dt> <dd>#[size]# Bytes</dd>#(mimeTypeAvailable)#::
@ -40,10 +52,10 @@
<input type="hidden" name="words" value="#[words]#" />
<input type="hidden" name="urlHash" value="#[hash]#" />
<input type="hidden" name="display" value="#[display]#" />
<input type="hidden" name="url" value="#[url]#" />
</fieldset>
</form>
:: <!-- 1 -->
<span class="error">No URL hash submitted.</span>
:: <!-- 2 -->
<span class="error">Unable to find URL Entry in DB</span>
:: <!-- 3 -->
@ -61,25 +73,25 @@
<p>
#(viewMode)#
:: <!-- 1 -->
<fieldset><legend>Plain Resource Content</legend>
<fieldset><legend>Plain Content</legend>
<p class="tt">
#[plainText]#
</p>
</fieldset>
:: <!-- 2 -->
<fieldset><legend>Parsed Resource Content</legend>
<fieldset><legend>Parsed Content</legend>
<p class="tt">
#[parsedText]#
</p>
</fieldset>
:: <!-- 3 -->
<fieldset><legend>Parsed Resource Sentences</legend>
<fieldset><legend>Parsed Sentences</legend>
<ol>#{sentences}#
<li class="tt">#[text]#</li>#{/sentences}#
</ol>
</fieldset>
:: <!-- 4 -->
<fieldset><legend>Original Resource Content</legend>
<fieldset><legend>Original Content</legend>
<iframe src="#[url]#" width="800" height="400" />
</fieldset>
:: <!-- 5 -->

@ -74,11 +74,23 @@ public class ViewFile {
final serverObjects prop = new serverObjects();
final Switchboard sb = (Switchboard)env;
final int display = (post == null) ? 0 : post.getInt("display", 0);
if (post == null) {
prop.put("display", 1);
prop.put("error_display", 0);
prop.putHTML("error_words", "");
prop.put("error_vMode-sentences", "1");
prop.put("error", "1");
prop.put("url", "");
prop.put("viewMode", VIEW_MODE_NO_TEXT);
return prop;
}
final int display = post.getInt("display", 1);
// get segment
Segment indexSegment = null;
if (post != null && post.containsKey("segment")) {
if (post.containsKey("segment")) {
String segmentName = post.get("segment");
if (sb.indexSegments.segmentExist(segmentName)) {
indexSegment = sb.indexSegments.segment(segmentName);
@ -91,7 +103,7 @@ public class ViewFile {
prop.put("display", display);
prop.put("error_display", display);
if (post != null && post.containsKey("words"))
if (post.containsKey("words"))
prop.putHTML("error_words", post.get("words"));
else {
prop.putHTML("error_words", "");
@ -108,17 +120,10 @@ public class ViewFile {
// get the url hash from which the content should be loaded
String urlHash = post.get("urlHash","");
if (urlHash.length() > 0) {
// get the urlEntry that belongs to the url hash
URIMetadataRow urlEntry = null;
urlEntry = indexSegment.urlMetadata().load(urlHash, null, 0);
if (urlEntry == null) {
prop.put("error", "2");
prop.put("viewMode",VIEW_MODE_NO_TEXT);
return prop;
}
// getting the url that belongs to the entry
URIMetadataRow urlEntry = null;
// get the urlEntry that belongs to the url hash
if (urlHash.length() > 0 && (urlEntry = indexSegment.urlMetadata().load(urlHash, null, 0)) != null) {
// get the url that belongs to the entry
final URIMetadataRow.Components metadata = urlEntry.metadata();
if ((metadata == null) || (metadata.url() == null)) {
prop.put("error", "3");
@ -132,6 +137,8 @@ public class ViewFile {
pre = urlEntry.flags().get(Condenser.flag_cat_indexof);
}
prop.put("error_inurldb", urlEntry == null ? 0 : 1);
// alternatively, get the url simply from a url String
// this can be used as a simple tool to test the text parser
final String urlString = post.get("url", "");
@ -154,10 +161,15 @@ public class ViewFile {
if (url == null) {
prop.put("error", "1");
prop.put("viewMode", VIEW_MODE_NO_TEXT);
prop.put("url", "");
return prop;
} else {
prop.put("url", url.toNormalform(false, true));
}
// loading the resource content as byte array
prop.put("error_incache", Cache.has(url) ? 1 : 0);
byte[] resource = null;
ResponseHeader responseHeader = null;
String resMime = null;

@ -3,5 +3,6 @@
<ul class="SubMenu">
<li><a href="/IndexControlRWIs_p.html" class="MenuItemLink lock">RWI Admin</a></li>
<li><a href="/IndexControlURLs_p.html" class="MenuItemLink lock">URL Reference Admin</a></li>
<li><a href="/ViewFile.html?display=1" class="MenuItemLink">URL Viewer</a></li>
</ul>
</div>

@ -80,7 +80,7 @@ public class BEncodedHeap implements Iterable<Map.Entry<byte[], Map<String, byte
final File location,
final int keylength) throws IOException {
this.table = new Heap(location, keylength, NaturalOrder.naturalOrder, 100);
this.columnames = new LinkedHashSet<String>();
this.columnames = new LinkedHashSet<String>();
}
public byte[] encodedKey(String key) {

@ -361,9 +361,12 @@ public class Tables {
TreeMap<String, Row> sortTree = new TreeMap<String, Row>();
Iterator<Row> i = iterator(table, whereKey, whereValue);
Row row;
byte[] r;
while ((maxcount < 0 || maxcount-- > 0) && i.hasNext()) {
row = i.next();
sortTree.put(new String(row.from(sortField)) + new String(row.pk), row);
r = row.from(sortField);
if (r == null) continue;
sortTree.put(new String(r) + new String(row.pk), row);
}
return sortTree.values();
}
@ -441,6 +444,12 @@ public class Tables {
return this.map.get(colname);
}
public byte[] from(String colname, byte[] dflt) {
byte[] r = this.map.get(colname);
if (r == null) return dflt;
return r;
}
public String toString() {
StringBuilder sb = new StringBuilder(keymaxlen + 20 * map.size());
sb.append(new String(pk)).append(":").append(map.toString());

Loading…
Cancel
Save