Skip to content

Commit a474abd

Browse files
plugins/feeds: render summary and make URLs in it absolute
Unrendered summaries contain directives such as: {{ link('content/blog-post.html', 'foo') }} These do not belong in the final HTML output. A function for summary rendering can be provided by a custom summary plugin. Use that if available and make rendered URLs absolute afterwards. See [1] for an example summary plugin. But note that it contains theme-related information. [1] https://github.com/pengutronix/flamingo-ptx-blog-engine/blob/master/flamingo_ptx_blog_engine/summary.py Signed-off-by: Bastian Krause <bst@pengutronix.de>
1 parent 16cefe1 commit a474abd

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

flamingo/plugins/feeds.py

Lines changed: 9 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

@@ -169,7 +171,13 @@ def pre_build(self, context):
169171
# https://github.com/pengutronix/flamingo-ptx-blog-engine/blob/master/flamingo_ptx_blog_engine/summary.py
170172
# for an example
171173
if i['summary']:
172-
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+
173181
if 'html_filter' in feed_config:
174182
summary = feed_config['html_filter'](summary)
175183
fe.summary(summary, type='html')

0 commit comments

Comments
 (0)