summaryrefslogtreecommitdiff
path: root/maker
diff options
context:
space:
mode:
Diffstat (limited to 'maker')
-rwxr-xr-xmaker88
1 files changed, 35 insertions, 53 deletions
diff --git a/maker b/maker
index 4ff298e..4b7033c 100755
--- a/maker
+++ b/maker
@@ -1,15 +1,12 @@
#!/usr/bin/env lua
-TITLE = "radionova"
-INPUT = "/srv/www/tears/artikler"
-OUTPUT = "/srv/www/"
-
-os.setlocale("no_NO")
-
lfs = require "lfs"
posix = require "posix"
require "corz"
+config = {}
+dofile 'config.lua'
+
function lup(file)
local raw, data = "", {}
local stat = posix.stat(file)
@@ -42,59 +39,45 @@ function header(data)
print("<!doctype html>\n")
print("<meta charset='utf-8'>\n")
if data.overskrift then
- print("<title>%s · %s</title>\n", data.overskrift or "", TITLE)
+ print("<title>%s · %s</title>\n", data.overskrift or "", config.title)
else
- print("<title>%s</title>\n", TITLE)
+ print("<title>%s</title>\n", config.title)
end
- print("<link href='/radionova.css' rel='stylesheet'>\n")
+ if config.css then
+ print("<link href='%s' rel='stylesheet'>\n", config.css)
+ end
+
+ print("<meta name='viewport' content='width=device-width'>")
+ print("<meta name='viewport' content='initial-scale=1.0'>")
print([[
<header>
<h1>%s</h1>
</header>
-]], TITLE)
+]], config.title)
- print([[
-<nav>
-<ul>
-<li><a href='/'>Radio Nova</a>
-<li><a href='/'>Programmer</a>
-<li><a href='/'>Sendeplan</a>
-<li><a href='/'>Studentnyhetene</a>
-</ul>
-</nav>
-]])
+ if config.nav then
+ print(config.nav)
+ end
print("<main>")
end
function footer(data)
print("</main>")
- print [[
-<footer>
- <div class=spiller>
- <p class=spiller-program>0900 - 1000 : Skumma Kultur
- <p class=spiller-naa>Spilles nå: blah blah blah
- </div>
-</footer>
-]]
+ if config.footer then
+ print(config.footer)
+ end
end
-function html(text, data, simple)
- if not simple then
- header(data)
- print "<section>"
- print [[
- <aside>
- </aside>
- ]]
- end
+function preview(text, data)
+ article(text, data)
+end
+function article(text, data)
print("<article>")
if simple then
if data.picto and #data.picto > 0 then
print('<p><img src="%s">', data.picto)
- else
- print('<p><img src="/article.jpg">')
end
if data.path then
print("<h2><a href='/%s/%s'>%s</a></h2>", data.date, data.path, data.overskrift or "")
@@ -103,51 +86,50 @@ function html(text, data, simple)
end
else
print("<h2>%s</h2>", data.overskrift or "")
- print("<p>skrevet %s, av %s for %s", data.date, data.author, data.group)
+ print("<p>posted %s, by %s", data.date, data.author)
print('<p class="lead">%s', data.lead or "")
- corz.marxup(text)
+ corz.marxup(text, io.output())
end
print "</article>\n"
- if not simple then
- print "</section>"
- footer(data)
- end
end
-root = INPUT
-finder = ("find %s -readable -not -iname '*~' -type f | sort -n"):format(root)
+root = config.input
+finder = ("find %s -readable -not -iname '*~' -type f | sort -rn"):format(root)
files = {}
for file in io.popen(finder):read("*a"):gmatch("[^\n]+") do
table.insert(files, file)
end
--- alle tingene
for n, file in ipairs(files) do
url = file:match(root .. "/(.+)%..*")
- dir = OUTPUT .. posix.dirname(url)
- out = OUTPUT .. url .. ".html"
+ dir = config.output .. posix.dirname(url)
+ out = config.output .. url .. ".html"
if not posix.stat(out) or posix.stat(file).mtime > posix.stat(out).mtime then
if not posix.stat(dir) then
os.execute("mkdir -p " .. dir)
end
io.output(out)
text, data = lup(file)
- html(text, data)
+ header(data)
+ article(text, data)
+ footer(data)
end
io.output(io.stdout)
end
+posix.setenv("MARXUP_HEADER", "3");
+
-- forside
-out = OUTPUT .. "index.html"
+out = config.output .. "index.html"
io.output(out)
header({})
for n=1,8 do
if files[n] then
text, data = lup(files[n])
data.path = posix.basename(files[n]):gsub(".txt$", ".html")
- html(text, data, true)
+ preview(text, data)
end
end
footer({})