From 777e39cea0ef9215f11c43b7423f5403afd126cb Mon Sep 17 00:00:00 2001 From: theli Date: Tue, 24 Oct 2006 12:13:46 +0000 Subject: [PATCH] *) 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 --- htroot/htdocsdefault/dir.java | 12 +++++++----- htroot/htdocsdefault/dir.xml | 20 ++++++++++++++++++++ source/de/anomic/http/httpdFileHandler.java | 7 ++++--- 3 files changed, 31 insertions(+), 8 deletions(-) create mode 100644 htroot/htdocsdefault/dir.xml diff --git a/htroot/htdocsdefault/dir.java b/htroot/htdocsdefault/dir.java index 3a64ea1b6..a4db30398 100644 --- a/htroot/htdocsdefault/dir.java +++ b/htroot/htdocsdefault/dir.java @@ -238,7 +238,7 @@ public class dir { // tree += "path = " + path + "

"; 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(" ", " ")); + 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); } } diff --git a/htroot/htdocsdefault/dir.xml b/htroot/htdocsdefault/dir.xml new file mode 100644 index 000000000..4615afd84 --- /dev/null +++ b/htroot/htdocsdefault/dir.xml @@ -0,0 +1,20 @@ + + +#{dirlist}# + #(dir)# + + #[name]# + #[date]# + #[size]# + #[md5s]# + #(descriptionMode)##[text]#::#[text]##(/descriptionMode)# + #[yacyhURL]# + + :: + + #[name]# + #[date]# + + #(/dir)# +#{/dirlist}# + \ No newline at end of file diff --git a/source/de/anomic/http/httpdFileHandler.java b/source/de/anomic/http/httpdFileHandler.java index d74c6d4c6..8a3198d89 100644 --- a/source/de/anomic/http/httpdFileHandler.java +++ b/source/de/anomic/http/httpdFileHandler.java @@ -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{