Mercurial > hg > decoupage
changeset 32:983c13e1b71f
included a links formatter; restructure index template
author | k0s <k0scist@gmail.com> |
---|---|
date | Mon, 08 Feb 2010 11:10:54 -0500 |
parents | f306089d6def |
children | e384d4569ac3 |
files | decoupage/formatters.py decoupage/templates/index.html setup.py |
diffstat | 3 files changed, 30 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/decoupage/formatters.py Sun Jan 17 19:49:04 2010 -0500 +++ b/decoupage/formatters.py Mon Feb 08 11:10:54 2010 -0500 @@ -15,7 +15,6 @@ defaults = {} # default values for attrs to be set on the instance - def __init__(self, string): args = [ i.strip() for i in string.split(',')] for index, arg in enumerate(args): @@ -37,7 +36,6 @@ class Ignore(object): """ignore files of a certain pattern""" - def __init__(self, ignore): self.match = ignore.split() @@ -62,7 +60,6 @@ def __init__(self, pattern): self.match = pattern.split() - def __call__(self, request, data): _files = [] @@ -108,7 +105,6 @@ class TitleDescription(FormatterBase): """splits a description into a title and a description with a separator""" - defaults = { 'separator': ':' } def __call__(self, request, data): @@ -121,8 +117,26 @@ f['title'] = f['description'] f['description'] = None +class Links(FormatterBase): + """ + allow list of links per item: + foo.html = description of foo; [PDF]=foo.pdf; [TXT]=foo.txt + """ + + defaults = { 'separator': ';' } + + def __call__(self, request, data): + for f in data['files']: + if f['description'] and self.separator in f['description']: + f['description'], links = f['description'].split(self.separator, 1) + links = links.split(self.separator) + assert min(['=' in link for link in links]) + links = [ link.split('=', 1) for link in links ] + f['links'] = [ { 'text': text, 'link': link } + for text, link in links ] + class CSS(object): - """specify CSS""" + """specify CSS for the page""" def __init__(self, arg): self.css = arg.split()
--- a/decoupage/templates/index.html Sun Jan 17 19:49:04 2010 -0500 +++ b/decoupage/templates/index.html Mon Feb 08 11:10:54 2010 -0500 @@ -10,10 +10,16 @@ </head> <body> <xi:include py:if="include" href="${include}"/> - <ul> + <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 href="${f['path']}"> + ${f.get('title', f['description']) or f['name']}</a><span py:if="'title' in f and f['description']">: ${f['description']} + </span> + <span py:if="'links' in f" py:for="link in f['links']" + class="link"> + <a href="link['link']">${link['text']}</a> </span> </li> </ul>
--- a/setup.py Sun Jan 17 19:49:04 2010 -0500 +++ b/setup.py Mon Feb 08 11:10:54 2010 -0500 @@ -6,7 +6,7 @@ except IOError: description = '' -version = '0.5' +version = '0.5.2' setup(name='decoupage', version=version, @@ -41,9 +41,10 @@ [decoupage.formatters] all = decoupage.formatters:All css = decoupage.formatters:CSS + describe = decoupage.formatters:FilenameDescription ignore = decoupage.formatters:Ignore include = decoupage.formatters:Include - describe = decoupage.formatters:FilenameDescription + links = decoupage.formatters:Links title = decoupage.formatters:TitleDescription sort = decoupage.formatters:Sort """,