Implement syndication of news
This commit is contained in:
22
news/urls.py
22
news/urls.py
@@ -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
BIN
static/feed.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 764 B |
2
templates/news/_feed_description.html
Normal file
2
templates/news/_feed_description.html
Normal file
@@ -0,0 +1,2 @@
|
||||
{% load markup %}
|
||||
{{ obj.body|markdown }}
|
@@ -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 %}
|
||||
|
Reference in New Issue
Block a user