Skip to content

Commit d51d5f2

Browse files
authored
Merge pull request #51 from Bastian-Krause/bst/feed-summary
plugins/feeds: mention summary plugin, render summaries correctly
2 parents 087f4d8 + a474abd commit d51d5f2

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

flamingo/plugins/feeds.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ def make_urls_absolute(html, base_url):
2929

3030
class Feeds:
3131
def pre_build(self, context):
32+
env = context.templating_engine.env
33+
render_summary = env.globals.get('render_summary')
3234
FEEDS_DOMAIN = getattr(context.settings, 'FEEDS_DOMAIN', '/')
3335
FEEDS = getattr(context.settings, 'FEEDS', [])
3436

@@ -165,8 +167,17 @@ def pre_build(self, context):
165167
'name': author,
166168
})
167169

170+
# relies on a plugin generating a summary - see
171+
# https://github.com/pengutronix/flamingo-ptx-blog-engine/blob/master/flamingo_ptx_blog_engine/summary.py
172+
# for an example
168173
if i['summary']:
169-
summary = str(i['summary'])
174+
if render_summary:
175+
summary = render_summary(i)
176+
else:
177+
summary = str(i['summary'])
178+
179+
summary = make_urls_absolute(summary, fe_link['href'])
180+
170181
if 'html_filter' in feed_config:
171182
summary = feed_config['html_filter'](summary)
172183
fe.summary(summary, type='html')

0 commit comments

Comments
 (0)