Compare commits
11 commits
9b52848707
...
f6e5520873
Author | SHA1 | Date | |
---|---|---|---|
f6e5520873 | |||
63c38e3fec | |||
8686fd9bae | |||
f3e175f2f5 | |||
55a497fe02 | |||
2336656ab8 | |||
2fb681d121 | |||
4628cab3f8 | |||
3e4e3d84d6 | |||
f7cc8e37a1 | |||
704313b5ae |
19 changed files with 210 additions and 45 deletions
2
.editorconfig
Normal file
2
.editorconfig
Normal file
|
@ -0,0 +1,2 @@
|
|||
[*]
|
||||
indent_style = tab
|
3
.luarc.json
Normal file
3
.luarc.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"workspace.checkThirdParty": false
|
||||
}
|
|
@ -15,7 +15,7 @@ dependencies = {
|
|||
"lua-cjson ~> 2.1",
|
||||
"restia",
|
||||
"rgbstr",
|
||||
"scaffold ~> 1.1",
|
||||
"scaffold ~> 1.3.1",
|
||||
"shapeshift ~> 1.1",
|
||||
"skooma",
|
||||
"streamcsv ~> 1.1",
|
||||
|
|
52
build.lua
52
build.lua
|
@ -5,18 +5,27 @@ local scaffold = require 'scaffold'
|
|||
local shapeshift = require 'shapeshift'
|
||||
|
||||
-- Project-specific stuff
|
||||
local rss = require 'feed.rss'
|
||||
local atom = require 'feed.atom'
|
||||
local paramparser = require 'paramparser'
|
||||
local params = paramparser(...)
|
||||
package.loaded.params = params
|
||||
local config = require 'config'
|
||||
local pages = require 'pages'
|
||||
local templates = require 'templates'
|
||||
local posts = require 'posts'
|
||||
|
||||
local tree = {}
|
||||
local output_tree = {}
|
||||
|
||||
for i, path in ipairs(params.copy) do
|
||||
scaffold.deep(tree, path, scaffold.readdir(path))
|
||||
for name, content in pairs(scaffold.readdir("static")) do
|
||||
scaffold.deep(output_tree, name, content)
|
||||
end
|
||||
|
||||
local function is_image(name)
|
||||
if name:downcase():match("^.jpg$") then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
local function render(name, data)
|
||||
|
@ -28,16 +37,39 @@ local function page(name, data)
|
|||
end
|
||||
|
||||
-- Render Posts
|
||||
for idx, post in ipairs(posts) do
|
||||
for _, post in ipairs(posts) do
|
||||
local body = tostring(render("post", post))
|
||||
|
||||
scaffold.deep(tree, post.path, body)
|
||||
scaffold.deep(output_tree, post.path, body)
|
||||
end
|
||||
|
||||
scaffold.deep(output_tree, "feeds/all.rss.xml", rss(posts))
|
||||
scaffold.deep(output_tree, "feeds/all.atom.xml", atom(posts))
|
||||
|
||||
if params.delete then
|
||||
restia.utils.delete(params.output)
|
||||
end
|
||||
|
||||
do -- Copy blog images
|
||||
local function iter_files(tree, callback)
|
||||
if getmetatable(tree) == scaffold.lazy then
|
||||
callback(tree)
|
||||
else
|
||||
for _, node in pairs(tree) do
|
||||
iter_files(node, callback)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
iter_files(scaffold.readdir("posts", {files = "lazy"}), function(file)
|
||||
local name = file.path:match("[^/]+$")
|
||||
if name:find(".jpg$") then
|
||||
local path = "/images/" .. name
|
||||
scaffold.deep(output_tree, path, file)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local function transform(tab)
|
||||
return function(data)
|
||||
local success, result = shapeshift.table(tab, "keep")(data)
|
||||
|
@ -48,7 +80,7 @@ end
|
|||
local function drop() return true, nil end
|
||||
|
||||
-- Generate Post Metadata
|
||||
tree["posts.json"] = json.encode(
|
||||
output_tree["posts.json"] = json.encode(
|
||||
fun
|
||||
.iter(posts)
|
||||
:map(transform {
|
||||
|
@ -58,10 +90,10 @@ tree["posts.json"] = json.encode(
|
|||
:totable()
|
||||
)
|
||||
|
||||
tree["index.html"] = tostring(page("index", tree["posts.json"]))
|
||||
output_tree["index.html"] = tostring(page("index", output_tree["posts.json"]))
|
||||
|
||||
if params.cname then
|
||||
tree.CNAME = params.cname
|
||||
output_tree.CNAME = params.cname
|
||||
end
|
||||
|
||||
scaffold.builddir(params.output, tree)
|
||||
scaffold.builddir(params.output, output_tree)
|
||||
|
|
1
config/description
Normal file
1
config/description
Normal file
|
@ -0,0 +1 @@
|
|||
This is my personal blog with a focus on IT and Programming content unless I have something else to say.
|
2
config/me.yaml
Normal file
2
config/me.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
name: Talia
|
||||
link: https://tech.lgbt/@darkwiiplayer
|
1
config/title
Normal file
1
config/title
Normal file
|
@ -0,0 +1 @@
|
|||
Talia's Blog
|
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
|
35
lib/feed/rss.lua
Normal file
35
lib/feed/rss.lua
Normal file
|
@ -0,0 +1,35 @@
|
|||
local skooma = require 'skooma'
|
||||
local config = require 'config'
|
||||
|
||||
local xml = skooma.env()
|
||||
|
||||
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 tostring(xml.rss{
|
||||
version="2.0";
|
||||
xml.channel {
|
||||
xml.title(config.title);
|
||||
xml.link "https://blog.but.gay/";
|
||||
xml.description(config.description);
|
||||
xml.language "en-uk";
|
||||
xml.lastBuildDate(os.date());
|
||||
map(posts, function(post)
|
||||
local link = "https://blog.but.gay"..post.head.uri
|
||||
return xml.item {
|
||||
xml.title(post.head.title);
|
||||
xml.description(post.head.description);
|
||||
xml.link(link);
|
||||
xml.guid(link);
|
||||
xml.pubDate(os.date("%d %b %Y", post.head.timestamp));
|
||||
}
|
||||
end)
|
||||
}
|
||||
})
|
||||
end
|
|
@ -6,7 +6,6 @@ return function(...)
|
|||
local parse = arrr {
|
||||
{ "Output directory", "--output", "-o", 'directory' };
|
||||
{ "Input directory", "--input", "-i", 'directory' };
|
||||
{ "Copy directory", "--copy", "-c", 'directory', 'repeatable' };
|
||||
{ "Include unpublished posts", "--unpublished", "-u", nil };
|
||||
{ "Set the github pages CNAME", "--cname", nil, 'domain' };
|
||||
{ "Delete everything first", "--delete", "-d" };
|
||||
|
|
|
@ -8,9 +8,9 @@ local string = require 'stringplus'
|
|||
local function parsedate(date)
|
||||
local year, month, day = date:match("(%d+)%-(%d+)%-(%d+)")
|
||||
return os.time {
|
||||
year = tonumber(year);
|
||||
month = tonumber(month);
|
||||
day = tonumber(day);
|
||||
year = tonumber(year) or error("Invalid date string: " .. date);
|
||||
month = tonumber(month) or error("Invalid date string: " .. date);
|
||||
day = tonumber(day) or error("Invalid date string: " .. date);
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -27,11 +27,18 @@ end
|
|||
|
||||
local function read_post(file)
|
||||
local content = io.open(file):read("*a")
|
||||
local head, body = restia.utils.frontmatter(content)
|
||||
return {
|
||||
head = head and yaml.load(head) or {};
|
||||
body = cmark.render_html(cmark.parse_document(body, #body, cmark.OPT_DEFAULT), cmark.OPT_DEFAULT + cmark.OPT_UNSAFE);
|
||||
}
|
||||
local head_text, body_text = restia.utils.frontmatter(content)
|
||||
|
||||
local head = head_text and yaml.load(head_text) or {}
|
||||
local body = cmark.render_html(cmark.parse_document(body_text, #body_text, cmark.OPT_DEFAULT), cmark.OPT_DEFAULT + cmark.OPT_UNSAFE)
|
||||
|
||||
local cover_image = file:gsub("md$", "jpg")
|
||||
if io.open(cover_image) then
|
||||
head.cover_image = "/images/" .. cover_image:match("[^/]+$")
|
||||
print(head.cover_image)
|
||||
end
|
||||
|
||||
return { head = head, body = body }
|
||||
end
|
||||
|
||||
local posts = {}
|
||||
|
@ -49,7 +56,7 @@ for file in restia.utils.files(params.input, "^./posts/.*%.md$") do
|
|||
post.head.tags = string.split(post.head.tags, "[%a-]+")
|
||||
end
|
||||
|
||||
for key, tag in ipairs(post.head.tags) do
|
||||
for key, tag in ipairs(post.head.tags or {}) do
|
||||
post.head.tags[key] = string.lower(tag)
|
||||
end
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ return function(tags)
|
|||
end
|
||||
return {
|
||||
html.flexRow(list);
|
||||
html.verticalSpacer();
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,14 +7,23 @@ post = =>
|
|||
color = table.concat({rgbstr.bytes(@head.tags[1], 16, .3, .5)}, " ")
|
||||
flexColumn class: "info box", style: "--color: rgb(#{color})"
|
||||
* h2 a(@head.title, href: @head.uri), style: "view-transition-name: #{@head.slug}"
|
||||
* small time is: 'local-date', datetime: @head.date, @head.date
|
||||
* p @head.description
|
||||
* tags(@head.tags)
|
||||
* time is: 'local-date', datetime: @head.date, @head.date
|
||||
* @head.description
|
||||
|
||||
slots.head title "Index"
|
||||
slots.head title "Talia's Blog"
|
||||
|
||||
slots.head
|
||||
* meta property: "og:title", content: "Index"
|
||||
* meta property: "og:site_name", content: "Talia's Blog"
|
||||
* meta property: "og:description", content: "This is my personal blog with a focus on IT and Programming content unless I have something else to say."
|
||||
* meta property: "og:type", content: "website"
|
||||
* meta property: "og:article:author", content: "Talia"
|
||||
|
||||
slots.head script type: 'module', src: "/javascript/LocalDate.js"
|
||||
slots.head script type: 'module', src: "/javascript/BlogPost.js"
|
||||
|
||||
return main
|
||||
return article
|
||||
class: "content-width"
|
||||
* h1 "Blog Posts"
|
||||
* [blogPost post p for p in *posts]
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
@import url('https://cdn.jsdelivr.net/gh/darkwiiplayer/css@main/all.css') layer(framework);
|
||||
@import url('https://cdn.jsdelivr.net/gh/darkwiiplayer/css@main/drop-in.css') layer(framework);
|
||||
|
||||
blog-post[hidden] {
|
||||
display: none;
|
||||
}
|
|
@ -25,7 +25,7 @@ task.build {
|
|||
[[
|
||||
export LUA_PATH='%s'
|
||||
export LUA_CPATH='%s'
|
||||
lua build.lua --copy css --copy javascript --output blog --cname blog.but.gay
|
||||
lua build.lua --output blog --cname blog.but.gay
|
||||
]],
|
||||
path, cpath
|
||||
)
|
||||
|
@ -40,8 +40,8 @@ task.deploy {
|
|||
find . | treh -c
|
||||
git add --all
|
||||
if git log -1 --format=%s | grep "$hash$"
|
||||
then git commit --amend --no-edit
|
||||
else git commit -m "Update blog to $hash"
|
||||
then git commit --no-verify --amend --no-edit
|
||||
else git commit --no-verify -m "Update blog to $hash"
|
||||
fi
|
||||
git push --force origin page
|
||||
cd ../
|
||||
|
|
|
@ -2,18 +2,37 @@ import output from require 'params'
|
|||
import slotty from require 'skooma'
|
||||
import 'config'
|
||||
|
||||
slots = slotty!
|
||||
|
||||
styles = [[
|
||||
@import url('https://fonts.googleapis.com/css2?family=Raleway&display=swap');
|
||||
@import url('https://fonts.googleapis.com/css2?family=Open+Sans&display=swap');
|
||||
@import url('https://fonts.googleapis.com/css2?family=Fira+Code&display=swap');
|
||||
|
||||
@view-transition { navigation: auto; }
|
||||
|
||||
:root { container: style; }
|
||||
:is(h1, h2, h3, h4, h5, h6) { font-family: "Raleway", sans-serif; }
|
||||
:is(code, kbd, var, samp) { font-family: "Fira Code", monospace; }
|
||||
.badge { font-family: "Open Sans", sans-serif }
|
||||
]]
|
||||
|
||||
slots = slotty!
|
||||
slots.footer aside id: "contact"
|
||||
* h2 "Social"
|
||||
* p
|
||||
* "Got feedback? — Tag me on fedi!"
|
||||
* br
|
||||
* a "@darkwiiplayer@tech.lgbt", href: 'https://tech.lgbt/@darkwiiplayer', rel: 'me'
|
||||
|
||||
slots.footer aside id: "git"
|
||||
* h2 "Git"
|
||||
* ul
|
||||
* li a "Github", href: "https://github.com/darkwiiplayer"
|
||||
* li a "Forgejo", href: "https://git.but.gay/darkwiiplayer"
|
||||
|
||||
slots.footer aside id: "platforms"
|
||||
* h2 "Federated cloud"
|
||||
* p "darkwiiplayer@cloud.but.gay"
|
||||
|
||||
css = =>
|
||||
link rel: 'stylesheet', href: @
|
||||
|
@ -22,11 +41,11 @@ content, data = select 1, ...
|
|||
html
|
||||
lang: "english"
|
||||
* head
|
||||
* 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 charset: "UTF-8"
|
||||
* meta name: "viewport", content: "width=device-width"
|
||||
* css 'https://darkwiiplayer.github.io/css/all.css'
|
||||
* css 'https://darkwiiplayer.github.io/css/schemes/talia.css'
|
||||
* css "/css/site.css"
|
||||
* style styles
|
||||
* slots.head
|
||||
|
@ -35,14 +54,11 @@ html
|
|||
* slots.top
|
||||
* header class: 'sticky', style: "view-transition-name: header"
|
||||
* h1 "Talia's Blog"
|
||||
* nav { class: 'right bar' }
|
||||
* nav { class: 'right underlined bar' }
|
||||
* ul li a "Home", href: "/"
|
||||
* main
|
||||
* content slots, data
|
||||
* ->
|
||||
if #slots.footer > 0
|
||||
footer class: "box"
|
||||
* gridBox columns: math.min(#slots.footer, 3), class: 'content-padding'
|
||||
* slots.footer
|
||||
else
|
||||
{}
|
||||
footer class: "box"
|
||||
* gridBox columns: math.min(#slots.footer, 3), class: 'content-padding'
|
||||
* slots.footer
|
||||
|
|
|
@ -29,7 +29,7 @@ positions = (input, character) ->
|
|||
|
||||
breadcrumb = (href) -> li a :href, href\match('[^/]+$'), tabindex: 0
|
||||
|
||||
if src = post.head.cover_image
|
||||
if src := post.head.cover_image
|
||||
slots.top pageHero cover: 60
|
||||
* img :src, style: 'opacity: .4'
|
||||
* h1(post.head.title, style: "view-transition-name: #{post.head.slug}")
|
||||
|
@ -41,7 +41,7 @@ else
|
|||
slots.summary div post.head.description, class: "summary", tabindex: 0
|
||||
slots.summary verticalSpacer
|
||||
|
||||
slots.banner aside class: { 'box' }
|
||||
slots.banner aside class: { 'floating box' }, stripe: "rebeccapurple"
|
||||
* b "Hey there!"
|
||||
* p raw [[
|
||||
This blog doesn't use any tracking. When you open this page, I don't see
|
||||
|
@ -51,10 +51,6 @@ slots.banner aside class: { 'box' }
|
|||
]]
|
||||
* p i "Thank you."
|
||||
|
||||
slots.footer aside id: "contact"
|
||||
* p raw "Got feedback?<br>Tag me on fedi!"
|
||||
* a "@darkwiiplayer@tech.lgbt", href: 'https://tech.lgbt/@darkwiiplayer'
|
||||
|
||||
return (=>@)
|
||||
* article
|
||||
* slots.title
|
||||
|
|
Loading…
Reference in a new issue