From 3314559176aa2804a76b63c998c606853e39fa2c Mon Sep 17 00:00:00 2001 From: Thomas Letan Date: Sat, 13 May 2023 15:31:10 +0200 Subject: RSS feed finally! --- plugins/archives-index.lua | 7 +++++++ plugins/series-index.lua | 9 +++++---- soupault.toml | 6 +++++- templates/index.xml | 25 +++++++++++++++++++++++++ templates/main.html | 1 + 5 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 templates/index.xml diff --git a/plugins/archives-index.lua b/plugins/archives-index.lua index aceb7a9..c3dc4aa 100644 --- a/plugins/archives-index.lua +++ b/plugins/archives-index.lua @@ -8,12 +8,19 @@ if Value.is_string(container_content) then end template = nil +pages = {} if container_content then env['contents'] = Table.take(site_index, container_content) template = "index_short_template_file" else env['contents'] = site_index + + template = Sys.read_file(config['index_rss_template_file']) + + path = Sys.join_path(target_dir, 'index.xml') + Sys.write_file(path, String.render_template(template, env)) + template = "index_full_template_file" end diff --git a/plugins/series-index.lua b/plugins/series-index.lua index 12b693a..d74a833 100644 --- a/plugins/series-index.lua +++ b/plugins/series-index.lua @@ -1,20 +1,21 @@ +prefix_url = "/" .. soupault_config['widgets']['urls-rewriting']['prefix_url'] + env = {} current_entry = {} function append_entry(entry) if entry['series_url'] then - if build_dir .. entry['series_url'] == target_file then + if "out" .. entry['series_url'] == target_file then if not entry['series_prev_url'] then - current_entry = entry['url'] + current_entry = prefix_url .. entry['url'] end - env[entry['url']] = entry + env[prefix_url .. entry['url']] = entry end end end if site_index and site_index[1] then - index = HTML.select_one(page, config['index_selector']) if index then diff --git a/soupault.toml b/soupault.toml index b0b7512..f34810c 100644 --- a/soupault.toml +++ b/soupault.toml @@ -73,7 +73,7 @@ index = true index_first = true dump_json = "test.json" - extract_after_widgets = ["series"] + extract_after_widgets = ["series", "urls-rewriting"] [index.fields.title] selector = ["h1"] @@ -111,6 +111,9 @@ [index.fields.abstract] selector = "#meta-tags .description" +[index.fields.contents] + selector = "main article" + [index.views.tags] section = "posts/" sort_by = "date" @@ -143,4 +146,5 @@ index_selector = "#archives-index" index_full_template_file = "templates/index_archives_full.html" index_short_template_file = "templates/index_archives_short.html" + index_rss_template_file = "templates/index.xml" file = "plugins/archives-index.lua" diff --git a/templates/index.xml b/templates/index.xml new file mode 100644 index 0000000..ecf618e --- /dev/null +++ b/templates/index.xml @@ -0,0 +1,25 @@ + +{% set base = "https://soap.coffee/~lthms" %} + + + Thomas Letan’s Blog + {{ base }} + + Blogposts in Thomas Letan’s Website + + + {% for article in contents %} + + {{ article.title | striptags }} + {{ base }}{{ article.url }} + {{ base }}{{ article.url }} + {{ article.date_str }} + + {% if article.contents %} + {{ article.contents | escape }} + {% endif %} + + + {% endfor %} + + diff --git a/templates/main.html b/templates/main.html index 843f52f..1249ce4 100644 --- a/templates/main.html +++ b/templates/main.html @@ -8,6 +8,7 @@ + -- cgit v1.2.3