From f8ddfb09e2c3051eb3b886781a83a66d15da70e1 Mon Sep 17 00:00:00 2001 From: Yax <1949284+kianby@users.noreply.github.com> Date: Fri, 23 Aug 2019 13:24:19 +0200 Subject: [PATCH] rss feed --- layout/item.html | 4 ++-- layout/item.xml | 5 ++--- layout/list.html | 3 --- layout/page.html | 18 +++++++++--------- layout/{feed.xml => rss.xml} | 2 +- makesite.py | 19 +++++++++++-------- params.json | 3 ++- 7 files changed, 27 insertions(+), 27 deletions(-) rename layout/{feed.xml => rss.xml} (76%) diff --git a/layout/item.html b/layout/item.html index 3e90363..3f41146 100644 --- a/layout/item.html +++ b/layout/item.html @@ -1,5 +1,5 @@
-

{{ title }}

+

{{ title }}

{{ category_label}}{{ friendly_date }}

{{ summary }}

-
\ No newline at end of file + diff --git a/layout/item.xml b/layout/item.xml index 8403e00..b3981ad 100644 --- a/layout/item.xml +++ b/layout/item.xml @@ -1,12 +1,11 @@ {{ title }} -{{ site_url }}/{{ blog }}/{{ slug }}/ +{{ site_url }}/{{ year }}/{{ slug }}.html -{{ summary }} ... +{{ content }}

-

Read More

]]>
{{ rfc_2822_date }} diff --git a/layout/list.html b/layout/list.html index be196f9..cddd070 100644 --- a/layout/list.html +++ b/layout/list.html @@ -1,4 +1 @@ {{ content }} -
-RSS -
diff --git a/layout/page.html b/layout/page.html index 255ae22..4badc9c 100644 --- a/layout/page.html +++ b/layout/page.html @@ -2,18 +2,18 @@ - {{ title }} - {{ subtitle }} + {{ title }} - - + + - + @@ -28,9 +28,11 @@ - - + + + +
@@ -41,7 +43,6 @@
@@ -68,5 +69,4 @@ - diff --git a/layout/feed.xml b/layout/rss.xml similarity index 76% rename from layout/feed.xml rename to layout/rss.xml index 388c39e..8a0a33e 100644 --- a/layout/feed.xml +++ b/layout/rss.xml @@ -4,7 +4,7 @@ {{ title }} {{ site_url }}/ -Grow with Technology +{{ subtitle }} {{ content }} diff --git a/makesite.py b/makesite.py index 440d53f..8c0f3ed 100755 --- a/makesite.py +++ b/makesite.py @@ -246,8 +246,11 @@ def make_list(posts, dst, list_layout, item_layout, banner_layout, **params): item = render(item_layout, **item_params) items.append(item) - banner = render(banner_layout, **params) - params['banner'] = banner + if banner_layout is None: + params['banner'] = '' + else: + banner = render(banner_layout, **params) + params['banner'] = banner params['content'] = ''.join(items) dst_path = render(dst, **params) @@ -265,7 +268,6 @@ def main(): # Default parameters. params = { - 'base_path': '', 'title': 'Blog', 'subtitle': 'Lorem Ipsum', 'author': 'Admin', @@ -284,7 +286,7 @@ def main(): item_layout = fread('layout/item.html') banner_layout = fread('layout/banner.html') category_layout = fread('layout/category.html') - feed_xml = fread('layout/feed.xml') + rss_xml = fread('layout/rss.xml') item_xml = fread('layout/item.xml') # Combine layouts to form final layouts. @@ -316,13 +318,14 @@ def main(): catpost[cat] = [post] for cat in catpost.keys(): make_list(catpost[cat], '_site/' + slugify(cat) + '.html', - list_layout, item_layout, banner_layout, **params) + list_layout, item_layout, None, **params) - print(catpost.keys()) #print(blog_posts) + # Create RSS feeds. - #make_list(blog_posts, '_site/blog/rss.xml', - # feed_xml, item_xml, banner_layout, **params) + nb_items = min(10, len(blog_posts)) + make_list(blog_posts[:nb_items], '_site/rss.xml', + rss_xml, item_xml, None, **params) # Test parameter to be set temporarily by unit tests. diff --git a/params.json b/params.json index 6bb96f9..f1e7b1e 100644 --- a/params.json +++ b/params.json @@ -1,5 +1,6 @@ { + "site_url": "https://blogduyax.madyanne.fr", "title": "Le blog du Yax", "subtitle": "GNU, Linux, BSD et autres libertés", "author": "Yax" -} \ No newline at end of file +}