# HG changeset patch # User Jeff Hammel # Date 1373049179 25200 # Node ID a8a74f6bcf9333e7ee45f821f0d64a205722fd7f # Parent 5330cd62e17958f388ccf49cdac1e35315e7125b add some dates and fix some bugs! diff -r 5330cd62e179 -r a8a74f6bcf93 decoupage/formatters.py --- a/decoupage/formatters.py Tue Apr 16 00:45:31 2013 -0700 +++ b/decoupage/formatters.py Fri Jul 05 11:32:59 2013 -0700 @@ -2,6 +2,7 @@ import random import sys +from datetime import datetime from fnmatch import fnmatch from pkg_resources import iter_entry_points @@ -76,11 +77,12 @@ _files.append(f) break else: - # use only files where the description is not None - if f['description'] is not None: + # use only files where the title or description is not None + if (f['description'] is not None) or (f.get('title') is not None): _files.append(f) data['files'] = _files + class Sort(FormatterBase): """ determines how to sort the files in a directory; @@ -200,6 +202,31 @@ f['title'] = f['description'] f['description'] = None +class Datestamp(FormatterBase): + """ + datestamps for modified times + """ + # TODO: + # - currently we only do modified; TODO: created/modified/etc + # - use modified dateutil from bitsyblog; + # - e.g. javascript for things like e.g. "Yesterday" + key = 'modified' + + def __init__(self, string): + FormatterBase.__init__(self, string) + + # check formatting string now v later + datetime.now().strftime(self._string) + + def __call__(self, request, data): + for f in data['files']: + _datetime = f.get(self.key) + try: + datestamp = _datetime.strftime(self._string) + f['datestamp'] = datestamp + except: + raise # TODO: handle more better + class Links(FormatterBase): """ allow list of links per item: @@ -207,7 +234,7 @@ """ fatal = False - defaults = { 'separator': ';' } + defaults = {'separator': ';'} def __call__(self, request, data): @@ -285,6 +312,7 @@ def __call__(self, request, data): data['include'] = self.include +### def formatters(): formatters = {} diff -r 5330cd62e179 -r a8a74f6bcf93 decoupage/templates/index.html --- a/decoupage/templates/index.html Tue Apr 16 00:45:31 2013 -0700 +++ b/decoupage/templates/index.html Fri Jul 05 11:32:59 2013 -0700 @@ -22,6 +22,7 @@ ${link['text']} + diff -r 5330cd62e179 -r a8a74f6bcf93 setup.py --- a/setup.py Tue Apr 16 00:45:31 2013 -0700 +++ b/setup.py Fri Jul 05 11:32:59 2013 -0700 @@ -6,7 +6,7 @@ except IOError: description = '' -version = '0.11.2' +version = '0.12' setup(name='decoupage', version=version, @@ -47,6 +47,7 @@ [decoupage.formatters] all = decoupage.formatters:All css = decoupage.formatters:CSS + datestamp = decoupage.formatters:Datestamp describe = decoupage.formatters:FilenameDescription icon = decoupage.formatters:Favicon ignore = decoupage.formatters:Ignore