# HG changeset patch # User k0s # Date 1261779721 18000 # Node ID d60a5ffbf4f42e4a603716596c818b55e2581968 # Parent 75b19560f517a89ef7f01265c53d69b07c8a66bd * include a new template to display images in a grid * refactor Images formatter * stub for thumbnails diff -r 75b19560f517 -r d60a5ffbf4f4 montage/formatters.py --- a/montage/formatters.py Fri Dec 25 04:21:30 2009 -0500 +++ b/montage/formatters.py Fri Dec 25 17:22:01 2009 -0500 @@ -1,18 +1,23 @@ import mimetypes -from decoupage.formatters import All +from decoupage.formatters import FormatterBase -class Images(object): - """list of images""" +class Images(FormatterBase): + """display images with thumbnails""" + + defaults = { 'size': 'x', + 'columns': None } def __init__(self, arg): - if 'x' in arg: - width, height = [ i.strip() for i in arg.split('x', 1) ] - self.width = width or None - self.height = height or None - else: - self.width = self.height = None + FormatterBase.__init__(self, arg) + # get image size for display + width, height = [ i.strip() for i in self.size.split('x', 1) ] + self.width = width or None + self.height = height or None + def __call__(self, request, data): + + # add width + height data data['width'] = self.width data['height'] = self.height @@ -22,5 +27,18 @@ mimetype = mimetypes.guess_type(f['name'])[0] if mimetype and mimetype.split('/')[0] == 'image': _files.append(f) + f['link'] = f['path'] data['files'] = _files + + # columns for grid display + if self.columns is None: + data['columns'] = len(data['files']) + else: + data['columns'] = int(self.columns) + # thumbnails + if 'thumbnails' not in self.args: + return + for f in data['files']: + raise NotImplementedError + import pdb; pdb.set_trace() diff -r 75b19560f517 -r d60a5ffbf4f4 montage/templates/grid.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/montage/templates/grid.html Fri Dec 25 17:22:01 2009 -0500 @@ -0,0 +1,32 @@ + + + + ${title or path} + + +
+ + + + + + + +
+
+
+ ${image.get('title', image['description'])} +
+
+
+
+ ${image.get('title', image['description'])} +
+
+
+ + diff -r 75b19560f517 -r d60a5ffbf4f4 montage/templates/strip.html --- a/montage/templates/strip.html Fri Dec 25 04:21:30 2009 -0500 +++ b/montage/templates/strip.html Fri Dec 25 17:22:01 2009 -0500 @@ -10,7 +10,10 @@
-
+ + + +
${image.get('title', image['description'])}