# HG changeset patch # User k0s # Date 1265645454 18000 # Node ID 983c13e1b71f00df2ce509af9f63b75891d1b670 # Parent f306089d6def5bf9d751f07e74654ec1b22971de included a links formatter; restructure index template diff -r f306089d6def -r 983c13e1b71f decoupage/formatters.py --- 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() diff -r f306089d6def -r 983c13e1b71f decoupage/templates/index.html --- 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 @@ -