From 5d2f6c6b3a02b25d1ec81fc6fcfe23fa3236fc02 Mon Sep 17 00:00:00 2001 From: bie Date: Fri, 4 Aug 2017 06:53:05 +0000 Subject: uhm --- maker | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/maker b/maker index c0ae292..1109dfe 100755 --- a/maker +++ b/maker @@ -61,7 +61,7 @@ for n=1,8 do local data = lupin.transform(files[n], "later", false, "full") local slug = posix.basename(files[n]):gsub(".txt$", "") data.path = posix.dirname(files[n]):gsub("^" .. config.src, "") - data.url = config.base .. "/" .. data.path .. "/" .. slug + data.url = config.base .. data.path .. "/" .. slug if config.extension then data.url = data.url .. config.extension end @@ -82,3 +82,37 @@ for i, page in ipairs(config.static) do build(path, page.template, data) end +local archive = "find %s -perm /o+r -readable -not -iname '*~' -not -path '%s' -type d | sort -n" +local files = {} +for raw in io.popen(archive:format(config.src, config.src)):read("*a"):gmatch("[^\n]+") do + local original = lfs.currentdir() + lfs.chdir(raw) + + local page = {} + page.site = config + page.articles = {} + + local finder = "find . -perm /o+r -readable -not -iname '*~' -type f | sort -rn" + local nposts = 0 + for file in io.popen(finder:format(config.src)):read("*a"):gmatch("[^\n]+") do + local data = lupin.transform(file, "later", false, "full") + local slug = posix.basename(file):gsub(".txt$", "") + + data.path = posix.dirname(file):gsub("^" .. config.src, "") + data.url = config.base .. data.path .. "/" .. slug + if config.extension then + data.url = data.url .. config.extension + end + + nposts = nposts + 1 + table.insert(page.articles, data) + end + lfs.chdir(original) + if nposts > 0 then + local apath = raw:gsub("^" .. config.src, "") + local path = config.www .. "/" .. apath .. "/index.html" + build(path, "index", page) + end +end + + -- cgit v1.0