# HG changeset patch # User Steve Losh # Date 1234629574 18000 # Node ID 1f2356294a8e10adb60eae1e0b8d9c87bd6e5787 # Parent 315df6ca542d0640c10a9584453152cafea0dacf Started the photoblog app. diff -r 315df6ca542d -r 1f2356294a8e photoblog/__init__.py diff -r 315df6ca542d -r 1f2356294a8e photoblog/admin.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/photoblog/admin.py Sat Feb 14 11:39:34 2009 -0500 @@ -0,0 +1,17 @@ +from stevelosh.photoblog.models import Entry +from django.contrib import admin + +class EntryAdmin(admin.ModelAdmin): + fieldsets = [ + ('Entry', { 'fields': ['title', 'original_image', 'body'] }), + ('Publishing', { 'fields': ['pub_date', 'published'] }), + ('Advanced', { 'fields': ['slug'] }), + ] + save_on_top = True + list_display = ('title', 'snippet', 'num_views', 'pub_date', 'published',) + list_filter = ('published',) + date_hierarchy = 'pub_date' + ordering = ('-pub_date',) + prepopulated_fields = { 'slug': ('title',) } + +admin.site.register(Entry, EntryAdmin) diff -r 315df6ca542d -r 1f2356294a8e photoblog/models.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/photoblog/models.py Sat Feb 14 11:39:34 2009 -0500 @@ -0,0 +1,22 @@ +from django.db import models +from imagekit.models import ImageModel +import datetime + +class Entry(ImageModel): + title = models.CharField(max_length=300) + slug = models.SlugField() + pub_date = models.DateField(default=datetime.datetime.today) + body = models.TextField(blank=True) + original_image = models.ImageField(upload_to="storage/photoblog/original") + num_views = models.PositiveIntegerField(editable=False, default=0) + published = models.BooleanField(default=True) + + def snippet(self): + return self.body[:50] + ('...' if len(self.body) > 50 else '') + + class IKOptions: + spec_module = 'photoblog.specs' + cache_dir = 'storage/photoblog/cache' + image_field = 'original_image' + save_count_as = 'num_views' + diff -r 315df6ca542d -r 1f2356294a8e photoblog/specs.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/photoblog/specs.py Sat Feb 14 11:39:34 2009 -0500 @@ -0,0 +1,22 @@ +from imagekit.specs import ImageSpec +from imagekit import processors + +class ResizeThumb(processors.Resize): + width = 100 + height = 100 + +class ResizeDisplay(processors.Resize): + width = 550 + +class EnchanceThumb(processors.Adjustment): + contrast = 1.2 + sharpness = 1.1 + +class Thumbnail(ImageSpec): + access_as = 'thumbnail' + pre_cache = True + processors = [ResizeThumb, EnchanceThumb] + +class Display(ImageSpec): + increment_count = True + processors = [ResizeDisplay] diff -r 315df6ca542d -r 1f2356294a8e photoblog/views.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/photoblog/views.py Sat Feb 14 11:39:34 2009 -0500 @@ -0,0 +1,1 @@ +# Create your views here. diff -r 315df6ca542d -r 1f2356294a8e settings.py --- a/settings.py Fri Feb 13 20:40:27 2009 -0500 +++ b/settings.py Sat Feb 14 11:39:34 2009 -0500 @@ -90,6 +90,8 @@ 'stevelosh.blog', 'stevelosh.projects', 'stevelosh.thoughts', + 'stevelosh.photoblog', 'mobileadmin', 'typogrify', + 'imagekit', )