diff options
-rw-r--r-- | config.def.lua | 16 | ||||
-rwxr-xr-x | maker | 114 | ||||
-rw-r--r-- | templates/archive.html | 18 | ||||
-rw-r--r-- | templates/index.html | 14 | ||||
-rw-r--r-- | templates/layout.html | 31 | ||||
-rw-r--r-- | templates/yearly.html | 11 |
6 files changed, 174 insertions, 30 deletions
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' } -} - @@ -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}} + <article> + <header> + <h2><a href='{{url}}'>{{title}}</a></h2> + <p>posted {{date}}, by {{author}} + </header> + {{&text}} + </article> +{{/articles}} + +{{#prevarchive}} +<p>Previous: {{slug}}: {{url}} +{{/prevarchive}} + +{{#nextarchive}} +<p>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}} <article> - <h2><a href='{{url}}'>{{title}}</a></h2> - <p>posted {{date}} by {{author}} - {{#lead}} - <p class=lead>{{lead}} - {{/lead}} + <header> + <h2><a href='{{url}}'>{{title}}</a></h2> + <p>posted {{date}}, by {{author}} + </header> + {{&text}} </article> {{/articles}} +{{#next}} +<p><a href='{{archive}}#{{slug}}'>More</a> +{{/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 @@ <!doctype html> -<meta charset=utf-8> +<meta charset='utf-8'> +<meta name='twitter:card' content='summary_large_image'> +<meta name='twitter:site' content='@twiss'> +<meta name='twitter:creator' content='@twiss'> +<meta name='twitter:title' content='Musings from Mt. Prometheus'> +<meta name='twitter:description' content='disney blog'> +{{#image}} +<meta name='twitter:image' content='{{image}}'> +{{/image}} +{{^image}} +<meta name='twitter:image' content='https://happiest.place/gallery/images/1486815538136542.jpg.m.jpg'> +{{/image}} +<meta name='viewport' content='width=device-width'><meta name='viewport' content='initial-scale=1.0'> +{{#title}} +<title>{{title}} ยท {{site.title}}</title> +{{/title}} +{{^title}} <title>{{site.title}}</title> -<meta name=viewport content=width=device-width> -<meta name=viewport content=initial-scale=1.0> -<link rel=stylesheet href='{{&site.base}}/maker.css'> - +{{/title}} +<link href='blog.css' rel='stylesheet'> <header> <h1>{{site.title}}</h1> </header> +<nav> + <ul> + <li><a href='/blog'>Blog</a> + <li><a href='/gallery'>Gallery</a> + </ul> +</nav> + <main> {{&_}} </main> 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}} + <article> + <header> + <h2><a href='{{url}}'>{{title}}</a></h2> + </header> + </article> +{{/articles}} + +{{#prevarchive}} +lol +{{/prevarchive}} |