mirror of
https://github.com/r4sas/py-i2phosts
synced 2025-09-03 17:42:11 +00:00
Implement RSS export for all active hosts
KwukDuck asked me for RSS for using it with LiveBookmarks firefox plugin in his portable I2P package.
This commit is contained in:
parent
fe5e6ccc80
commit
dc919135cc
26
pyi2phosts/lib/rss.py
Executable file
26
pyi2phosts/lib/rss.py
Executable file
@ -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
|
@ -6,6 +6,7 @@ from django.views.generic.list_detail import object_list
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
admin.autodiscover()
|
admin.autodiscover()
|
||||||
|
|
||||||
|
from pyi2phosts.lib.rss import AliveHostsFeed
|
||||||
from pyi2phosts.lib.utils import get_b32
|
from pyi2phosts.lib.utils import get_b32
|
||||||
from pyi2phosts.extsources.models import ExternalSource
|
from pyi2phosts.extsources.models import ExternalSource
|
||||||
from pyi2phosts.postkey.models import i2phost
|
from pyi2phosts.postkey.models import i2phost
|
||||||
@ -42,6 +43,7 @@ urlpatterns = patterns('',
|
|||||||
}, name='index'),
|
}, name='index'),
|
||||||
url(r'^faq/$', object_list, extsources, name='faq'),
|
url(r'^faq/$', object_list, extsources, name='faq'),
|
||||||
url(r'^browse/$', object_list, browse_hosts, name='browse'),
|
url(r'^browse/$', object_list, browse_hosts, name='browse'),
|
||||||
|
url(r'^browse/rss/$', AliveHostsFeed()),
|
||||||
|
|
||||||
(r'^latest/$', include('pyi2phosts.latest.urls')),
|
(r'^latest/$', include('pyi2phosts.latest.urls')),
|
||||||
(r'^search/$', include('pyi2phosts.search.urls')),
|
(r'^search/$', include('pyi2phosts.search.urls')),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user