From 16cefe1db1a61303b58f0d82f32d3143b9062bc4 Mon Sep 17 00:00:00 2001 From: Bastian Krause Date: Sat, 17 Aug 2024 18:55:38 +0200 Subject: [PATCH 1/2] plugins/feeds: note that summaries are only available through a plugin By default, the content does not contain a summary. A custom plugin can add that functionality, though. The summary plugin used by Pengutronix is publicly available in flamingo-ptx-blog-engine [1]. It is not part of flamingo itself because it contains theme specifics (ptx-image, ptx-sidebar, ps-gallery). Mention that in the feeds plugin. [1] https://github.com/pengutronix/flamingo-ptx-blog-engine Signed-off-by: Bastian Krause --- flamingo/plugins/feeds.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/flamingo/plugins/feeds.py b/flamingo/plugins/feeds.py index 23d97a9..a9a8bdf 100644 --- a/flamingo/plugins/feeds.py +++ b/flamingo/plugins/feeds.py @@ -165,6 +165,9 @@ def pre_build(self, context): 'name': author, }) + # relies on a plugin generating a summary - see + # https://github.com/pengutronix/flamingo-ptx-blog-engine/blob/master/flamingo_ptx_blog_engine/summary.py + # for an example if i['summary']: summary = str(i['summary']) if 'html_filter' in feed_config: From a474abd28cf6b89b40c7fa03ea727e20fb9c412d Mon Sep 17 00:00:00 2001 From: Bastian Krause Date: Sat, 17 Aug 2024 18:58:09 +0200 Subject: [PATCH 2/2] 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 --- flamingo/plugins/feeds.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/flamingo/plugins/feeds.py b/flamingo/plugins/feeds.py index a9a8bdf..d40f0fb 100644 --- a/flamingo/plugins/feeds.py +++ b/flamingo/plugins/feeds.py @@ -29,6 +29,8 @@ def make_urls_absolute(html, base_url): class Feeds: def pre_build(self, context): + env = context.templating_engine.env + render_summary = env.globals.get('render_summary') FEEDS_DOMAIN = getattr(context.settings, 'FEEDS_DOMAIN', '/') FEEDS = getattr(context.settings, 'FEEDS', []) @@ -169,7 +171,13 @@ def pre_build(self, context): # https://github.com/pengutronix/flamingo-ptx-blog-engine/blob/master/flamingo_ptx_blog_engine/summary.py # for an example if i['summary']: - summary = str(i['summary']) + if render_summary: + summary = render_summary(i) + else: + summary = str(i['summary']) + + summary = make_urls_absolute(summary, fe_link['href']) + if 'html_filter' in feed_config: summary = feed_config['html_filter'](summary) fe.summary(summary, type='html')