# HG changeset patch # User Steve Losh # Date 1234633179 18000 # Node ID 444fa384fab87c9729db32a6521c9846efee2a1c # Parent a8bf2eea85f7da739ec91d99fe87bc6688995e33 Got a working photoblog (almost). diff -r a8bf2eea85f7 -r 444fa384fab8 photoblog/models.py --- a/photoblog/models.py Sat Feb 14 11:46:36 2009 -0500 +++ b/photoblog/models.py Sat Feb 14 12:39:39 2009 -0500 @@ -11,6 +11,11 @@ num_views = models.PositiveIntegerField(editable=False, default=0) published = models.BooleanField(default=True) + @models.permalink + def get_absolute_url(self): + return ('photoblog-entry', (self.pub_date.year, self.pub_date.month, + self.pub_date.day, self.slug),) + def snippet(self): return self.body[:50] + ('...' if len(self.body) > 50 else '') diff -r a8bf2eea85f7 -r 444fa384fab8 photoblog/specs.py --- a/photoblog/specs.py Sat Feb 14 11:46:36 2009 -0500 +++ b/photoblog/specs.py Sat Feb 14 12:39:39 2009 -0500 @@ -1,9 +1,8 @@ from imagekit.specs import ImageSpec from imagekit import processors -class ResizeThumb(processors.Resize): - width = 100 - height = 100 +class ResizeThumb(processors.Resize): + height = 50 class ResizeDisplay(processors.Resize): width = 550 diff -r a8bf2eea85f7 -r 444fa384fab8 photoblog/urls.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/photoblog/urls.py Sat Feb 14 12:39:39 2009 -0500 @@ -0,0 +1,6 @@ +from django.conf.urls.defaults import * + +urlpatterns = patterns('stevelosh.photoblog.views', + url(r'^$', 'entry', name='photoblog-newest'), + url(r'^entry/(\d+)/(\d+)/(\d+)/(.*)/$', 'entry', name='photoblog-entry'), +) diff -r a8bf2eea85f7 -r 444fa384fab8 photoblog/views.py --- a/photoblog/views.py Sat Feb 14 11:46:36 2009 -0500 +++ b/photoblog/views.py Sat Feb 14 12:39:39 2009 -0500 @@ -1,1 +1,11 @@ -# Create your views here. +from stevelosh.photoblog.models import Entry +from django.shortcuts import get_object_or_404, render_to_response + +def entry(request, year=None, month=None, day=None, slug=None): + if year == None and month == None and day == None and slug == None: + entry = Entry.objects.all().order_by('-pub_date')[0] + else: + entry = get_object_or_404(Entry, slug=slug, pub_date__year=year, + pub_date__month=month, pub_date__day=day,) + + return render_to_response('photoblog/entry.html', { 'entry': entry }) \ No newline at end of file diff -r a8bf2eea85f7 -r 444fa384fab8 site-media/style/photoblog.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/site-media/style/photoblog.css Sat Feb 14 12:39:39 2009 -0500 @@ -0,0 +1,7 @@ +img#photoblog-main-image { border: 15px solid #eee; margin: 1em auto 2em; display: block; } +div#photoblog-entry-date { color: #666; } +div.photoblog-nav-entry { border-bottom: 1px solid #eee; height: 54px; vertical-align: middle; } +div.photoblog-nav-entry h2, div.photoblog-nav-entry h3 { line-height: 54px; display: inline; } +div.photoblog-nav-entry img { float: right; margin: 2px 0px; } +div#photoblog-nav-older { width: 48%; } +div#photoblog-nav-newer { width: 48%; float: right; } \ No newline at end of file diff -r a8bf2eea85f7 -r 444fa384fab8 site-media/style/stevelosh.css --- a/site-media/style/stevelosh.css Sat Feb 14 11:46:36 2009 -0500 +++ b/site-media/style/stevelosh.css Sat Feb 14 12:39:39 2009 -0500 @@ -79,12 +79,13 @@ margin-bottom: 0.5em; font-weight: bold; } -h1 a:link, h1 a:visited, h1 a:active, h2 a:link, h2 a:visited, h2 a:active { +h1 a:link, h1 a:visited, h1 a:active, h2 a:link, h2 a:visited, h2 a:active, +h3 a:link, h3 a:visited, h3 a:active { color: black; text-decoration: none; } -h1 a:hover, h2 a:hover { +h1 a:hover, h2 a:hover, h3 a:hover { color: #900; } diff -r a8bf2eea85f7 -r 444fa384fab8 templates/photoblog/base.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/photoblog/base.html Sat Feb 14 12:39:39 2009 -0500 @@ -0,0 +1,10 @@ +{% extends "base.html" %} + +{% block title %}Photo Blog{% endblock %} + +{% block style %} + +{% endblock %} + +{% block header %}/ photo blog{% endblock %} \ No newline at end of file diff -r a8bf2eea85f7 -r 444fa384fab8 templates/photoblog/entry.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/photoblog/entry.html Sat Feb 14 12:39:39 2009 -0500 @@ -0,0 +1,52 @@ +{% extends "photoblog/base.html" %} +{% load markup %} +{% load typogrify %} + +{% block title %}{{ entry.title }}{% endblock %} + +{% block script %} +{% endblock %} + +{% block content %} +
+

+ + {{ entry.title|typogrify }} + +

+ + + +
+ {{ entry.body|markdown|typogrify }} +
+ +
+

+ Posted on {{ entry.pub_date|date:"F j, Y" }} +

+
+ +
+
+
+

Newer

+
+
+ +

{{ entry.title }}

+
+
+ +
+
+

Older

+
+
+ +

{{ entry.title }}

+
+
+
+
+{% endblock %} \ No newline at end of file diff -r a8bf2eea85f7 -r 444fa384fab8 urls.py --- a/urls.py Sat Feb 14 11:46:36 2009 -0500 +++ b/urls.py Sat Feb 14 12:39:39 2009 -0500 @@ -12,6 +12,7 @@ url(r'^blog/', include('stevelosh.blog.urls')), url(r'^projects/', include('stevelosh.projects.urls')), url(r'^thoughts/', include('stevelosh.thoughts.urls')), + url(r'^photoblog/', include('stevelosh.photoblog.urls')), url(r'^rss/', include('stevelosh.rss.urls')), )