added feeds
This commit is contained in:
parent
0a3f74eee7
commit
39b59fd0f6
3
TODO
3
TODO
@ -1,9 +1,8 @@
|
||||
* revert option
|
||||
* wikiword highlighting
|
||||
* detect bad links
|
||||
* detect broken wiki links
|
||||
* only store diffs?
|
||||
* anonymous edits?
|
||||
|
||||
add options:
|
||||
* MARKUPWIKI_URL_RE
|
||||
* MARKUPWIKI_WIKIWORD_RE
|
||||
|
47
markupwiki/feeds.py
Normal file
47
markupwiki/feeds.py
Normal file
@ -0,0 +1,47 @@
|
||||
from django.contrib.syndication.views import Feed
|
||||
from django.shortcuts import get_object_or_404
|
||||
from markupwiki.models import Article, ArticleVersion
|
||||
|
||||
class LatestEditsFeed(Feed):
|
||||
title = 'Recent Changes'
|
||||
link = '/'
|
||||
description = 'Latest Changes to Wiki Articles'
|
||||
|
||||
def items(self):
|
||||
return ArticleVersion.objects.order_by('-timestamp').select_related()[:20]
|
||||
|
||||
def item_title(self, item):
|
||||
return unicode(item)
|
||||
|
||||
def item_description(self, item):
|
||||
return unicode(item.body)
|
||||
|
||||
def item_link(self, item):
|
||||
return item.get_absolute_url()
|
||||
|
||||
|
||||
class LatestArticleEditsFeed(Feed):
|
||||
|
||||
def get_object(self, request, title):
|
||||
return get_object_or_404(Article, title=title)
|
||||
|
||||
def title(self, obj):
|
||||
return 'Recent changes to %s' % obj
|
||||
|
||||
def description(self, obj):
|
||||
return 'Recent changes made to %s' % obj
|
||||
|
||||
def link(self, obj):
|
||||
return obj.get_absolute_url()
|
||||
|
||||
def items(self, obj):
|
||||
return obj.versions.order_by('-timestamp').select_related()[:20]
|
||||
|
||||
def item_title(self, item):
|
||||
return unicode(item)
|
||||
|
||||
def item_description(self, item):
|
||||
return unicode(item.body)
|
||||
|
||||
def item_link(self, item):
|
||||
return item.get_absolute_url()
|
@ -8,7 +8,7 @@ from markupfield.fields import MarkupField
|
||||
from markupfield import markup
|
||||
from markupwiki.utils import wikify_markup_wrapper
|
||||
|
||||
DEFAULT_MARKUP_TYPE = getattr(settings, 'MARKUPWIKI_DEFAULT_MARKUP_TYPE', 'plain')
|
||||
DEFAULT_MARKUP_TYPE = getattr(settings, 'MARKUPWIKI_DEFAULT_MARKUP_TYPE', 'markdown')
|
||||
WRITE_LOCK_SECONDS = getattr(settings, 'MARKUPWIKI_WRITE_LOCK_SECONDS', 60)
|
||||
MARKUP_TYPES = getattr(settings, 'MARKUPWIKI_MARKUP_TYPES', markup.DEFAULT_MARKUP_TYPES)
|
||||
|
||||
|
@ -1,8 +1,11 @@
|
||||
from django.conf.urls.defaults import *
|
||||
from markupwiki.feeds import LatestEditsFeed, LatestArticleEditsFeed
|
||||
|
||||
WIKI_REGEX = r'^(?P<title>.+)'
|
||||
|
||||
urlpatterns = patterns('markupwiki.views',
|
||||
url('^rss/$', LatestEditsFeed(), name='wiki_rss'),
|
||||
url(WIKI_REGEX + '/rss/$', LatestArticleEditsFeed(), name='article_rss'),
|
||||
url(WIKI_REGEX + '/edit/$', 'edit_article', name='edit_article'),
|
||||
url(WIKI_REGEX + '/update_status/$', 'article_status', name='update_article_status'),
|
||||
url(WIKI_REGEX + '/rename_article/$', 'rename', name='rename_article'),
|
||||
|
Loading…
Reference in New Issue
Block a user