summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbie <bie@blekksprut.net>2017-06-29 15:48:02 +0200
committerbie <bie@blekksprut.net>2017-06-29 15:48:02 +0200
commit05c51adb090fa096eb229c9cc4f1c519fcda6a01 (patch)
tree38e7e4e7f5f150b016ad4835548a19c4c959ff5c
parent9f249b3e2af30444dbfbd42396824df3724af68f (diff)
downloadmaker-05c51adb090fa096eb229c9cc4f1c519fcda6a01.tar.xz
wew wew
-rw-r--r--.gitignore2
-rwxr-xr-xmaker155
-rw-r--r--nova/article.html35
-rw-r--r--nova/index.html7
-rw-r--r--nova/layout.html49
-rw-r--r--templates/article.html9
-rw-r--r--templates/index.html10
-rw-r--r--templates/layout.html18
8 files changed, 174 insertions, 111 deletions
diff --git a/.gitignore b/.gitignore
index b25c15b..7f0df81 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,3 @@
+artikler/
+config.lua
*~
diff --git a/maker b/maker
index 4b7033c..043975c 100755
--- a/maker
+++ b/maker
@@ -2,136 +2,69 @@
lfs = require "lfs"
posix = require "posix"
+lustache = require "lustache"
+
+require "lupin"
require "corz"
config = {}
dofile 'config.lua'
-function lup(file)
- local raw, data = "", {}
- local stat = posix.stat(file)
- io.input(file)
- data.group = posix.getgroup(stat.gid).name
- data.author = posix.getpasswd(stat.uid).name
- data.overskrift = io.read('*l')
- for line in io.lines() do
- if line:match("^#") then
- local key, value = line:match("^#%s*(.-):%s*(.+)")
- if key and value then data[key] = value end
- else
- raw = raw .. line .. "\n"
- end
- end
- if data.published then
- data.date = os.date("%A %d. %B %Y, kl. %H.%M", data.published)
- else
- y, m, d = file:match(root .. "/(.*)/(.*)/(.*)/(.*)")
- data.date = ("%s/%s/%s"):format(y, m, d)
- end
- return raw, data
-end
-
-function print(...)
- io.write(string.format(...))
-end
-
-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 "", config.title)
- else
- print("<title>%s</title>\n", config.title)
- end
- 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>
-]], config.title)
-
- if config.nav then
- print(config.nav)
- end
- print("<main>")
+posix.setenv("MARXUP_HEADER", "3");
+lupin.loadblueprints(config.blueprints)
+
+function build(path, id, data)
+ local layout = io.open(config.templates .. "/layout.html"):read("*a")
+ local template = io.open(config.templates .. "/" .. id .. ".html"):read("*a")
+ data._ = lustache:render(template, data)
+ io.output(path)
+ io.write(lustache:render(layout, data))
+ io.output()
end
-function footer(data)
- print("</main>")
- if config.footer then
- print(config.footer)
- end
+local finder = "find %s -perm /o+r -readable -not -iname '*~' -type f | sort -rn"
+local files = {}
+for file in io.popen(finder:format(config.src)):read("*a"):gmatch("[^\n]+") do
+ table.insert(files, file)
end
-function preview(text, data)
- article(text, data)
-end
+for n, src in ipairs(files) do
+ local url = src:match(config.src .. "/(.+)%..*")
+ local dir = config.www .. "/" .. posix.dirname(url)
+ local path = config.www .. "/" .. url .. ".html"
-function article(text, data)
- print("<article>")
- if simple then
- if data.picto and #data.picto > 0 then
- print('<p><img src="%s">', data.picto)
- end
- if data.path then
- print("<h2><a href='/%s/%s'>%s</a></h2>", data.date, data.path, data.overskrift or "")
- else
- print("<h2>%s</h2>", data.overskrift or "")
- end
- else
- print("<h2>%s</h2>", data.overskrift or "")
- print("<p>posted %s, by %s", data.date, data.author)
- print('<p class="lead">%s', data.lead or "")
- corz.marxup(text, io.output())
+ local stale = false
+ if not posix.stat(path) or posix.stat(src).mtime > posix.stat(path).mtime then
+ stale = true
end
-
- print "</article>\n"
-
-end
-
-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
-
-for n, file in ipairs(files) do
- url = file:match(root .. "/(.+)%..*")
- 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 true or stale then -- if stale then
if not posix.stat(dir) then
os.execute("mkdir -p " .. dir)
end
- io.output(out)
- text, data = lup(file)
- header(data)
- article(text, data)
- footer(data)
+ local data = lupin.transform(src, "later", false, "full")
+ data.path = posix.dirname(src):gsub("^" .. config.src, "")
+ data.site = config
+
+ build(path, "article", data)
end
- io.output(io.stdout)
end
-posix.setenv("MARXUP_HEADER", "3");
-
--- forside
-out = config.output .. "index.html"
-io.output(out)
-header({})
+local path = config.www .. "/" .. "index.html"
+local page = {}
+page.site = config
+page.articles = {}
for n=1,8 do
if files[n] then
- text, data = lup(files[n])
- data.path = posix.basename(files[n]):gsub(".txt$", ".html")
- preview(text, data)
+ 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
+ table.insert(page.articles, data)
end
end
-footer({})
-io.output(io.stdout)
+build(path, "index", page)
diff --git a/nova/article.html b/nova/article.html
new file mode 100644
index 0000000..6e82369
--- /dev/null
+++ b/nova/article.html
@@ -0,0 +1,35 @@
+<article class=full>
+ <p class=figure data-attribution='{{attribution}}'>
+ <a href='{{url}}'><img alt src='{{image}}'></a>
+ <h2><a href='{{url}}'>{{title}}</a></h2>
+
+ <p class=byline>
+ <img alt class='headshot mini' src='{{portrait}}'>
+ <span class=navn>
+ <a href='/folk/{{author}}'>{{author}}</a>
+ for <a href='/group/{{group}}'>{{group}}</a>
+ </span>
+
+ <section class=content>
+ <aside>
+ <img alt class=headshot src='{{portrait}}'>
+ {{#info}}
+ <h3>Om filmen</h3>
+ {{/info}}
+ {{#info}}
+ <dl>
+ <dt>{{term}}</dt>
+ <dd>{{fact}}</dd>
+ </dl>
+ {{/info}}
+ </aside>
+
+ <section class=body>
+ {{#lead}}
+ <p class=lead><b>{{lead}}</b>
+ {{/lead}}
+ {{&text}}
+ </section>
+ </section>
+</article>
+
diff --git a/nova/index.html b/nova/index.html
new file mode 100644
index 0000000..97ef595
--- /dev/null
+++ b/nova/index.html
@@ -0,0 +1,7 @@
+{{#articles}}
+ <article>
+ <p><a href='{{url}}'><img alt src='{{image}}'></a>
+ <h2><a href='{{url}}'>{{title}}</a></h2>
+ </article>
+{{/articles}}
+
diff --git a/nova/layout.html b/nova/layout.html
new file mode 100644
index 0000000..e9b5c83
--- /dev/null
+++ b/nova/layout.html
@@ -0,0 +1,49 @@
+<!doctype html>
+<meta charset=utf-8>
+<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}}/css/font-awesome.min.css'>
+<link rel=stylesheet href='{{&site.base}}/css/font-awesome-animation.min.css'>
+
+<link rel=stylesheet href='{{&site.base}}/css/open-sans.css'>
+<link rel=stylesheet href='{{&site.base}}/css/noticia.css'>
+
+<link rel=stylesheet href='{{&site.base}}/css/radionova.css'>
+
+<script src='{{&site.base}}/js/jquery.js'></script>
+<script src='{{&site.base}}/js/radionova.js'></script>
+
+<audio id=novastream>
+ <source id="hls" src="http://henrik.party/stream/master.m3u8">
+ <source id="ogg" src="http://stream.radionova.no/ogg">
+ <source id="mp3" src="http://stream.radionova.no/mp3">
+</audio>
+
+<header>
+ <h1><a href='/'><img src='{{&site.base}}/radionova.png'></a></h1>
+
+ <div class='fa fa-play' id='stream-toggle'></div>
+ <div id='stream-playing'></div>
+
+ <nav id='site-menu' class='sidebar hidden'>
+ <p>
+ <a href='/podcast'>Podcast</a>
+ <a href='/programmer'>Programmer</a>
+ <a href='/a-lista'>A-Lista</a>
+ <a href='/a-lista'>Studentnyhetene</a>
+ <a href='/a-lista'>Sendeplan</a>
+
+ <p>Radio Nova er Oslo-studentenes helt egne radiokanal og en av Norges største lokalradioer.
+ <p>24 timer i døgnet, syv dager i uka gir vi deg et vidt spekter av programmer som garantert dekker dine interesser og spiller favorittmusikken din, før du visste at du likte den.
+ </nav>
+</header>
+
+<main>
+{{&_}}
+</main>
+
+<footer>
+</footer>
+
diff --git a/templates/article.html b/templates/article.html
new file mode 100644
index 0000000..d8b5b4b
--- /dev/null
+++ b/templates/article.html
@@ -0,0 +1,9 @@
+<article>
+ <h2>{{title}}</h2>
+ <p>posted {{date}} by {{author}}
+ {{#lead}}
+ <p class=lead>{{lead}}
+ {{/lead}}
+ {{&text}}
+</article>
+
diff --git a/templates/index.html b/templates/index.html
new file mode 100644
index 0000000..4695387
--- /dev/null
+++ b/templates/index.html
@@ -0,0 +1,10 @@
+{{#articles}}
+ <article>
+ <h2><a href='{{url}}'>{{title}}</a></h2>
+ <p>posted {{date}} by {{author}}
+ {{#lead}}
+ <p class=lead>{{lead}}
+ {{/lead}}
+ </article>
+{{/articles}}
+
diff --git a/templates/layout.html b/templates/layout.html
new file mode 100644
index 0000000..7937763
--- /dev/null
+++ b/templates/layout.html
@@ -0,0 +1,18 @@
+<!doctype html>
+<meta charset=utf-8>
+<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'>
+
+<header>
+ <h1>{{site.title}}</h1>
+</header>
+
+<main>
+{{&_}}
+</main>
+
+<footer>
+</footer>
+