|
@@ -0,0 +1,49 @@
|
|
|
+import feedparser
|
|
|
+
|
|
|
+from django.template import RequestContext
|
|
|
+from django.shortcuts import render_to_response
|
|
|
+from django.http import HttpResponse
|
|
|
+from django.conf import settings
|
|
|
+
|
|
|
+
|
|
|
+def feed_provider(request):
|
|
|
+ feed_url = ''
|
|
|
+ limit = 3
|
|
|
+ try:
|
|
|
+ if settings.FEED_PROVIDER_URL:
|
|
|
+ feed_url = settings.FEED_PROVIDER_URL
|
|
|
+ if settings.FEED_PROVIDER_MAX_ENTRIES:
|
|
|
+ limit = settings.FEED_PROVIDER_MAX_ENTRIES
|
|
|
+ except:
|
|
|
+ pass
|
|
|
+
|
|
|
+ return feed(request, feed_url, limit)
|
|
|
+
|
|
|
+
|
|
|
+def feed_ffdn(request):
|
|
|
+ feed_url = ''
|
|
|
+ limit = 3
|
|
|
+ try:
|
|
|
+ if settings.FEED_FFDN_URL:
|
|
|
+ feed_url = settings.FEED_FFDN_URL
|
|
|
+ if settings.FEED_FFDN_MAX_ENTRIES:
|
|
|
+ limit = settings.FEED_FFDN_MAX_ENTRIES
|
|
|
+ except:
|
|
|
+ pass
|
|
|
+
|
|
|
+ return feed(request, feed_url, limit)
|
|
|
+
|
|
|
+
|
|
|
+def feed(request, feed_url, limit):
|
|
|
+ try:
|
|
|
+ if feed_url:
|
|
|
+ feed = feedparser.parse(feed_url)
|
|
|
+ entries = feed.entries[:limit]
|
|
|
+
|
|
|
+ return render_to_response('fragments/feed.html',
|
|
|
+ {'feed_entries': entries},
|
|
|
+ context_instance=RequestContext(request))
|
|
|
+ except:
|
|
|
+ pass
|
|
|
+
|
|
|
+ return HttpResponse('')
|