mirror of
https://github.com/Hopiu/django-imagekit.git
synced 2026-05-25 04:33:44 +00:00
Merge branch 'release/1.0.1'
* release/1.0.1: Bumping docs to 1.0.1. Bumping version to 1.0.1. Making sure the templates make it via pip. Fixes #39. Generated filename is cached Fixes extension guessing based on image format No longer an alpha. Including README.rst and the docs in MANIFEST.in. Fixes #40. Develop is now v1.1.0.dev. Slightly updated README to correctly render as reStructuredText.
This commit is contained in:
commit
d9a7640d56
6 changed files with 36 additions and 25 deletions
|
|
@ -1,2 +1,5 @@
|
||||||
include AUTHORS
|
include AUTHORS
|
||||||
include LICENSE
|
include LICENSE
|
||||||
|
include README.rst
|
||||||
|
recursive-include docs *
|
||||||
|
recursive-include imagekit/templates *
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ Installation
|
||||||
------------
|
------------
|
||||||
|
|
||||||
1. ``pip install django-imagekit``
|
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
|
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``
|
ImageKit also contains a class named ``imagekit.admin.AdminThumbnail``
|
||||||
for displaying specs (or even regular ImageFields) in the
|
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::
|
Django admin classes::
|
||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
@ -103,6 +103,4 @@ Django admin classes::
|
||||||
AdminThumbnail can even use a custom template. For more information, see
|
AdminThumbnail can even use a custom template. For more information, see
|
||||||
``imagekit.admin.AdminThumbnail``.
|
``imagekit.admin.AdminThumbnail``.
|
||||||
|
|
||||||
|
.. _`Django admin change list`: https://docs.djangoproject.com/en/dev/intro/tutorial02/#customize-the-admin-change-list
|
||||||
__ 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
|
|
||||||
|
|
|
||||||
|
|
@ -48,9 +48,9 @@ copyright = u'2011, Justin Driscoll, Bryan Veloso, Greg Newman, Chris Drackett &
|
||||||
# built documents.
|
# built documents.
|
||||||
#
|
#
|
||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
version = '1.0alpha'
|
version = '1.0.1'
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = '1.0alpha'
|
release = '1.0.1'
|
||||||
|
|
||||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||||
# for a list of supported languages.
|
# for a list of supported languages.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
__title__ = 'django-imagekit'
|
__title__ = 'django-imagekit'
|
||||||
__author__ = 'Justin Driscoll, Bryan Veloso, Greg Newman, Chris Drackett, Matthew Tretter, Eric Eldredge'
|
__author__ = 'Justin Driscoll, Bryan Veloso, Greg Newman, Chris Drackett, Matthew Tretter, Eric Eldredge'
|
||||||
__version__ = (1, 0, 0, 'final', 0)
|
__version__ = (1, 0, 1, 'final', 0)
|
||||||
__build__ = 0x001000
|
|
||||||
__license__ = 'BSD'
|
__license__ = 'BSD'
|
||||||
|
|
|
||||||
|
|
@ -95,10 +95,15 @@ class ImageSpec(_ImageSpecMixin):
|
||||||
dispatch_uid='%s.delete' % uid)
|
dispatch_uid='%s.delete' % uid)
|
||||||
|
|
||||||
|
|
||||||
|
def get_registered_extensions():
|
||||||
|
Image.preinit()
|
||||||
|
return Image.EXTENSION
|
||||||
|
|
||||||
|
|
||||||
def _get_suggested_extension(name, format):
|
def _get_suggested_extension(name, format):
|
||||||
if format:
|
if format:
|
||||||
# Try to look up an extension by the 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()]
|
if v == format.upper()]
|
||||||
else:
|
else:
|
||||||
extensions = []
|
extensions = []
|
||||||
|
|
@ -124,7 +129,7 @@ class _ImageSpecFileMixin(object):
|
||||||
# The extension is explicit, so assume they want the matching format.
|
# The extension is explicit, so assume they want the matching format.
|
||||||
extension = os.path.splitext(filename)[1].lower()
|
extension = os.path.splitext(filename)[1].lower()
|
||||||
# Try to guess the format from the extension.
|
# 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'
|
format = format or img.format or original_format or 'JPEG'
|
||||||
|
|
||||||
if format != 'JPEG':
|
if format != 'JPEG':
|
||||||
|
|
@ -237,22 +242,26 @@ class ImageSpecFile(_ImageSpecFileMixin, ImageFieldFile):
|
||||||
control this by providing a `cache_to` method to the ImageSpec.
|
control this by providing a `cache_to` method to the ImageSpec.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
filename = self.source_file.name
|
name = getattr(self, '_name', None)
|
||||||
if filename:
|
if not name:
|
||||||
cache_to = self.field.cache_to or self._default_cache_to
|
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:
|
if not cache_to:
|
||||||
raise Exception('No cache_to or default_cache_to value specified')
|
raise Exception('No cache_to or default_cache_to value specified')
|
||||||
if callable(cache_to):
|
if callable(cache_to):
|
||||||
new_filename = force_unicode(datetime.datetime.now().strftime( \
|
new_filename = force_unicode(datetime.datetime.now().strftime( \
|
||||||
smart_str(cache_to(self.instance, self.source_file.name,
|
smart_str(cache_to(self.instance, self.source_file.name,
|
||||||
self.attname, self._suggested_extension))))
|
self.attname, self._suggested_extension))))
|
||||||
else:
|
else:
|
||||||
dir_name = os.path.normpath(force_unicode(datetime.datetime.now().strftime(smart_str(cache_to))))
|
dir_name = os.path.normpath(force_unicode(datetime.datetime.now().strftime(smart_str(cache_to))))
|
||||||
filename = os.path.normpath(os.path.basename(filename))
|
filename = os.path.normpath(os.path.basename(filename))
|
||||||
new_filename = os.path.join(dir_name, filename)
|
new_filename = os.path.join(dir_name, filename)
|
||||||
|
|
||||||
return new_filename
|
self._name = new_filename
|
||||||
|
return self._name
|
||||||
|
|
||||||
@name.setter
|
@name.setter
|
||||||
def name(self, value):
|
def name(self, value):
|
||||||
|
|
|
||||||
2
setup.py
2
setup.py
|
|
@ -23,6 +23,8 @@ setup(
|
||||||
license='BSD',
|
license='BSD',
|
||||||
url='http://github.com/jdriscoll/django-imagekit/',
|
url='http://github.com/jdriscoll/django-imagekit/',
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
|
zip_safe=False,
|
||||||
|
include_package_data=True,
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'Development Status :: 4 - Beta',
|
'Development Status :: 4 - Beta',
|
||||||
'Environment :: Web Environment',
|
'Environment :: Web Environment',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue