1
0
mirror of https://github.com/r4sas/py-i2phosts synced 2025-02-03 18:34:33 +00:00

38 lines
1.1 KiB
Python
Raw Normal View History

from django.contrib.syndication.views import Feed
from django.conf import settings
from pyi2phosts.postkey.models import i2phost
from pyi2phosts.latest.views import get_latest
class AliveHostsFeed(Feed):
2015-10-26 18:55:35 +00:00
""" Generate RSS feed with all alive hosts """
2015-10-26 18:55:35 +00:00
title = settings.DOMAIN + ' alive hosts'
# FIXME: make this URL more dynamic
link = 'http://' + settings.DOMAIN + '/browse/'
description = 'All known active hosts inside I2P'
2015-10-26 18:55:35 +00:00
def items(self):
return i2phost.objects.filter(activated=True).order_by('name')
2015-10-26 18:55:35 +00:00
def item_title(self, item):
return item.name
2015-10-26 18:55:35 +00:00
def item_link(self, item):
return 'http://' + item.name + '/?i2paddresshelper=' + item.b64hash
2015-10-26 18:55:35 +00:00
def item_description(self, item):
return item.description
class LatestHostsFeed(AliveHostsFeed):
2015-10-26 18:55:35 +00:00
""" Generate RSS feed with freshly added hosts """
2015-10-26 18:55:35 +00:00
title = settings.DOMAIN + ' latest hosts'
# FIXME: make this URL more dynamic
link = 'http://' + settings.DOMAIN + '/latest/'
description = 'Freshly added hosts'
2015-10-26 18:55:35 +00:00
def items(self):
return get_latest()