changeset 55:47acf12d01e1

merge commit
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 18 Nov 2010 08:19:06 -0800
parents 0e2b9e0507c5 (current diff) a2f09d749a3f (diff)
children 0cc1af24602b
files decoupage/formats.py
diffstat 2 files changed, 17 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/decoupage/formats.py	Thu Nov 18 08:18:49 2010 -0800
+++ b/decoupage/formats.py	Thu Nov 18 08:19:06 2010 -0800
@@ -12,7 +12,8 @@
 
   # fix datetime
   for f in data['files']:
-    f['modified'] = f['modified'].ctime()
+    if 'modified' in f:
+      f['modified'] = f['modified'].ctime()
 
   return 'application/json', json.dumps(data['files'])
   
--- a/decoupage/web.py	Thu Nov 18 08:18:49 2010 -0800
+++ b/decoupage/web.py	Thu Nov 18 08:19:06 2010 -0800
@@ -133,6 +133,7 @@
         conf = self.conf(path)
 
         ### build data dictionary
+        # TODO: separate these out into several formatters
         files = self.filedata(path, directory, conf)
         data = {'path': path, 'files': files, 'request': request }
 
@@ -208,10 +209,11 @@
 
     ### internal methods
 
-    def filedata(self, path, directory, conf):
+    def filedata(self, path, directory, conf=None):
+        conf = conf or {}
         files = []
-
-        for i in os.listdir(directory):
+        filenames = os.listdir(directory)
+        for i in filenames:
             filepath = os.path.join(directory, i)
             filetype = 'file'
             if os.path.isdir(filepath):
@@ -222,10 +224,19 @@
                           'name': i,
                           'size': os.path.getsize(filepath),
                           'modified': modified,
-                          'description': conf.get(i.lower(), None),
                           'type': filetype})
         
         # TODO: deal with other links in conf
+        for i in conf:
+            if i in filenames or i.startswith('/'):
+                continue
+            if i.startswith('http://') or i.startswith('https://'):
+                files.append({'path': i,
+                              'name': i,
+                              'type': link})
+            
+        for f in files:
+            f['description'] = conf.get(f['name'].lower(), None)
 
         return files