Browse Source

Implement RSS export for all active hosts

KwukDuck asked me for RSS for using it with LiveBookmarks firefox
plugin in his portable I2P package.
pull/1/head
Hidden Z 14 years ago
parent
commit
dc919135cc
  1. 26
      pyi2phosts/lib/rss.py
  2. 2
      pyi2phosts/urls.py

26
pyi2phosts/lib/rss.py

@ -0,0 +1,26 @@ @@ -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

2
pyi2phosts/urls.py

@ -6,6 +6,7 @@ from django.views.generic.list_detail import object_list @@ -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('', @@ -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')),

Loading…
Cancel
Save