2011-07-13 17:36:07 +08:00
|
|
|
|
from django.http import Http404
|
2017-01-27 03:58:33 +08:00
|
|
|
|
from django.utils.translation import gettext as _
|
2011-07-13 17:36:07 +08:00
|
|
|
|
|
2013-11-03 01:18:46 +08:00
|
|
|
|
|
2011-07-13 17:36:07 +08:00
|
|
|
|
def feed(request, url, feed_dict=None):
|
|
|
|
|
"""Provided for backwards compatibility."""
|
|
|
|
|
if not feed_dict:
|
2012-06-08 00:08:47 +08:00
|
|
|
|
raise Http404(_("No feeds are registered."))
|
2011-07-13 17:36:07 +08:00
|
|
|
|
|
2014-04-21 18:25:43 +08:00
|
|
|
|
slug = url.partition('/')[0]
|
2011-07-13 17:36:07 +08:00
|
|
|
|
try:
|
|
|
|
|
f = feed_dict[slug]
|
|
|
|
|
except KeyError:
|
2019-06-28 00:39:47 +08:00
|
|
|
|
raise Http404(_('Slug %r isn’t registered.') % slug)
|
2011-07-13 17:36:07 +08:00
|
|
|
|
|
|
|
|
|
instance = f()
|
|
|
|
|
instance.feed_url = getattr(f, 'feed_url', None) or request.path
|
|
|
|
|
instance.title_template = f.title_template or ('feeds/%s_title.html' % slug)
|
|
|
|
|
instance.description_template = f.description_template or ('feeds/%s_description.html' % slug)
|
|
|
|
|
return instance(request)
|