From 4555df03d0d4410efc9bdfb93d96791627260958 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 31 Oct 2011 16:24:29 +0100 Subject: [PATCH 1/9] Slightly updated README to correctly render as reStructuredText. --- README.rst | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index c423623..b52319c 100644 --- a/README.rst +++ b/README.rst @@ -7,7 +7,7 @@ Installation ------------ 1. ``pip install django-imagekit`` - (or clone the source and put the imagekit module on your path) + (or clone the source and put the imagekit module on your path) 2. Add ``'imagekit'`` to your ``INSTALLED_APPS`` list in your project's settings.py @@ -85,7 +85,7 @@ Admin ImageKit also contains a class named ``imagekit.admin.AdminThumbnail`` for displaying specs (or even regular ImageFields) in the -`Django admin change list`__. AdminThumbnail is used as a property on +`Django admin change list`_. AdminThumbnail is used as a property on Django admin classes:: from django.contrib import admin @@ -103,6 +103,4 @@ Django admin classes:: AdminThumbnail can even use a custom template. For more information, see ``imagekit.admin.AdminThumbnail``. - -__ https://docs.djangoproject.com/en/dev/intro/tutorial02/#customize-the-admin-change-list -__ https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_display +.. _`Django admin change list`: https://docs.djangoproject.com/en/dev/intro/tutorial02/#customize-the-admin-change-list From 28f4dd01032a1ff474abce3b79398e66bbaa9249 Mon Sep 17 00:00:00 2001 From: Bryan Veloso Date: Tue, 1 Nov 2011 00:44:29 +0900 Subject: [PATCH 2/9] Develop is now v1.1.0.dev. --- imagekit/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imagekit/__init__.py b/imagekit/__init__.py index c12553b..d97fb0b 100644 --- a/imagekit/__init__.py +++ b/imagekit/__init__.py @@ -1,5 +1,5 @@ __title__ = 'django-imagekit' __author__ = 'Justin Driscoll, Bryan Veloso, Greg Newman, Chris Drackett, Matthew Tretter, Eric Eldredge' -__version__ = (1, 0, 0, 'final', 0) +__version__ = (1, 1, 0, 'dev', 0) __build__ = 0x001000 __license__ = 'BSD' From a2296a382b3d93b12ae10df5c1fbb7fad5745c87 Mon Sep 17 00:00:00 2001 From: Bryan Veloso Date: Tue, 1 Nov 2011 01:30:59 +0900 Subject: [PATCH 3/9] Including README.rst and the docs in MANIFEST.in. Fixes #40. --- MANIFEST.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MANIFEST.in b/MANIFEST.in index 27e27bd..2a86e0d 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,4 @@ include AUTHORS include LICENSE +include README.rst +recursive-include docs * From 4b86e37f93122df5b3ea0619fbc0f83e5380551d Mon Sep 17 00:00:00 2001 From: Bryan Veloso Date: Tue, 1 Nov 2011 01:54:31 +0900 Subject: [PATCH 4/9] No longer an alpha. --- docs/conf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index a751d2c..dcaf826 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -48,9 +48,9 @@ copyright = u'2011, Justin Driscoll, Bryan Veloso, Greg Newman, Chris Drackett & # built documents. # # The short X.Y version. -version = '1.0alpha' +version = '1.0' # The full version, including alpha/beta/rc tags. -release = '1.0alpha' +release = '1.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. From 892cce7c7f0c5a5d1a579179b6c5053f7efa4619 Mon Sep 17 00:00:00 2001 From: Matthew Tretter Date: Tue, 1 Nov 2011 18:54:18 -0400 Subject: [PATCH 5/9] Fixes extension guessing based on image format IK relies on PIL's EXTENSION list to map formats to extensions. However, this list normally isn't populated until an image is loaded. This change forces the population of the list before examining it. --- imagekit/models.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/imagekit/models.py b/imagekit/models.py index 815a972..03b2e64 100755 --- a/imagekit/models.py +++ b/imagekit/models.py @@ -95,10 +95,15 @@ class ImageSpec(_ImageSpecMixin): dispatch_uid='%s.delete' % uid) +def get_registered_extensions(): + Image.preinit() + return Image.EXTENSION + + def _get_suggested_extension(name, format): if format: # Try to look up an extension by the format. - extensions = [k for k, v in Image.EXTENSION.iteritems() \ + extensions = [k for k, v in get_registered_extensions().iteritems() \ if v == format.upper()] else: extensions = [] @@ -124,7 +129,7 @@ class _ImageSpecFileMixin(object): # The extension is explicit, so assume they want the matching format. extension = os.path.splitext(filename)[1].lower() # Try to guess the format from the extension. - format = Image.EXTENSION.get(extension) + format = get_registered_extensions().get(extension) format = format or img.format or original_format or 'JPEG' if format != 'JPEG': From 8885325bfc98a2771d45bff3551238e40d754c83 Mon Sep 17 00:00:00 2001 From: Matthew Tretter Date: Tue, 1 Nov 2011 19:39:54 -0400 Subject: [PATCH 6/9] Generated filename is cached --- imagekit/models.py | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/imagekit/models.py b/imagekit/models.py index 03b2e64..435d58b 100755 --- a/imagekit/models.py +++ b/imagekit/models.py @@ -242,22 +242,26 @@ class ImageSpecFile(_ImageSpecFileMixin, ImageFieldFile): control this by providing a `cache_to` method to the ImageSpec. """ - filename = self.source_file.name - if filename: - cache_to = self.field.cache_to or self._default_cache_to + name = getattr(self, '_name', None) + if not name: + filename = self.source_file.name + new_filename = None + if filename: + cache_to = self.field.cache_to or self._default_cache_to - if not cache_to: - raise Exception('No cache_to or default_cache_to value specified') - if callable(cache_to): - new_filename = force_unicode(datetime.datetime.now().strftime( \ - smart_str(cache_to(self.instance, self.source_file.name, - self.attname, self._suggested_extension)))) - else: - dir_name = os.path.normpath(force_unicode(datetime.datetime.now().strftime(smart_str(cache_to)))) - filename = os.path.normpath(os.path.basename(filename)) - new_filename = os.path.join(dir_name, filename) + if not cache_to: + raise Exception('No cache_to or default_cache_to value specified') + if callable(cache_to): + new_filename = force_unicode(datetime.datetime.now().strftime( \ + smart_str(cache_to(self.instance, self.source_file.name, + self.attname, self._suggested_extension)))) + else: + dir_name = os.path.normpath(force_unicode(datetime.datetime.now().strftime(smart_str(cache_to)))) + filename = os.path.normpath(os.path.basename(filename)) + new_filename = os.path.join(dir_name, filename) - return new_filename + self._name = new_filename + return self._name @name.setter def name(self, value): From 023f8592d74bfe268a1c31b7ca1a4150a89a5de4 Mon Sep 17 00:00:00 2001 From: Bryan Veloso Date: Wed, 2 Nov 2011 13:40:51 +0900 Subject: [PATCH 7/9] Making sure the templates make it via pip. Fixes #39. --- MANIFEST.in | 1 + setup.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/MANIFEST.in b/MANIFEST.in index 2a86e0d..0adbc50 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,3 +2,4 @@ include AUTHORS include LICENSE include README.rst recursive-include docs * +recursive-include imagekit/templates * diff --git a/setup.py b/setup.py index 579d7ee..46aef9a 100644 --- a/setup.py +++ b/setup.py @@ -23,6 +23,8 @@ setup( license='BSD', url='http://github.com/jdriscoll/django-imagekit/', packages=find_packages(), + zip_safe=False, + include_package_data=True, classifiers=[ 'Development Status :: 4 - Beta', 'Environment :: Web Environment', From 2e27e8283217af3713a55ae6bc51b8d0353aa036 Mon Sep 17 00:00:00 2001 From: Bryan Veloso Date: Wed, 2 Nov 2011 13:45:10 +0900 Subject: [PATCH 8/9] Bumping version to 1.0.1. --- imagekit/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/imagekit/__init__.py b/imagekit/__init__.py index d97fb0b..93b5287 100644 --- a/imagekit/__init__.py +++ b/imagekit/__init__.py @@ -1,5 +1,4 @@ __title__ = 'django-imagekit' __author__ = 'Justin Driscoll, Bryan Veloso, Greg Newman, Chris Drackett, Matthew Tretter, Eric Eldredge' -__version__ = (1, 1, 0, 'dev', 0) -__build__ = 0x001000 +__version__ = (1, 0, 1, 'final', 0) __license__ = 'BSD' From 3985629b9ae0d5803a3e83f609505dd70c93139d Mon Sep 17 00:00:00 2001 From: Bryan Veloso Date: Wed, 2 Nov 2011 13:46:23 +0900 Subject: [PATCH 9/9] Bumping docs to 1.0.1. --- docs/conf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index dcaf826..4005268 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -48,9 +48,9 @@ copyright = u'2011, Justin Driscoll, Bryan Veloso, Greg Newman, Chris Drackett & # built documents. # # The short X.Y version. -version = '1.0' +version = '1.0.1' # The full version, including alpha/beta/rc tags. -release = '1.0' +release = '1.0.1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages.