Implement syndication of news

This commit is contained in:
Trever Fischer
2012-02-25 14:44:07 -05:00
parent ee82cd40cb
commit 21d4ac4700
4 changed files with 28 additions and 0 deletions

View File

@@ -1,7 +1,29 @@
from django.conf.urls.defaults import patterns, include, url
from django.contrib.syndication.views import Feed
import models
class NewsFeed(Feed):
title = 'Caminus News'
link = '/news/'
description = 'News posts from Team Caminus'
description_template = 'news/_feed_description.html'
def items(self):
return models.Post.objects.order_by('-created')[:5]
def item_title(self, item):
return item.title
def item_description(self, item):
return item.body
def item_author_name(self, item):
return item.author
urlpatterns = patterns('news',
url('^$', 'views.index'),
url('^feed$', NewsFeed()),
url('^(?P<page>[0-9]+)$', 'views.index'),
url('^(?P<slug>.*)$', 'views.view')
)

BIN
static/feed.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 764 B

View File

@@ -0,0 +1,2 @@
{% load markup %}
{{ obj.body|markdown }}

View File

@@ -1,4 +1,5 @@
{% extends 'base.html' %}
{% load static %}
{% load markup %}
{% load comments %}
@@ -13,4 +14,7 @@
</div>
<div class="commentcount">{% get_comment_count for post as comment_count %}{{comment_count}} comments.</div>
{% endfor %}
{% get_static_prefix as STATIC_PREFIX %}
<a href="/news/feed"><img src="{{ STATIC_PREFIX }}/feed.png"/></a>
{% endblock %}