changeset 2:4b8aa9b0a45b

montage actually does something now
author k0s <k0scist@gmail.com>
date Fri, 25 Dec 2009 03:59:26 -0500
parents c5d30bfd032e
children 75a57e8f72d4
files montage/formatters.py montage/templates/strip.html setup.py
diffstat 3 files changed, 41 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/montage/formatters.py	Tue Dec 15 21:04:17 2009 -0500
+++ b/montage/formatters.py	Fri Dec 25 03:59:26 2009 -0500
@@ -1,11 +1,26 @@
+import mimetypes
 from decoupage.formatters import All
 
-class Montage(All):
+class Images(object):
+    """list of images"""
 
     def __init__(self, arg):
-        # XXX dummy arg
-        self.match = [ "*.jpg", "*.png", ]
-        # XXX should really filter on mimetype
+        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
 
     def __call__(self, request, data):
-        All.__call__(self, request, data)
+        data['width'] = self.width
+        data['height'] = self.height
+
+        # filter out non-images
+        _files = []
+        for f in data['files']:
+            mimetype = mimetypes.guess_type(f['name'])[0]
+            if mimetype and mimetype.split('/')[0] == 'image':
+                _files.append(f)
+        data['files'] = _files
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/montage/templates/strip.html	Fri Dec 25 03:59:26 2009 -0500
@@ -0,0 +1,18 @@
+<!DOCTYPE html
+    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+      xmlns:py="http://genshi.edgewall.org/"
+      xmlns:xi="http://www.w3.org/2001/XInclude">
+  <head>
+  </head>
+  <body>
+    <py:for each="index, image in enumerate(files)">
+      <div>
+        <img src="${image['path']}" width="${width or None}" height="${height or None}"/><br/>
+        ${image['description']}
+      </div>
+      <hr py:if="index != len(files) - 1"/>
+    </py:for>
+  </body>
+</html>
--- a/setup.py	Tue Dec 15 21:04:17 2009 -0500
+++ b/setup.py	Fri Dec 25 03:59:26 2009 -0500
@@ -1,7 +1,7 @@
 from setuptools import setup, find_packages
 import sys, os
 
-version = '0.0'
+version = '0.0.1'
 
 setup(name='montage',
       version=version,
@@ -20,7 +20,7 @@
       install_requires=[
           # -*- Extra requirements: -*-
         'decoupage',
-        'PIL'
+#        'PIL'
       ],
       dependency_links=[
         "http://dist.repoze.org/PIL-1.1.6.tar.gz",
@@ -28,6 +28,6 @@
       entry_points="""
       # -*- Entry points: -*-
       [decoupage.formatters]
-      montage = montage.formatters:Montage
+      images = montage.formatters:Images
       """,
       )