summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbie <bie@blekksprut.net>2017-07-31 06:03:35 +0200
committerbie <bie@blekksprut.net>2017-07-31 06:03:35 +0200
commitbcc916147c695604c1b00ad73210321ce6843b87 (patch)
tree7eea214634aec28024a28fbb619525b20a0ba94a
parent8df4f368a73a3b39a152bf864ab03c409179e5ec (diff)
parent749c1789ee6d8537cd9645be0d39415291677182 (diff)
downloadmaker-bcc916147c695604c1b00ad73210321ce6843b87.tar.xz
ehm
-rw-r--r--.gitignore2
-rw-r--r--config.def.lua21
-rwxr-xr-xmaker18
-rw-r--r--templates/article.html9
-rw-r--r--templates/index.html10
-rw-r--r--templates/layout.html18
6 files changed, 65 insertions, 13 deletions
diff --git a/.gitignore b/.gitignore
index b25c15b..7f0df81 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,3 @@
+artikler/
+config.lua
*~
diff --git a/config.def.lua b/config.def.lua
index c4f2d80..6b251c5 100644
--- a/config.def.lua
+++ b/config.def.lua
@@ -1,16 +1,15 @@
config.title = "~maker~"
-config.input = "/srv/artikler"
-config.output = "/srv/www"
-config.css = "/maker.css"
+config.templates = "templates"
+config.blueprints = "blueprints"
+config.src = "artikler"
+config.www = "www"
+config.date = "%A %d. %B %Y, kl. %H.%M"
-config.nav = [[
-<nav>
-</nav>
-]]
+config.base = "http://localhost/"
+config.extension = ".html"
-config.footer = [[
-<footer>
-</footer>
-]]
+config.static = {
+ { src = 'sendeplan.yaml', template = 'sendeplan', path = 'sendeplan.html' }
+}
diff --git a/maker b/maker
index b8b9ba6..c6ae2fa 100755
--- a/maker
+++ b/maker
@@ -3,6 +3,8 @@
lfs = require "lfs"
posix = require "posix"
lustache = require "lustache"
+yaml = require 'yaml'
+yaml.configure{ load_numeric_scalars = false }
require "lupin"
require "corz"
@@ -22,7 +24,7 @@ function build(path, id, data)
io.output()
end
-local finder = "find %s -readable -not -iname '*~' -type f | sort -rn"
+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)
@@ -66,5 +68,17 @@ for n=1,8 do
table.insert(page.articles, data)
end
end
-build(path, "index", page)
+for i, page in ipairs(config.static) do
+ local path = config.www .. "/" .. page.path
+ local data = nil
+ if type(page.src) == "string" then
+ data = yaml.loadpath(page.src)
+ else
+ data = page.src()
+ end
+ data.site = config
+ build(path, page.template, data)
+end
+
+build(path, "index", page)
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>
+