build.lua

changeset 8
6dc28a66f4d9
parent 6
cf40d55f8122
child 11
36dd235e09d2
equal deleted inserted replaced
7:9ab155822b0b 8:6dc28a66f4d9
1 require "LuaTemplates.templates" 1 require "LuaTemplates.templates"
2 require "LuaTemplates.parsers" 2 require "LuaTemplates.parsers"
3 require "lfs" 3 require "lfs"
4 require "util" 4 require "util"
5 5
6 -- Config --
7
8 dofile(arg[1] or ".blogrc")
9
10 posts_dir = posts_dir or "_posts/"
11 layouts_dir = layouts_dir or "_layouts/"
12 output_dir = output_dir or "./"
13 -- - -- - --
14
15 -- Logging -- 6 -- Logging --
16 function make_msg(prefix, name) return function (fmt, ...) print(prefix, string.format(fmt, ...)); end end 7 function make_msg(prefix, name) return function (fmt, ...) print(prefix, string.format(fmt, ...)); end end
17 msg_info, msg_warn, msg_error = make_msg("II", "info"), make_msg("WW", "warn"), make_msg("EE", "error"); 8 msg_info, msg_warn, msg_error = make_msg("II", "info"), make_msg("WW", "warn"), make_msg("EE", "error");
18 -- -- - -- -- 9 -- -- - -- --
19
20 -- Append '/' to end of posts_dir if necessary
21 posts_dir = posts_dir:gsub("([^/])$", "%1/")
22
23 -- Append '/' to end of output_dir if necessary
24 output_dir = output_dir:gsub("([^/])$", "%1/")
25
26 -- Append '/' to end of base_url if necessary
27 base_url = base_url:gsub("([^/])$", "%1/")
28 10
29 posts = {}; 11 posts = {};
30 12
31 13
32 -- Read posts, interpret 14 -- Read posts, interpret

mercurial