From 575e2ad387273aed3f13beddbe61de42490f4f1c Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Sat, 30 Dec 2023 15:25:46 -0600 Subject: [PATCH] provide author information for the feed and entries Signed-off-by: Brian S. Stephan --- incorporealcms/config.py | 3 +++ incorporealcms/feed.py | 2 ++ tests/test_feed.py | 11 ++++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/incorporealcms/config.py b/incorporealcms/config.py index b812ed7..bd877bc 100644 --- a/incorporealcms/config.py +++ b/incorporealcms/config.py @@ -65,4 +65,7 @@ class Config(object): TITLE_SUFFIX = DOMAIN_NAME CONTACT_EMAIL = 'admin@example.com' + # feed settings + AUTHOR = {'name': 'Test Name', 'email': 'admin@example.com'} + # specify FAVICON in your instance config.py to override the provided icon diff --git a/incorporealcms/feed.py b/incorporealcms/feed.py index 63e0d00..84c4d92 100644 --- a/incorporealcms/feed.py +++ b/incorporealcms/feed.py @@ -34,6 +34,7 @@ def serve_feed(feed_type): fg = FeedGenerator() fg.id(f'https://{app.config["DOMAIN_NAME"]}/') fg.title(f'{app.config["TITLE_SUFFIX"]}') + fg.author(app.config["AUTHOR"]) fg.link(href=f'https://{app.config["DOMAIN_NAME"]}/feed/{feed_type}', rel='self') fg.link(href=f'https://{app.config["DOMAIN_NAME"]}', rel='alternate') fg.subtitle(f"Blog posts and other dated materials from {app.config['TITLE_SUFFIX']}") @@ -55,6 +56,7 @@ def serve_feed(feed_type): fe = fg.add_entry() fe.id(_generate_feed_id(feed_entry_path)) fe.title(page_name if page_name else page_title) + fe.author(app.config["AUTHOR"]) fe.link(href=link) fe.content(content, type='html') diff --git a/tests/test_feed.py b/tests/test_feed.py index 84d2907..04226e7 100644 --- a/tests/test_feed.py +++ b/tests/test_feed.py @@ -26,8 +26,17 @@ def test_rss_type_is_200(client): print(response.text) -def test_feed_generator(app): +def test_feed_generator_atom(app): """Test the root feed generator.""" with app.test_request_context(): content = serve_feed('atom') assert b'https://example.com/' in content + assert b'admin@example.com' in content + assert b'Test Name' in content + + +def test_feed_generator_rss(app): + """Test the root feed generator.""" + with app.test_request_context(): + content = serve_feed('rss') + assert b'admin@example.com (Test Name)' in content