diff --git a/pyi2phosts/lib/rss.py b/pyi2phosts/lib/rss.py new file mode 100755 index 0000000..e448174 --- /dev/null +++ b/pyi2phosts/lib/rss.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python2.6 + +from django.contrib.syndication.views import Feed +from pyi2phosts.postkey.models import i2phost + +import settings + +class AliveHostsFeed(Feed): + """ Generate RSS feed with all alive hosts """ + + title = settings.DOMAIN + ' alive hosts' + # FIXME: make this URL more dynamic + link = 'http://' + settings.DOMAIN + '/browse/' + description = 'All known active hosts inside I2P' + + def items(self): + return i2phost.objects.filter(activated=True).order_by('name') + + def item_title(self, item): + return item.name + + def item_link(self, item): + return 'http://' + item.name + '/?i2paddresshelper=' + item.b64hash + + def item_description(self, item): + return item.description diff --git a/pyi2phosts/urls.py b/pyi2phosts/urls.py index 0876999..a00e7b1 100644 --- a/pyi2phosts/urls.py +++ b/pyi2phosts/urls.py @@ -6,6 +6,7 @@ from django.views.generic.list_detail import object_list from django.contrib import admin admin.autodiscover() +from pyi2phosts.lib.rss import AliveHostsFeed from pyi2phosts.lib.utils import get_b32 from pyi2phosts.extsources.models import ExternalSource from pyi2phosts.postkey.models import i2phost @@ -42,6 +43,7 @@ urlpatterns = patterns('', }, name='index'), url(r'^faq/$', object_list, extsources, name='faq'), url(r'^browse/$', object_list, browse_hosts, name='browse'), + url(r'^browse/rss/$', AliveHostsFeed()), (r'^latest/$', include('pyi2phosts.latest.urls')), (r'^search/$', include('pyi2phosts.search.urls')),