Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

added a size field to the search results. The file size is now shown in the html search page and the yacyinteractive. The field is presen in the rss and json

orbiter7cfab2ee9a18
diff --git a/htroot/yacyinteractive.html b/htroot/yacyinteractive.html
index 60d61f23e..a84e77543 100644
--- a/htroot/yacyinteractive.html
+++ b/htroot/yacyinteractive.html
@@ -54,11 +54,13 @@ function updatepage(str) {
html += "<table class=\"networkTable\" border=\"0\" cellpadding=\"2\" cellspacing=\"1\" width=\"99%\">";
html += "<tr class=\"TableHeader\" valign=\"bottom\">";
html += "<td width=\"30%\">Name</td>";
+ html += "<td width=\"60\">Size</td>";
//html += "<td>Description</td>";
html += "<td>Link</td></tr>";
for (var i = 0; i < firstChannel.items.length; i++) {
item = firstChannel.items[i];
html += "<tr class=\"TableCellLight\"><td>"+ item.title + "</td>";
+ html += "<td align=\"right\">" + item.sizename + "</td>";
//html += "<td>" + item.description + "</td>";
html += "<td><a href=\"" + item.link + "\">" + item.link + "</a></td></tr>";
}
diff --git a/htroot/yacysearchitem.html b/htroot/yacysearchitem.html
index e0094d28d..b51776512 100644
--- a/htroot/yacysearchitem.html
+++ b/htroot/yacysearchitem.html
@@ -17,7 +17,7 @@
#(/authorized)#
<p class="snippet"><span class="snippetLoaded" id="h#[urlhash]#">#[description]#</span></p>
<p class="url"><a href="#[link]#" id="url#[urlhash]#">#[urlname]#</a></p>
- <p class="urlinfo">#[date]# | YBR-#[ybr]# | <a href="ViewFile.html?urlHash=#[urlhash]#&amp;words=#[words]#&amp;display=#[display]#">Info</a> | <a href="yacysearch.html?cat=image&amp;url=#[link]#&amp;search=#[former]#&amp;display=#[display]#">Pictures</a></p>
+ <p class="urlinfo">#[date]# | #[sizename]# | YBR-#[ybr]# | <a href="ViewFile.html?urlHash=#[urlhash]#&amp;words=#[words]#&amp;display=#[display]#">Info</a> | <a href="yacysearch.html?cat=image&amp;url=#[link]#&amp;search=#[former]#&amp;display=#[display]#">Pictures</a></p>
</div>
::
#{items}#
diff --git a/htroot/yacysearchitem.java b/htroot/yacysearchitem.java
index 3ea613302..61eeba2ee 100644
--- a/htroot/yacysearchitem.java
+++ b/htroot/yacysearchitem.java
@@ -125,6 +125,7 @@ public class yacysearchitem {
prop.put("content_date822", plasmaSwitchboard.dateString822(result.modified()));
prop.put("content_ybr", plasmaSearchRankingProcess.ybr(result.hash()));
prop.putNum("content_size", result.filesize());
+ prop.putHTML("content_sizename", sizename(result.filesize()));
prop.put("content_nl", (item == 0) ? 0 : 1);
final TreeSet<String>[] query = theQuery.queryWords();
@@ -204,5 +205,15 @@ public class yacysearchitem {
if (p < 0) return s.substring(0, length - 3) + "...";
return s.substring(0, length - (s.length() - p) - 3) + "..." + s.substring(p);
}
+
+ private static String sizename(int size) {
+ if (size < 1024) return size + " bytes";
+ size = size / 1024;
+ if (size < 1024) return size + " kbyte";
+ size = size / 1024;
+ if (size < 1024) return size + " mbyte";
+ size = size / 1024;
+ return size + " gbyte";
+ }
}
diff --git a/htroot/yacysearchitem.json b/htroot/yacysearchitem.json
index 68023eb16..a72a91891 100644
--- a/htroot/yacysearchitem.json
+++ b/htroot/yacysearchitem.json
@@ -4,5 +4,7 @@
"link": "#[link]#",
"description": "#[description]#",
"pubDate": "#[date822]#",
+ "size": "#[size]#",
+ "sizename": "#[sizename]#",
"guid": "#[urlhash]#"
}#(/content)#
\ No newline at end of file
diff --git a/htroot/yacysearchitem.xml b/htroot/yacysearchitem.xml
index 2387fe732..d013a0b34 100644
--- a/htroot/yacysearchitem.xml
+++ b/htroot/yacysearchitem.xml
@@ -3,5 +3,7 @@
<link>#[link]#</link>
<description>#[description-xml]#</description>
<pubDate>#[date822]#</pubDate>
+<yacy:size>#[size]#</yacy:size>
+<yacy:sizename>#[sizename]#</yacy:sizename>
<guid isPermaLink="false">#[urlhash]#</guid>
</item>#(/content)#
\ No newline at end of file