1 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
4 from datetime import date
5 from django.conf import settings
6 from django.template import Library
13 @register.inclusion_tag('latest_blog_posts.html')
14 def latest_blog_posts(feed_url=None, posts_to_show=5):
16 feed_url = settings.LATEST_BLOG_POSTS
19 feed = feedparser.parse(str(feed_url))
20 for i in range(posts_to_show):
21 pub_date = feed['entries'][i].published_parsed
22 published = date(pub_date[0], pub_date[1], pub_date[2])
24 'title': feed['entries'][i].title,
25 'summary': feed['entries'][i].summary,
26 'link': feed['entries'][i].link,