Mercurial > hg > decoupage
diff decoupage/formatters.py @ 70:262fb90a54b4
make template loading lenient and other fixes; bump version
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sat, 04 Aug 2012 15:55:52 -0700 |
parents | 4094bee13154 |
children | ebf3d3c39cb7 |
line wrap: on
line diff
--- a/decoupage/formatters.py Fri Aug 03 23:48:25 2012 -0700 +++ b/decoupage/formatters.py Sat Aug 04 15:55:52 2012 -0700 @@ -17,6 +17,7 @@ defaults = {} # default values for attrs to be set on the instance def __init__(self, string): + self._string = string args = [ i.strip() for i in string.split(',')] for index, arg in enumerate(args): if '=' in arg: @@ -174,6 +175,18 @@ defaults = { 'separator': ':' } def __call__(self, request, data): + + # title webpage + title = self._string + if ':' in title: + _title, url = [i.strip() for i in title.split(':', 1)] + if '://' in url: + # XXX could also use urlparse + title = _title + data['link'] = url + data['title'] = title + + # title files for f in data['files']: if f['description'] and self.separator in f['description']: title, description = f['description'].split(self.separator, 1)