summaryrefslogtreecommitdiff
path: root/maker
diff options
context:
space:
mode:
Diffstat (limited to 'maker')
-rwxr-xr-xmaker36
1 files changed, 34 insertions, 2 deletions
diff --git a/maker b/maker
index c6ae2fa..a00efdb 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
@@ -81,4 +81,36 @@ for i, page in ipairs(config.static) do
build(path, page.template, data)
end
-build(path, "index", page)
+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
+