##// END OF EJS Templates
Removed threads list cache cause it's causing problems with tags view.
Removed threads list cache cause it's causing problems with tags view.

File last commit:

r189:bd4cb780 default
r192:ae8703f0 default
Show More
rss.py
75 lines | 1.9 KiB | text/x-python | PythonLexer
neko259
Implemented RSS support. This fixes #11
r89 from django.contrib.syndication.views import Feed
from django.core.urlresolvers import reverse
from django.shortcuts import get_object_or_404
from boards.models import Post, Tag, NO_PARENT
from neboard import settings
__author__ = 'neko259'
neko259
Show only several last items in the RSS feed.
r189 MAX_ITEMS = 20
neko259
Implemented RSS support. This fixes #11
r89
class AllThreadsFeed(Feed):
title = settings.SITE_NAME + ' - All threads'
link = '/'
description_template = 'boards/rss/post.html'
def items(self):
neko259
Show only several last items in the RSS feed.
r189 return Post.objects.get_threads(order_by='-pub_time')[:MAX_ITEMS]
neko259
Implemented RSS support. This fixes #11
r89
def item_title(self, item):
return item.title
def item_link(self, item):
return reverse('thread', args={item.id})
def item_pubdate(self, item):
return item.pub_time
class TagThreadsFeed(Feed):
link = '/'
description_template = 'boards/rss/post.html'
def items(self, obj):
neko259
Show only several last items in the RSS feed.
r189 return Post.objects.get_threads(tag=obj, order_by='-pub_time')[:MAX_ITEMS]
neko259
Implemented RSS support. This fixes #11
r89
def get_object(self, request, tag_name):
return get_object_or_404(Tag, name=tag_name)
def item_title(self, item):
return item.title
def item_link(self, item):
return reverse('thread', args={item.id})
def item_pubdate(self, item):
return item.pub_time
def title(self, obj):
return obj.name
class ThreadPostsFeed(Feed):
link = '/'
description_template = 'boards/rss/post.html'
def items(self, obj):
neko259
Show only several last items in the RSS feed.
r189 return Post.objects.get_thread(opening_post_id=obj)[:MAX_ITEMS]
neko259
Implemented RSS support. This fixes #11
r89
def get_object(self, request, post_id):
return post_id
def item_title(self, item):
return item.title
def item_link(self, item):
if NO_PARENT == item.parent:
return reverse('thread', args={item.id})
else:
return reverse('thread', args={item.parent}) + "#" + str(item.id)
def item_pubdate(self, item):
return item.pub_time
def title(self, obj):
return get_object_or_404(Post, id=obj).title