diff --git a/TODO b/TODO index ea7dfee..f9ac1d0 100644 --- a/TODO +++ b/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 diff --git a/markupwiki/feeds.py b/markupwiki/feeds.py new file mode 100644 index 0000000..b3ff86c --- /dev/null +++ b/markupwiki/feeds.py @@ -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() diff --git a/markupwiki/models.py b/markupwiki/models.py index a99bd11..55a18a4 100644 --- a/markupwiki/models.py +++ b/markupwiki/models.py @@ -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) diff --git a/markupwiki/urls.py b/markupwiki/urls.py index 48cfab4..1826718 100644 --- a/markupwiki/urls.py +++ b/markupwiki/urls.py @@ -1,8 +1,11 @@ from django.conf.urls.defaults import * +from markupwiki.feeds import LatestEditsFeed, LatestArticleEditsFeed WIKI_REGEX = r'^(?P.+)' 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'),