summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2013-01-19 17:33:03 +0100
committerDan McGee <dan@archlinux.org>2013-01-19 17:33:03 +0100
commitfbc153ed456f2f4aa730580f942d10d973fd1ea9 (patch)
tree198f5a969c01738513c6441981fd1339ef7d2d33
parenta42a0dc6e400d03609d2d53c0955273b3c05c7ea (diff)
downloadarchweb-fbc153ed456f2f4aa730580f942d10d973fd1ea9.tar.gz
archweb-fbc153ed456f2f4aa730580f942d10d973fd1ea9.tar.xz
Initial cut of a Releases RSS feed
This is our first use of enclosures on the site as well. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--feeds.py43
-rw-r--r--urls.py3
2 files changed, 45 insertions, 1 deletions
diff --git a/feeds.py b/feeds.py
index c5bdbde..98e1fb8 100644
--- a/feeds.py
+++ b/feeds.py
@@ -1,4 +1,6 @@
+from datetime import datetime, time
import hashlib
+from pytz import utc
from django.contrib.sites.models import Site
from django.contrib.syndication.views import Feed
@@ -9,6 +11,7 @@ from django.views.decorators.http import condition
from main.utils import retrieve_latest
from main.models import Arch, Repo, Package
from news.models import News
+from releng.models import Release
class GuidNotPermalinkFeed(Rss201rev2Feed):
@@ -152,4 +155,44 @@ class NewsFeed(Feed):
def item_author_name(self, item):
return item.author.get_full_name()
+
+class ReleaseFeed(Feed):
+ feed_type = GuidNotPermalinkFeed
+
+ title = 'Arch Linux: Releases'
+ link = '/download/'
+ description = 'Release ISOs'
+ subtitle = description
+
+ __name__ = 'release_feed'
+
+ def items(self):
+ return Release.objects.filter(available=True)[:10]
+
+ def item_title(self, item):
+ return item.version
+
+ def item_description(self, item):
+ return item.info_html()
+
+ # TODO: individual release pages
+ item_link = '/download/'
+
+ def item_pubdate(self, item):
+ return datetime.combine(item.release_date, time()).replace(tzinfo=utc)
+
+ def item_guid(self, item):
+ # http://diveintomark.org/archives/2004/05/28/howto-atom-id
+ date = item.release_date
+ return 'tag:%s,%s:%s' % (Site.objects.get_current().domain,
+ date.strftime('%Y-%m-%d'), item.iso_url())
+
+ def item_enclosure_url(self, item):
+ domain = Site.objects.get_current().domain
+ proto = 'https'
+ return "%s://%s/%s.torrent" % (proto, domain, item.iso_url())
+
+ item_enclosure_mime_type = 'application/x-bittorrent'
+ item_enclosure_length = 0
+
# vim: set ts=4 sw=4 et:
diff --git a/urls.py b/urls.py
index 1bdf1a5..8288297 100644
--- a/urls.py
+++ b/urls.py
@@ -6,7 +6,7 @@ from django.views.decorators.cache import cache_page
from django.views.generic import TemplateView, RedirectView
from django.views.i18n import null_javascript_catalog
-from feeds import PackageFeed, NewsFeed
+from feeds import PackageFeed, NewsFeed, ReleaseFeed
import sitemaps
our_sitemaps = {
@@ -32,6 +32,7 @@ feeds_patterns = patterns('',
cache_page(300)(PackageFeed())),
(r'^packages/(?P<arch>[A-z0-9]+)/(?P<repo>[A-z0-9\-]+)/$',
cache_page(300)(PackageFeed())),
+ (r'^releases/$', cache_page(300)(ReleaseFeed())),
)
# Sitemaps