From 241cffabb7ce2b9175c752f35d1a1865bd7f82a0 Mon Sep 17 00:00:00 2001 From: bie Date: Fri, 4 Aug 2017 16:27:02 +0900 Subject: fuchhhh --- config.def.lua | 16 +++---- maker | 114 ++++++++++++++++++++++++++++++++++++++++++++----- templates/archive.html | 18 ++++++++ templates/index.html | 14 +++--- templates/layout.html | 31 +++++++++++--- templates/yearly.html | 11 +++++ 6 files changed, 174 insertions(+), 30 deletions(-) create mode 100644 templates/archive.html create mode 100644 templates/yearly.html diff --git a/config.def.lua b/config.def.lua index 6b251c5..67e5d95 100644 --- a/config.def.lua +++ b/config.def.lua @@ -1,15 +1,11 @@ -config.title = "~maker~" +config.title = "radionova" -config.templates = "templates" -config.blueprints = "blueprints" -config.src = "artikler" -config.www = "www" +config.templates = "nova" +config.blueprints = "/srv/www/tears/blueprints" +config.src = "/srv/www/tears/artikler" +config.www = "/home/bie/www/nova" config.date = "%A %d. %B %Y, kl. %H.%M" -config.base = "http://localhost/" +config.base = "/~bie/nova" config.extension = ".html" -config.static = { - { src = 'sendeplan.yaml', template = 'sendeplan', path = 'sendeplan.html' } -} - diff --git a/maker b/maker index c6ae2fa..412dc10 100755 --- a/maker +++ b/maker @@ -51,23 +51,59 @@ for n, src in ipairs(files) do end end +function dirtodata(dir, files) + local data = {} + data.slug = dir:gsub("^" .. config.src, ""):gsub("^/", "") + data.path = config.www .. "/" .. data.slug .. "/index.html" + data.articles = files + data.url = config.base .. "/" .. data.slug + if data.slug:match("^%d+$") then + data.collection = "year" + data.template = "yearly" + elseif data.slug:match("^%d+/%d+$") then + data.collection = "month" + data.template = "archive" + else + data.collection = "day" + data.template = "archive" + end + return data +end + +function filetodata(file) + local data = lupin.transform(file, "later", false, "full") + data.slug = posix.basename(file):gsub(".txt$", "") + data.path = posix.dirname(file):gsub("^" .. config.src, "") + data.url = config.base .. "/" .. data.path .. "/" .. data.slug + data.archive = posix.dirname(posix.dirname(file)) + if config.extension then + data.url = data.url .. config.extension + end + return data +end + local path = config.www .. "/" .. "index.html" local page = {} page.site = config page.articles = {} -for n=1,8 do +local more = false +for n=1,6 do if files[n] then - local data - 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 - if config.extension then - data.url = data.url .. config.extension - end + local data = filetodata(files[n]) table.insert(page.articles, data) + if files[n + 1] then + more = files[n + 1] + else + more = false + end + else + more = false end end +if more then + page.next = filetodata(more) +end +build(path, "index", page) for i, page in ipairs(config.static) do local path = config.www .. "/" .. page.path @@ -81,4 +117,62 @@ for i, page in ipairs(config.static) do build(path, page.template, data) end -build(path, "index", page) +-- archive time! +local finder = "find %s -perm /o+r -readable -not -iname '*~' -type d | sort -n" + +local yearly = {} +local monthly = {} +local daily = {} + +for dir in io.popen(finder:format(config.src)):read("*a"):gmatch("[^\n]+") do + if dir ~= config.src then + local finder = "find %s -perm /o+r -readable -not -iname '*~' -type f | sort -rn" + local files = {} + for file in io.popen(finder:format(dir)):read("*a"):gmatch("[^\n]+") do + table.insert(files, filetodata(file)) + end + if #files > 0 then + local data = dirtodata(dir, files) + if data.collection == "year" then + table.insert(yearly, data) + elseif data.collection == "month" then + table.insert(monthly, data) + elseif data.collection == "day" then + table.insert(daily, data) + else + print(data.collection) + end + end + end +end + +for i,dir in ipairs(yearly) do + if i > 1 then + dir.prevarchive = yearly[i - 1] + end + if yearly[i + 1] then + dir.nextarchive = yearly[i + 1] + end + build(dir.path, dir.template, dir) +end + +for i,dir in ipairs(monthly) do + if i > 1 then + dir.prevarchive = monthly[i - 1] + end + if monthly[i + 1] then + dir.nextarchive = monthly[i + 1] + end + build(dir.path, dir.template, dir) +end + +for i,dir in ipairs(daily) do + if i > 1 then + dir.prevarchive = daily[i - 1] + end + if daily[i + 1] then + dir.nextarchive = daily[i + 1] + end + build(dir.path, dir.template, dir) +end + diff --git a/templates/archive.html b/templates/archive.html new file mode 100644 index 0000000..97103b2 --- /dev/null +++ b/templates/archive.html @@ -0,0 +1,18 @@ +{{#articles}} +
+
+

{{title}}

+

posted {{date}}, by {{author}} +

+ {{&text}} +
+{{/articles}} + +{{#prevarchive}} +

Previous: {{slug}}: {{url}} +{{/prevarchive}} + +{{#nextarchive}} +

Next: {{slug}}: {{url}} +{{/nextarchive}} + diff --git a/templates/index.html b/templates/index.html index 4695387..c275df3 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,10 +1,14 @@ {{#articles}}

-

{{title}}

-

posted {{date}} by {{author}} - {{#lead}} -

{{lead}} - {{/lead}} +

+

{{title}}

+

posted {{date}}, by {{author}} +

+ {{&text}}
{{/articles}} +{{#next}} +

More +{{/next}} + diff --git a/templates/layout.html b/templates/layout.html index 7937763..3aeaa54 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -1,14 +1,35 @@ - + + + + + + +{{#image}} + +{{/image}} +{{^image}} + +{{/image}} + +{{#title}} +{{title}} ยท {{site.title}} +{{/title}} +{{^title}} {{site.title}} - - - - +{{/title}} +

{{site.title}}

+ +
{{&_}}
diff --git a/templates/yearly.html b/templates/yearly.html new file mode 100644 index 0000000..8fd8b8c --- /dev/null +++ b/templates/yearly.html @@ -0,0 +1,11 @@ +{{#articles}} +
+
+

{{title}}

+
+
+{{/articles}} + +{{#prevarchive}} +lol +{{/prevarchive}} -- cgit v1.0