Skip to content

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

*) adding possibility to display a fileshare-dir as RSS feed (e.g. to monitor the directory for changes) usage example: http://localhost:8080/share/?format=rss

theli51b2df566b47
diff --git a/htroot/htdocsdefault/dir.java b/htroot/htdocsdefault/dir.java
index abfc36726..0c1654a1d 100644
--- a/htroot/htdocsdefault/dir.java
+++ b/htroot/htdocsdefault/dir.java
@@ -58,6 +58,7 @@ import java.util.Iterator;
import de.anomic.data.userDB;
import de.anomic.http.httpHeader;
+import de.anomic.http.httpc;
import de.anomic.http.httpd;
import de.anomic.plasma.plasmaURL;
import de.anomic.index.indexURLEntry;
@@ -279,13 +280,15 @@ public class dir {
// last modification date if the entry
prop.put("dirlist_" + fileIdx + "_dir_date" , dateString(new Date(f.lastModified())));
+ prop.put("dirlist_" + fileIdx + "_dir_rfc822date" , httpc.dateString(new Date(f.lastModified())));
prop.put("dirlist_" + fileIdx + "_dir_timestamp" , Long.toString(f.lastModified()));
// the entry name
- prop.putSafeXML("dirlist_" + fileIdx + "_dir_name" , fileName);
+ prop.putSafeXML("dirlist_" + fileIdx + "_dir_name" , fileName);
if (f.isDirectory()) {
// the entry is a directory
prop.put("dirlist_" + fileIdx + "_dir" , 1);
+ prop.putSafeXML("dirlist_" + fileIdx + "_dir_URL","http://" + yacyCore.seedDB.mySeed.getAddress() + path + fileName + "/");
} else {
// determine if we should display the description string or a preview image
boolean showImage = (description.length() == 0) && (fileName.endsWith(".jpg") || fileName.endsWith(".gif") || fileName.endsWith(".png"));
@@ -296,16 +299,17 @@ public class dir {
prop.put("dirlist_" + fileIdx + "_dir_size" , serverMemory.bytesToString(f.length()));
prop.put("dirlist_" + fileIdx + "_dir_sizeBytes" , Long.toString(f.length()));
// the unique url
- prop.putSafeXML("dirlist_" + fileIdx + "_dir_yacyhURL",yacyhURL(yacyCore.seedDB.mySeed, fileName, md5s));
+ prop.putSafeXML("dirlist_" + fileIdx + "_dir_yacyhURL",yacyhURL(yacyCore.seedDB.mySeed, fileName, md5s));
+ prop.putSafeXML("dirlist_" + fileIdx + "_dir_URL","http://" + yacyCore.seedDB.mySeed.getAddress() + path + fileName);
// the md5 sum of the file
prop.put("dirlist_" + fileIdx + "_dir_md5s",md5s);
// description mode: 0...image preview, 1...description text
prop.put("dirlist_" + fileIdx + "_dir_descriptionMode",showImage?0:1);
if (showImage) {
prop.put("dirlist_" + fileIdx + "_dir_descriptionMode_image",fileName);
- } else {
- prop.putSafeXML("dirlist_" + fileIdx + "_dir_descriptionMode_text",description);
- }
+ }
+ // always set the description tag (needed by rss and xml)
+ prop.putSafeXML("dirlist_" + fileIdx + "_dir_descriptionMode_text",description);
}
prop.put("dirlist_" + fileIdx + "_adminAuthorization",adminAuthorization?1:0);
diff --git a/htroot/htdocsdefault/dir.rss b/htroot/htdocsdefault/dir.rss
new file mode 100644
index 000000000..237179a02
--- /dev/null
+++ b/htroot/htdocsdefault/dir.rss
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<rss version="2.0">
+<channel>
+ <title><![CDATA[YaCy '#[clientname]#': Public Files]]></title>
+ <link>http://#[peeraddress]##[path]#</link>
+ <description><![CDATA[Directory Listing of #[path]#]]></description>
+ <image>
+ <url>http://#[peeraddress]#/env/grafics/yacy.png</url>
+ <title>YaCy</title>
+ <link>http://#[peeraddress]#/</link>
+ </image>
+ #{dirlist}#<item>
+ <title><![CDATA[#(dir)##[name]#::#[name]##(/dir)#]]></title>
+ <link>#(dir)##[URL]#::#[URL]##(/dir)#</link>
+ <pubDate>#(dir)##[rfc822date]#::#[rfc822date]##(/dir)#</pubDate>
+ #(dir)#<guid>#[md5s]#</guid>::#(/dir)#
+ #(dir)#<description><![CDATA[#(descriptionMode)##[text]#::#[text]##(/descriptionMode)#]]></description>::#(/dir)#
+ <category><![CDATA[#(dir)#File::Directory#(/dir)#]]></category>
+ </item>#{/dirlist}#
+</channel>
+</rss>
\ No newline at end of file