changeset 35:20e3d138dc98

better way of doing up; this breaks old behaviour so incrementing version
author k0s <k0scist@gmail.com>
date Mon, 08 Feb 2010 19:21:30 -0500
parents 527ccb76d043
children 9ba237db4cde
files decoupage/formatters.py decoupage/templates/index.html decoupage/web.py example.ini setup.py
diffstat 5 files changed, 30 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/decoupage/formatters.py	Mon Feb 08 11:44:20 2010 -0500
+++ b/decoupage/formatters.py	Mon Feb 08 19:21:30 2010 -0500
@@ -156,6 +156,23 @@
                 f['links'] = [ { 'text': text, 'link': link }
                              for text, link in links ]
 
+
+class Up(object):
+    """
+    provides an up link to the path above:
+    /up = ..
+    """
+
+    def __init__(self, arg):
+        self.up = arg.strip()
+    
+    def __call__(self, request, data):
+        path = request.path_info
+        if (path != '/') and self.up:
+            data['files'].insert(0, {'path': '..',
+                                     'name': path.rsplit('/', 1)[0] + '/',
+                                     'description': self.up})
+
 class CSS(object):
     """specify CSS used (whitespace separated list)"""
 
--- a/decoupage/templates/index.html	Mon Feb 08 11:44:20 2010 -0500
+++ b/decoupage/templates/index.html	Mon Feb 08 19:21:30 2010 -0500
@@ -15,7 +15,6 @@
     <xi:include py:if="include" href="${include}"/>
     <h1 py:if="title">${title}</h1>
     <ul id="listing">
-      <li py:if="request.path_info.strip('/')"><a href="..">..</a></li>
       <li py:for="f in files">
         <a href="${f['path']}">
         ${f.get('title', f['description']) or f['name']}</a><span py:if="'title' in f and f['description']">: ${f['description']}
--- a/decoupage/web.py	Mon Feb 08 11:44:20 2010 -0500
+++ b/decoupage/web.py	Mon Feb 08 19:21:30 2010 -0500
@@ -169,10 +169,19 @@
 
     def filedata(self, path, directory, conf):
         files = []
+
+        # TODO: other items to add
+        # type: 'file' or 'directory'
+        # last_modified
+        # created
+
         for i in os.listdir(directory):
             files.append({'path' : '%s/%s' % (path.rstrip('/'), i),
                           'name': i,
                           'description': conf.get(i.lower(), None)})
+        
+        # TODO: deal with other links in conf
+
         return files
 
     def conf(self, path, cascade=None):
--- a/example.ini	Mon Feb 08 11:44:20 2010 -0500
+++ b/example.ini	Mon Feb 08 19:21:30 2010 -0500
@@ -1,7 +1,9 @@
 [/]
 /ignore = .*
+/up = ..
 foo.txt = a file about cats
 
 [/cats]
+/up = ..
 lilly.txt = lilly
 hobbes.txt = a file about Hobbes
\ No newline at end of file
--- a/setup.py	Mon Feb 08 11:44:20 2010 -0500
+++ b/setup.py	Mon Feb 08 19:21:30 2010 -0500
@@ -6,7 +6,7 @@
 except IOError:
     description = ''
 
-version = '0.6'
+version = '0.7'
 
 setup(name='decoupage',
       version=version,
@@ -49,6 +49,7 @@
       scripts = decoupage.formatter:JavaScript
       sort = decoupage.formatters:Sort
       title = decoupage.formatters:TitleDescription
+      up = decoupage.formatters:Up
       """,
       )