Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ENH: Add RSS feed to blog app

  • Loading branch information...
commit 427927c5b6db03cc6c2e7153e08542014e7e227c 1 parent dde8bd0
Luis Pedro Coelho authored
Showing with 21 additions and 0 deletions.
  1. +19 −0 gitcms/blog/feeds.py
  2. +2 −0  gitcms/blog/urls.py
View
19 gitcms/blog/feeds.py
@@ -0,0 +1,19 @@
+from django.contrib.syndication.views import Feed
+from gitcms.blog.models import BlogPost
+
+class LatestFeed(Feed):
+ title = 'pythonvision.org blog feed'
+ link = '/blog/feed'
+ description = 'Updates on pythonvision.org and items of interest for computer vision in Python'
+
+ def items(self):
+ return BlogPost.objects.order_by('-timestamp')[:20]
+
+ def item_title(self, post):
+ return post.title
+
+ def item_description(self, post):
+ return post.content
+
+ def item_link(self, post):
+ return '/blog/' + post.year_month_slug
View
2  gitcms/blog/urls.py
@@ -1,8 +1,10 @@
from django.conf.urls.defaults import *
import views
+import feeds
urlpatterns = patterns('',
(r'^tag/(?P<tag>.*)/?', views.bytag),
(r'^(?P<year>[0-9]+)/(?P<month>[^/]*)/(?P<slug>[^/]*)/?', views.post),
+ (r'^feed/?', feeds.LatestFeed()),
(r'^/?', views.mostrecent),
)
Please sign in to comment.
Something went wrong with that request. Please try again.