summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Letan <lthms@soap.coffee>2023-05-13 15:31:10 +0200
committerThomas Letan <lthms@soap.coffee>2023-05-13 15:31:10 +0200
commit3314559176aa2804a76b63c998c606853e39fa2c (patch)
tree5883110db19c85228991599284a7d1ab0b6d9cd8
parentSwitch to googlecode theme (diff)
RSS feed finally!
-rw-r--r--plugins/archives-index.lua7
-rw-r--r--plugins/series-index.lua9
-rw-r--r--soupault.toml6
-rw-r--r--templates/index.xml25
-rw-r--r--templates/main.html1
5 files changed, 43 insertions, 5 deletions
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 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+{% set base = "https://soap.coffee/~lthms" %}
+<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
+ <channel>
+ <title>Thomas Letan’s Blog</title>
+ <link>{{ base }}</link>
+ <description>
+ Blogposts in Thomas Letan’s Website
+ </description>
+ <atom:link href="https://soap.coffee/~lthms/posts/index.xml" rel="self" type="application/rss+xml" />
+ {% for article in contents %}
+ <item>
+ <title>{{ article.title | striptags }}</title>
+ <link>{{ base }}{{ article.url }}</link>
+ <guid>{{ base }}{{ article.url }}</guid>
+ <pubDate>{{ article.date_str }}</pubDate>
+ <description>
+ {% if article.contents %}
+ {{ article.contents | escape }}
+ {% endif %}
+ </description>
+ </item>
+ {% endfor %}
+ </channel>
+</rss>
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 @@
<meta name="twitter:creator" content="@_lthms_" />
<link href="https://soap.coffee/+vendor/katex/0.16.4/katex.min.css" rel="stylesheet" media="none" onload="if(media!='all')media='all'">
<link href="/styles/highlight.css" rel="stylesheet">
+ <link rel="alternate" type="application/rss+xml" title="RSS" href="/posts/index.xml">
<style> /* set automatically, see soupault.toml */ </style>
</head>
<body>