diff options
-rw-r--r-- | feeds.py | 36 | ||||
-rw-r--r-- | templates/feeds/news_description.html | 4 | ||||
-rw-r--r-- | templates/feeds/news_title.html | 1 | ||||
-rw-r--r-- | templates/feeds/packages_description.html | 1 | ||||
-rw-r--r-- | templates/feeds/packages_title.html | 1 | ||||
-rw-r--r-- | urls.py | 11 |
6 files changed, 54 insertions, 0 deletions
diff --git a/feeds.py b/feeds.py new file mode 100644 index 00000000..cc6f3278 --- /dev/null +++ b/feeds.py @@ -0,0 +1,36 @@ +import datetime +from django.contrib.syndication.feeds import Feed +from archweb.main.models import Package, News +#from datetime import datetime + +class PackageFeed(Feed): + title = 'Recent Package Updates' + link = '/packages/' + description = 'Recent Package Updates' + + def items(self): + return Package.objects.order_by('-last_update')[:24] + + def item_pubdate(self, item): + return item.last_update + + def item_categories(self, item): + return (item.repo.name,item.arch.name) + +class NewsFeed(Feed): + title = 'Recent News Updates' + link = '/news/' + description = 'Recent News Updates' + + def items(self): + return News.objects.order_by('-postdate', '-id')[:10] + + def item_pubdate(self, item): + d = item.postdate + return datetime.datetime(d.year, d.month, d.day) + + def item_author_name(self, item): + return item.author.get_full_name() + +# vim: set ts=4 sw=4 et: + diff --git a/templates/feeds/news_description.html b/templates/feeds/news_description.html new file mode 100644 index 00000000..c428b9e2 --- /dev/null +++ b/templates/feeds/news_description.html @@ -0,0 +1,4 @@ +{% autoescape off %} +{{obj.author.get_full_name}} wrote:<br /> +{{ obj.content }} +{% endautoescape %} diff --git a/templates/feeds/news_title.html b/templates/feeds/news_title.html new file mode 100644 index 00000000..d355de5b --- /dev/null +++ b/templates/feeds/news_title.html @@ -0,0 +1 @@ +{{ obj.title }} diff --git a/templates/feeds/packages_description.html b/templates/feeds/packages_description.html new file mode 100644 index 00000000..6b9c47b3 --- /dev/null +++ b/templates/feeds/packages_description.html @@ -0,0 +1 @@ +{{ obj.pkgdesc }} diff --git a/templates/feeds/packages_title.html b/templates/feeds/packages_title.html new file mode 100644 index 00000000..910c6207 --- /dev/null +++ b/templates/feeds/packages_title.html @@ -0,0 +1 @@ +{{ obj.pkgname }} {{ obj.pkgver }}-{{ obj.pkgrel }} {{ obj.arch.name }} @@ -7,6 +7,13 @@ from django.views.generic.simple import direct_to_template from django.contrib.auth.decorators import permission_required from archweb.main.models import Todolist +from archweb.feeds import PackageFeed, NewsFeed + + +feeds = { + 'packages': PackageFeed, + 'news': NewsFeed +} admin.autodiscover() @@ -50,6 +57,10 @@ urlpatterns = patterns('', (r'^devel/newuser/$', 'archweb.devel.views.new_user_form'), +# Feeds and sitemaps + (r'^feeds/(?P<url>.*)/$', + 'django.contrib.syndication.views.feed', {'feed_dict': feeds}), + # Authentication / Admin (r'^login/$', 'django.contrib.auth.views.login', { 'template_name': 'registration/login.html'}), |