##// END OF EJS Templates
Fixed tag parsing
Fixed tag parsing

File last commit:

r1946:473318e3 default
r2104:2e6f7c21 default
Show More
rss.py
79 lines | 2.0 KiB | text/x-python | PythonLexer
neko259
Implemented RSS support. This fixes #11
r89 from django.contrib.syndication.views import Feed
from django.shortcuts import get_object_or_404
neko259
Removed unused imports
r1946
neko259
Moved imageboard settings to the boards settings module. Added setting to disable archive
r716 from boards import settings
neko259
Removed unused imports
r1946 from boards.models import Post, TagAlias
neko259
Thread status field instead of bumpable and archived fields (per BB-73)
r1414 from boards.models.thread import STATUS_ARCHIVE
neko259
Implemented RSS support. This fixes #11
r89
neko259
Fixed thread RSS. Limit items count in RSS
r1400 __author__ = 'nekorin'
MAX_ITEMS = settings.get_int('RSS', 'MaxItems')
neko259
Implemented RSS support. This fixes #11
r89
neko259
Moved some settings to boards.settings
r333
neko259
Cleaned up code in some modules. Added a new style for the contributor roles.
r203 # TODO Make tests for all of these
class AllThreadsFeed(Feed):
neko259
Implemented RSS support. This fixes #11
r89
neko259
Implemented ini settings parser
r1153 title = settings.get('Version', 'SiteName') + ' - All threads'
neko259
Implemented RSS support. This fixes #11
r89 link = '/'
description_template = 'boards/rss/post.html'
def items(self):
neko259
Fixed RSS
r1594 return Post.objects.filter(opening=True).exclude(thread__status=STATUS_ARCHIVE).order_by('-id')[:MAX_ITEMS]
neko259
Implemented RSS support. This fixes #11
r89
def item_title(self, item):
neko259
Fixed RSS
r1594 return item.title
neko259
Implemented RSS support. This fixes #11
r89
def item_link(self, item):
neko259
Fixed RSS
r1594 return item.get_absolute_url()
neko259
Implemented RSS support. This fixes #11
r89
def item_pubdate(self, item):
neko259
Fixed RSS
r1594 return item.pub_time
neko259
Implemented RSS support. This fixes #11
r89
class TagThreadsFeed(Feed):
neko259
Cleaned up code in some modules. Added a new style for the contributor roles.
r203
neko259
Implemented RSS support. This fixes #11
r89 link = '/'
description_template = 'boards/rss/post.html'
def items(self, obj):
neko259
Fixed tag rss
r1882 return Post.objects.filter(opening=True, thread__tags__aliases__name__in=[obj]).exclude(thread__status=STATUS_ARCHIVE).order_by('-id')[:MAX_ITEMS]
neko259
Implemented RSS support. This fixes #11
r89
def get_object(self, request, tag_name):
neko259
Fixed tag rss
r1882 return get_object_or_404(TagAlias, name=tag_name).parent
neko259
Implemented RSS support. This fixes #11
r89
def item_title(self, item):
neko259
Fixed RSS
r1594 return item.title
neko259
Implemented RSS support. This fixes #11
r89
def item_link(self, item):
neko259
Fixed RSS
r1594 return item.get_absolute_url()
neko259
Implemented RSS support. This fixes #11
r89
def item_pubdate(self, item):
neko259
Fixed RSS
r1594 return item.pub_time
neko259
Implemented RSS support. This fixes #11
r89
def title(self, obj):
neko259
Fixed tag rss
r1882 return obj.get_name()
neko259
Implemented RSS support. This fixes #11
r89
class ThreadPostsFeed(Feed):
neko259
Cleaned up code in some modules. Added a new style for the contributor roles.
r203
neko259
Implemented RSS support. This fixes #11
r89 link = '/'
description_template = 'boards/rss/post.html'
def items(self, obj):
neko259
Fixed thread RSS. Limit items count in RSS
r1400 return obj.get_thread().get_replies().order_by('-pub_time')[:MAX_ITEMS]
neko259
Implemented RSS support. This fixes #11
r89
def get_object(self, request, post_id):
neko259
Fixed thread RSS
r580 return get_object_or_404(Post, id=post_id)
neko259
Implemented RSS support. This fixes #11
r89
def item_title(self, item):
return item.title
def item_link(self, item):
neko259
Fixed RSS
r1594 return item.get_absolute_url()
neko259
Implemented RSS support. This fixes #11
r89
def item_pubdate(self, item):
return item.pub_time
def title(self, obj):
neko259
Fixed thread RSS
r580 return obj.title