# HG changeset patch # User Steve Losh # Date 1231975256 18000 # Node ID 796ae675fd37573f28aec183fe41a37ea829a703 # Parent 5d5a567385bb7292518ad7cbac5fb825762a5a68 Blog post RSS implemented. diff -r 5d5a567385bb -r 796ae675fd37 blog/models.py --- a/blog/models.py Tue Jan 13 19:37:21 2009 -0500 +++ b/blog/models.py Wed Jan 14 18:20:56 2009 -0500 @@ -10,9 +10,10 @@ body = models.TextField() published = models.BooleanField(default=False) + @models.permalink def get_absolute_url(self): - return "/blog/entry/%i/%i/%i/%s/" % (self.pub_date.year, - self.pub_date.month, self.pub_date.day, self.slug) + return ('blog-entry', (self.pub_date.year, self.pub_date.month, + self.pub_date.day, self.slug),) def __unicode__(self): return u'%s' % (self.title,) diff -r 5d5a567385bb -r 796ae675fd37 feeds.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/feeds.py Wed Jan 14 18:20:56 2009 -0500 @@ -0,0 +1,17 @@ +from django.contrib.syndication.feeds import Feed +from stevelosh.blog.models import Entry, Comment as BlogComment + +class LatestEntries(Feed): + title = "stevelosh.com blog entries" + link = "http://stevelosh.com/blog/" + description = "Latest blog entries on stevelosh.com" + + item_author_name = 'Steve Losh' + item_author_email = 'steve@stevelosh.com' + item_author_link = 'http://stevelosh.com/' + + def items(self): + return Entry.objects.filter(published=True).order_by('-pub_date')[:15] + + def item_pubdate(self, item): + return item.pub_date diff -r 5d5a567385bb -r 796ae675fd37 templates/blog/entry.html --- a/templates/blog/entry.html Tue Jan 13 19:37:21 2009 -0500 +++ b/templates/blog/entry.html Wed Jan 14 18:20:56 2009 -0500 @@ -36,6 +36,7 @@

Comments

{% for comment in entry.comment_set.all|dictsort:"submitted" %}
+

{{ comment.name }} said:

{{ comment.body|markdown:"safe" }} diff -r 5d5a567385bb -r 796ae675fd37 templates/feeds/blog_description.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/feeds/blog_description.html Wed Jan 14 18:20:56 2009 -0500 @@ -0,0 +1,1 @@ +{{ obj.snip }} \ No newline at end of file diff -r 5d5a567385bb -r 796ae675fd37 templates/feeds/blog_title.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/feeds/blog_title.html Wed Jan 14 18:20:56 2009 -0500 @@ -0,0 +1,1 @@ +{{ obj.title }} \ No newline at end of file diff -r 5d5a567385bb -r 796ae675fd37 urls.py --- a/urls.py Tue Jan 13 19:37:21 2009 -0500 +++ b/urls.py Wed Jan 14 18:20:56 2009 -0500 @@ -1,9 +1,11 @@ from django.conf.urls.defaults import * from django.contrib import admin from django.conf import settings +from stevelosh.feeds import LatestEntries admin.autodiscover() +feeds = { 'blog': LatestEntries, } urlpatterns = patterns('', (r'^admin/(.*)', admin.site.root), @@ -19,6 +21,7 @@ url(r'^projects/(.*)/$', 'stevelosh.projects.views.project'), url(r'^thoughts/$', 'stevelosh.thoughts.views.list', name='thoughts-list-newest'), url(r'^thoughts/page/(\d+)/$', 'stevelosh.thoughts.views.list', name='thoughts-list-page'), + url(r'^rss/(?P.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': feeds}), )