--- a/feeds.py Wed Jan 14 18:20:56 2009 -0500
+++ b/feeds.py Wed Jan 14 18:46:33 2009 -0500
@@ -1,5 +1,7 @@
from django.contrib.syndication.feeds import Feed
from stevelosh.blog.models import Entry, Comment as BlogComment
+from stevelosh.projects.models import Project, Comment as ProjectComment
+import operator
class LatestEntries(Feed):
title = "stevelosh.com blog entries"
@@ -15,3 +17,37 @@
def item_pubdate(self, item):
return item.pub_date
+
+class LatestComments(Feed):
+ title = "stevelosh.com blog comments"
+ link = "http://stevelosh.com/blog/"
+ description = "Latest comments on blog entries from stevelosh.com"
+
+ item_author_name = 'Steve Losh'
+ item_author_email = 'steve@stevelosh.com'
+ item_author_link = 'http://stevelosh.com/'
+
+ def items(self):
+ comments = list(BlogComment.objects.order_by('-submitted')[:50])
+ comments += list(ProjectComment.objects.order_by('-submitted')[:50])
+ comments.sort(key=operator.attrgetter('submitted'))
+ return comments[:50]
+
+ def item_pubdate(self, item):
+ return item.submitted
+
+class LatestProjects(Feed):
+ title = "stevelosh.com projects"
+ link = "http://stevelosh.com/projects/"
+ description = "Latest projects on stevelosh.com"
+
+ item_author_name = 'Steve Losh'
+ item_author_email = 'steve@stevelosh.com'
+ item_author_link = 'http://stevelosh.com/'
+
+ def items(self):
+ return Project.objects.order_by('-posted')[:15]
+
+ def item_pubdate(self, item):
+ return item.posted
+
--- a/projects/models.py Wed Jan 14 18:20:56 2009 -0500
+++ b/projects/models.py Wed Jan 14 18:46:33 2009 -0500
@@ -12,6 +12,10 @@
posted = models.DateTimeField(blank=False, default=datetime.datetime.now)
slug = models.SlugField()
+ @models.permalink
+ def get_absolute_url(self):
+ return ('project-view', (self.slug,),)
+
def __unicode__(self):
return u"%s" % (self.name,)
@@ -50,6 +54,9 @@
submitted = models.DateTimeField(default=datetime.datetime.now)
project = models.ForeignKey(Project)
+ def get_absolute_url(self):
+ return self.project.get_absolute_url() + "#comment-" + str(self.id)
+
def __unicode__(self):
return u'%s on %s' % (self.name, self.entry.title)
--- a/urls.py Wed Jan 14 18:20:56 2009 -0500
+++ b/urls.py Wed Jan 14 18:46:33 2009 -0500
@@ -1,27 +1,29 @@
from django.conf.urls.defaults import *
from django.contrib import admin
from django.conf import settings
-from stevelosh.feeds import LatestEntries
+from stevelosh.feeds import LatestEntries, LatestComments, LatestProjects
admin.autodiscover()
-feeds = { 'blog': LatestEntries, }
+feeds = { 'blog': LatestEntries,
+ 'comments': LatestComments,
+ 'projects': LatestProjects, }
urlpatterns = patterns('',
(r'^admin/(.*)', admin.site.root),
- url(r'^blog/$', 'stevelosh.blog.views.list', name='blog-list-newest'),
- url(r'^blog/page/(\d+)/$', 'stevelosh.blog.views.list', name='blog-list-page'),
- url(r'^blog/comment/$', 'stevelosh.blog.views.comment'),
+ url(r'^blog/$', 'stevelosh.blog.views.list', name='blog-list-newest'),
+ url(r'^blog/page/(\d+)/$', 'stevelosh.blog.views.list', name='blog-list-page'),
+ url(r'^blog/comment/$', 'stevelosh.blog.views.comment', name='blog-post-comment'),
url(r'^blog/entry/(\d+)/(\d+)/(\d+)/(.*)/$',
- 'stevelosh.blog.views.entry', name='blog-entry'),
+ 'stevelosh.blog.views.entry', name='blog-entry'),
url(r'^blog/(\d+)/(\d+)/(\d+)/(.*).html/$',
- 'stevelosh.blog.views.old_entry', name='blog-old-entry'),
- url(r'^projects/$', 'stevelosh.projects.views.list', name='project-list'),
- url(r'^projects/comment/$', 'stevelosh.projects.views.comment'),
- 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<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': feeds}),
+ 'stevelosh.blog.views.old_entry', name='blog-old-entry'),
+ url(r'^projects/$', 'stevelosh.projects.views.list', name='project-list'),
+ url(r'^projects/comment/$', 'stevelosh.projects.views.comment', name='project-post-comment'),
+ url(r'^projects/(.*)/$', 'stevelosh.projects.views.project', name='project-view'),
+ 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<url>.+)/$', 'django.contrib.syndication.views.feed', {'feed_dict': feeds}),
)