Style refactor and per-post images
This commit is contained in:
parent
f3e175f2f5
commit
8686fd9bae
13 changed files with 62 additions and 31 deletions
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",
|
"lua-cjson ~> 2.1",
|
||||||
"restia",
|
"restia",
|
||||||
"rgbstr",
|
"rgbstr",
|
||||||
"scaffold ~> 1.1",
|
"scaffold ~> 1.3.1",
|
||||||
"shapeshift ~> 1.1",
|
"shapeshift ~> 1.1",
|
||||||
"skooma",
|
"skooma",
|
||||||
"streamcsv ~> 1.1",
|
"streamcsv ~> 1.1",
|
||||||
|
|
51
build.lua
51
build.lua
|
@ -10,15 +10,22 @@ 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
|
||||||
local config = require 'config'
|
|
||||||
local pages = require 'pages'
|
local pages = require 'pages'
|
||||||
local templates = require 'templates'
|
local templates = require 'templates'
|
||||||
local posts = require 'posts'
|
local posts = require 'posts'
|
||||||
|
|
||||||
local tree = {}
|
local output_tree = {}
|
||||||
|
|
||||||
for i, path in ipairs(params.copy) do
|
for name, content in pairs(scaffold.readdir("static")) do
|
||||||
scaffold.deep(tree, path, scaffold.readdir(path))
|
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
|
end
|
||||||
|
|
||||||
local function render(name, data)
|
local function render(name, data)
|
||||||
|
@ -30,19 +37,39 @@ local function page(name, data)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Render Posts
|
-- Render Posts
|
||||||
for idx, post in ipairs(posts) do
|
for _, post in ipairs(posts) do
|
||||||
local body = tostring(render("post", post))
|
local body = tostring(render("post", post))
|
||||||
|
|
||||||
scaffold.deep(tree, post.path, body)
|
scaffold.deep(output_tree, post.path, body)
|
||||||
end
|
end
|
||||||
|
|
||||||
scaffold.deep(tree, "feeds/all.rss.xml", rss(posts))
|
scaffold.deep(output_tree, "feeds/all.rss.xml", rss(posts))
|
||||||
scaffold.deep(tree, "feeds/all.atom.xml", atom(posts))
|
scaffold.deep(output_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)
|
||||||
end
|
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)
|
local function transform(tab)
|
||||||
return function(data)
|
return function(data)
|
||||||
local success, result = shapeshift.table(tab, "keep")(data)
|
local success, result = shapeshift.table(tab, "keep")(data)
|
||||||
|
@ -53,7 +80,7 @@ end
|
||||||
local function drop() return true, nil end
|
local function drop() return true, nil end
|
||||||
|
|
||||||
-- Generate Post Metadata
|
-- Generate Post Metadata
|
||||||
tree["posts.json"] = json.encode(
|
output_tree["posts.json"] = json.encode(
|
||||||
fun
|
fun
|
||||||
.iter(posts)
|
.iter(posts)
|
||||||
:map(transform {
|
:map(transform {
|
||||||
|
@ -63,10 +90,10 @@ tree["posts.json"] = json.encode(
|
||||||
:totable()
|
: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
|
if params.cname then
|
||||||
tree.CNAME = params.cname
|
output_tree.CNAME = params.cname
|
||||||
end
|
end
|
||||||
|
|
||||||
scaffold.builddir(params.output, tree)
|
scaffold.builddir(params.output, output_tree)
|
||||||
|
|
|
@ -6,7 +6,6 @@ return function(...)
|
||||||
local parse = arrr {
|
local parse = arrr {
|
||||||
{ "Output directory", "--output", "-o", 'directory' };
|
{ "Output directory", "--output", "-o", 'directory' };
|
||||||
{ "Input directory", "--input", "-i", 'directory' };
|
{ "Input directory", "--input", "-i", 'directory' };
|
||||||
{ "Copy directory", "--copy", "-c", 'directory', 'repeatable' };
|
|
||||||
{ "Include unpublished posts", "--unpublished", "-u", nil };
|
{ "Include unpublished posts", "--unpublished", "-u", nil };
|
||||||
{ "Set the github pages CNAME", "--cname", nil, 'domain' };
|
{ "Set the github pages CNAME", "--cname", nil, 'domain' };
|
||||||
{ "Delete everything first", "--delete", "-d" };
|
{ "Delete everything first", "--delete", "-d" };
|
||||||
|
|
|
@ -8,9 +8,9 @@ local string = require 'stringplus'
|
||||||
local function parsedate(date)
|
local function parsedate(date)
|
||||||
local year, month, day = date:match("(%d+)%-(%d+)%-(%d+)")
|
local year, month, day = date:match("(%d+)%-(%d+)%-(%d+)")
|
||||||
return os.time {
|
return os.time {
|
||||||
year = tonumber(year);
|
year = tonumber(year) or error("Invalid date string: " .. date);
|
||||||
month = tonumber(month);
|
month = tonumber(month) or error("Invalid date string: " .. date);
|
||||||
day = tonumber(day);
|
day = tonumber(day) or error("Invalid date string: " .. date);
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ return function(tags)
|
||||||
end
|
end
|
||||||
return {
|
return {
|
||||||
html.flexRow(list);
|
html.flexRow(list);
|
||||||
html.verticalSpacer();
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,9 +7,9 @@ post = =>
|
||||||
color = table.concat({rgbstr.bytes(@head.tags[1], 16, .3, .5)}, " ")
|
color = table.concat({rgbstr.bytes(@head.tags[1], 16, .3, .5)}, " ")
|
||||||
flexColumn class: "info box", style: "--color: rgb(#{color})"
|
flexColumn class: "info box", style: "--color: rgb(#{color})"
|
||||||
* h2 a(@head.title, href: @head.uri), style: "view-transition-name: #{@head.slug}"
|
* 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)
|
* tags(@head.tags)
|
||||||
* time is: 'local-date', datetime: @head.date, @head.date
|
|
||||||
* @head.description
|
|
||||||
|
|
||||||
slots.head title "Talia's Blog"
|
slots.head title "Talia's Blog"
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ slots.head
|
||||||
slots.head script type: 'module', src: "/javascript/LocalDate.js"
|
slots.head script type: 'module', src: "/javascript/LocalDate.js"
|
||||||
slots.head script type: 'module', src: "/javascript/BlogPost.js"
|
slots.head script type: 'module', src: "/javascript/BlogPost.js"
|
||||||
|
|
||||||
return main
|
return article
|
||||||
class: "content-width"
|
class: "content-width"
|
||||||
* h1 "Blog Posts"
|
* h1 "Blog Posts"
|
||||||
* [blogPost post p for p in *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] {
|
blog-post[hidden] {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
|
@ -25,7 +25,7 @@ task.build {
|
||||||
[[
|
[[
|
||||||
export LUA_PATH='%s'
|
export LUA_PATH='%s'
|
||||||
export LUA_CPATH='%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
|
path, cpath
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,19 +2,21 @@ import output from require 'params'
|
||||||
import slotty from require 'skooma'
|
import slotty from require 'skooma'
|
||||||
import 'config'
|
import 'config'
|
||||||
|
|
||||||
|
slots = slotty!
|
||||||
|
|
||||||
styles = [[
|
styles = [[
|
||||||
@import url('https://fonts.googleapis.com/css2?family=Raleway&display=swap');
|
@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=Open+Sans&display=swap');
|
||||||
@import url('https://fonts.googleapis.com/css2?family=Fira+Code&display=swap');
|
@import url('https://fonts.googleapis.com/css2?family=Fira+Code&display=swap');
|
||||||
|
|
||||||
|
@view-transition { navigation: auto; }
|
||||||
|
|
||||||
:root { container: style; }
|
:root { container: style; }
|
||||||
:is(h1, h2, h3, h4, h5, h6) { font-family: "Raleway", sans-serif; }
|
:is(h1, h2, h3, h4, h5, h6) { font-family: "Raleway", sans-serif; }
|
||||||
:is(code, kbd, var, samp) { font-family: "Fira Code", monospace; }
|
:is(code, kbd, var, samp) { font-family: "Fira Code", monospace; }
|
||||||
.badge { font-family: "Open Sans", sans-serif }
|
.badge { font-family: "Open Sans", sans-serif }
|
||||||
]]
|
]]
|
||||||
|
|
||||||
slots = slotty!
|
|
||||||
|
|
||||||
slots.footer aside id: "contact"
|
slots.footer aside id: "contact"
|
||||||
* h2 "Social"
|
* h2 "Social"
|
||||||
* p
|
* p
|
||||||
|
@ -26,7 +28,7 @@ slots.footer aside id: "git"
|
||||||
* h2 "Git"
|
* h2 "Git"
|
||||||
* ul
|
* ul
|
||||||
* li a "Github", href: "https://github.com/darkwiiplayer"
|
* li a "Github", href: "https://github.com/darkwiiplayer"
|
||||||
* li a "Gitea", href: "https://git.but.gay/darkwiiplayer"
|
* li a "Forgejo", href: "https://git.but.gay/darkwiiplayer"
|
||||||
|
|
||||||
slots.footer aside id: "platforms"
|
slots.footer aside id: "platforms"
|
||||||
* h2 "Federated cloud"
|
* h2 "Federated cloud"
|
||||||
|
@ -44,8 +46,6 @@ html
|
||||||
* 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"
|
||||||
* css 'https://darkwiiplayer.github.io/css/all.css'
|
|
||||||
* css 'https://darkwiiplayer.github.io/css/schemes/talia.css'
|
|
||||||
* css "/css/site.css"
|
* css "/css/site.css"
|
||||||
* style styles
|
* style styles
|
||||||
* slots.head
|
* slots.head
|
||||||
|
@ -54,7 +54,7 @@ html
|
||||||
* slots.top
|
* slots.top
|
||||||
* header class: 'sticky', style: "view-transition-name: header"
|
* header class: 'sticky', style: "view-transition-name: header"
|
||||||
* h1 "Talia's Blog"
|
* h1 "Talia's Blog"
|
||||||
* nav { class: 'right bar' }
|
* nav { class: 'right underlined bar' }
|
||||||
* ul li a "Home", href: "/"
|
* ul li a "Home", href: "/"
|
||||||
* main
|
* main
|
||||||
* content slots, data
|
* content slots, data
|
||||||
|
|
|
@ -41,7 +41,7 @@ else
|
||||||
slots.summary div post.head.description, class: "summary", tabindex: 0
|
slots.summary div post.head.description, class: "summary", tabindex: 0
|
||||||
slots.summary verticalSpacer
|
slots.summary verticalSpacer
|
||||||
|
|
||||||
slots.banner aside class: { 'box' }
|
slots.banner aside class: { 'floating box' }, stripe: "rebeccapurple"
|
||||||
* b "Hey there!"
|
* b "Hey there!"
|
||||||
* p raw [[
|
* p raw [[
|
||||||
This blog doesn't use any tracking. When you open this page, I don't see
|
This blog doesn't use any tracking. When you open this page, I don't see
|
||||||
|
|
Loading…
Reference in a new issue