*) new template to display the dir-listing in xml format.

This can e.g. be done by using the url http://localhost:8080/share/?format=xml

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2856 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
theli 18 years ago
parent 9e8942a064
commit 777e39cea0

@ -238,7 +238,7 @@ public class dir {
// tree += "<span class=\"tt\">path&nbsp;=&nbsp;" + path + "</span><br><br>";
if (list != null) {
int filecount = 0, fileIdx = 0;
prop.put("path", path);
prop.putNoHTML("path", path);
boolean dark = false;
for (int i = 0; i < list.length; i++) {
@ -280,8 +280,9 @@ 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_timestamp" , Long.toString(f.lastModified()));
// the entry name
prop.put("dirlist_" + fileIdx + "_dir_name" , fileName);
prop.putNoHTML("dirlist_" + fileIdx + "_dir_name" , fileName);
if (f.isDirectory()) {
// the entry is a directory
@ -293,9 +294,10 @@ public class dir {
// the entry is a file
prop.put("dirlist_" + fileIdx + "_dir" , 0);
// the file size
prop.put("dirlist_" + fileIdx + "_dir_size" , serverMemory.bytesToString(f.length()).replaceAll(" ", "&nbsp;"));
prop.put("dirlist_" + fileIdx + "_dir_size" , serverMemory.bytesToString(f.length()));
prop.put("dirlist_" + fileIdx + "_dir_sizeBytes" , Long.toString(f.length()));
// the unique url
prop.put("dirlist_" + fileIdx + "_dir_yacyhURL",yacyhURL(yacyCore.seedDB.mySeed, fileName, md5s));
prop.putNoHTML("dirlist_" + fileIdx + "_dir_yacyhURL",yacyhURL(yacyCore.seedDB.mySeed, fileName, md5s));
// the md5 sum of the file
prop.put("dirlist_" + fileIdx + "_dir_md5s",md5s);
// description mode: 0...image preview, 1...description text
@ -303,7 +305,7 @@ public class dir {
if (showImage) {
prop.put("dirlist_" + fileIdx + "_dir_descriptionMode_image",fileName);
} else {
prop.put("dirlist_" + fileIdx + "_dir_descriptionMode_text",description);
prop.putNoHTML("dirlist_" + fileIdx + "_dir_descriptionMode_text",description);
}
}

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<share path="#[path]#">
#{dirlist}#
#(dir)#
<file>
<name>#[name]#</name>
<date timestamp="#[timestamp]#">#[date]#</date>
<size bytes="#[sizeBytes]#">#[size]#</size>
<md5>#[md5s]#</md5>
<comment>#(descriptionMode)##[text]#::#[text]##(/descriptionMode)#</comment>
<yacyURL>#[yacyhURL]#</yacyURL>
</file>
::
<directory>
<name>#[name]#</name>
<date timestamp="#[timestamp]#">#[date]#</date>
</directory>
#(/dir)#
#{/dirlist}#
</share>

@ -460,10 +460,11 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http
}
//no defaultfile, send a dirlisting
if(targetFile == null || !targetFile.exists()){
targetFile = getOverlayedFile("/htdocsdefault/dir.html");
targetClass=getOverlayedClass("/htdocsdefault/dir.html");
String dirlistFormat = (args==null)?"html":args.get("format","html");
targetFile = getOverlayedFile("/htdocsdefault/dir." + dirlistFormat);
targetClass=getOverlayedClass("/htdocsdefault/dir." + dirlistFormat);
if(! (( targetFile != null && targetFile.exists()) && ( targetClass != null && targetClass.exists())) ){
httpd.sendRespondError(this.connectionProperties,out,3,500,"dir.html or dir.class not found.",null,null);
httpd.sendRespondError(this.connectionProperties,out,3,500,"dir." + dirlistFormat + " or dir.class not found.",null,null);
}
}
}else{

Loading…
Cancel
Save