Add atom feed too because cool
This commit is contained in:
parent
4628cab3f8
commit
2fb681d121
5 changed files with 65 additions and 5 deletions
|
@ -6,6 +6,7 @@ local shapeshift = require 'shapeshift'
|
||||||
|
|
||||||
-- Project-specific stuff
|
-- Project-specific stuff
|
||||||
local rss = require 'feed.rss'
|
local rss = require 'feed.rss'
|
||||||
|
local atom = require 'feed.atom'
|
||||||
local paramparser = require 'paramparser'
|
local paramparser = require 'paramparser'
|
||||||
local params = paramparser(...)
|
local params = paramparser(...)
|
||||||
package.loaded.params = params
|
package.loaded.params = params
|
||||||
|
@ -36,6 +37,7 @@ for idx, post in ipairs(posts) do
|
||||||
end
|
end
|
||||||
|
|
||||||
scaffold.deep(tree, "feeds/all.rss.xml", rss(posts))
|
scaffold.deep(tree, "feeds/all.rss.xml", rss(posts))
|
||||||
|
scaffold.deep(tree, "feeds/all.atom.xml", atom(posts))
|
||||||
|
|
||||||
if params.delete then
|
if params.delete then
|
||||||
restia.utils.delete(params.output)
|
restia.utils.delete(params.output)
|
||||||
|
|
2
config/me.yaml
Normal file
2
config/me.yaml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
name: Talia
|
||||||
|
link: https://tech.lgbt/@darkwiiplayer
|
60
lib/feed/atom.lua
Normal file
60
lib/feed/atom.lua
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
local skooma = require 'skooma'
|
||||||
|
local config = require 'config'
|
||||||
|
|
||||||
|
local xml = skooma.env()
|
||||||
|
|
||||||
|
local rfc3339 = "%Y-%m-%dT%H:%M:%SZ"
|
||||||
|
|
||||||
|
local function map(sequence, fun)
|
||||||
|
local new = {}
|
||||||
|
for key, value in ipairs(sequence) do
|
||||||
|
new[key] = fun(value)
|
||||||
|
end
|
||||||
|
return new
|
||||||
|
end
|
||||||
|
|
||||||
|
return function(posts)
|
||||||
|
return [[<?xml version="1.0" encoding="utf-8"?>]] .. tostring(xml.feed{
|
||||||
|
xmlns="http://www.w3.org/2005/Atom";
|
||||||
|
xml.id("https://blog.but.gay/");
|
||||||
|
xml.title(config.title:gsub("\n$", ""));
|
||||||
|
xml.link { rel="alternate", href = "https://blog.but.gay/", type="text/html" };
|
||||||
|
xml.link { rel="self", href = "https://blog.but.gay/feeds/all.atom.xml" };
|
||||||
|
xml.updated(os.date(rfc3339));
|
||||||
|
xml.author(
|
||||||
|
xml.name(config.me.name),
|
||||||
|
xml.uri(config.me.link)
|
||||||
|
);
|
||||||
|
xml.generator {
|
||||||
|
uri = "https://github.com/darkwiiplayer/blog";
|
||||||
|
"Home-grown SSG"
|
||||||
|
};
|
||||||
|
--xml.description(config.description);
|
||||||
|
map(posts, function(post)
|
||||||
|
local link = "https://blog.but.gay"..post.head.uri
|
||||||
|
return xml.entry {
|
||||||
|
xml.id(link);
|
||||||
|
xml.title(post.head.title);
|
||||||
|
function()
|
||||||
|
if post.head.updates then
|
||||||
|
return xml.updated(os.date(rfc3339, post.head.updates[#post.head.updates]));
|
||||||
|
else
|
||||||
|
return xml.updated(os.date(rfc3339, post.head.timestamp));
|
||||||
|
end
|
||||||
|
end;
|
||||||
|
--
|
||||||
|
xml.summary(post.head.description);
|
||||||
|
xml.content {
|
||||||
|
type="html";
|
||||||
|
post.body;
|
||||||
|
};
|
||||||
|
xml.link { href = link };
|
||||||
|
--
|
||||||
|
xml.published(os.date(rfc3339, post.head.timestamp));
|
||||||
|
map(post.head.tags, function(tag)
|
||||||
|
return xml.category { term = tag }
|
||||||
|
end)
|
||||||
|
}
|
||||||
|
end)
|
||||||
|
})
|
||||||
|
end
|
|
@ -14,7 +14,6 @@ end
|
||||||
return function(posts)
|
return function(posts)
|
||||||
return tostring(xml.rss{
|
return tostring(xml.rss{
|
||||||
version="2.0";
|
version="2.0";
|
||||||
["xmlns:atom"]="http://www.w3.org/2005/Atom";
|
|
||||||
xml.channel {
|
xml.channel {
|
||||||
xml.title(config.title);
|
xml.title(config.title);
|
||||||
xml.link "https://blog.but.gay/";
|
xml.link "https://blog.but.gay/";
|
||||||
|
@ -26,10 +25,6 @@ return function(posts)
|
||||||
return xml.item {
|
return xml.item {
|
||||||
xml.title(post.head.title);
|
xml.title(post.head.title);
|
||||||
xml.description(post.head.description);
|
xml.description(post.head.description);
|
||||||
xml.content {
|
|
||||||
type="html";
|
|
||||||
post.body;
|
|
||||||
};
|
|
||||||
xml.link(link);
|
xml.link(link);
|
||||||
xml.guid(link);
|
xml.guid(link);
|
||||||
xml.pubDate(os.date("%d %b %Y", post.head.timestamp));
|
xml.pubDate(os.date("%d %b %Y", post.head.timestamp));
|
||||||
|
|
|
@ -40,6 +40,7 @@ html
|
||||||
lang: "english"
|
lang: "english"
|
||||||
* head
|
* head
|
||||||
* link rel: 'alternate', type: 'application/rss+xml', title: 'RSS 2.0 feed', href: "/feeds/all.rss.xml"
|
* link rel: 'alternate', type: 'application/rss+xml', title: 'RSS 2.0 feed', href: "/feeds/all.rss.xml"
|
||||||
|
* link rel: 'alternate', type: 'application/atom+xml', title: 'Atom feed', href: "/feeds/all.atom.xml"
|
||||||
* meta name: "view-transition", content: "same-origin"
|
* meta name: "view-transition", content: "same-origin"
|
||||||
* meta charset: "UTF-8"
|
* meta charset: "UTF-8"
|
||||||
* meta name: "viewport", content: "width=device-width"
|
* meta name: "viewport", content: "width=device-width"
|
||||||
|
|
Loading…
Reference in a new issue