build.lua

changeset 6
cf40d55f8122
parent 5
951de9625338
child 8
6dc28a66f4d9
equal deleted inserted replaced
5:951de9625338 6:cf40d55f8122
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 5
5 -- Config -- 6 -- Config --
6 7
7 dofile(arg[1] or ".blogrc") 8 dofile(arg[1] or ".blogrc")
8 9
66 local post_data, err = post_file:read("*a"); 67 local post_data, err = post_file:read("*a");
67 68
68 -- Parse post_data according to extension, add to post list 69 -- Parse post_data according to extension, add to post list
69 --msg_info("Parsing %s...", post_filename) --:gsub("%.[^%.]+$", ""):match("[^/]+")); 70 --msg_info("Parsing %s...", post_filename) --:gsub("%.[^%.]+$", ""):match("[^/]+"));
70 post.content = templates.load(parsers[post_format](post_data)):render{ page = post }; 71 post.content = templates.load(parsers[post_format](post_data)):render{ page = post };
71 post.shorttitle = post.title:gsub("%W+", "-"):lower():sub(1,45) 72 post.shorttile = make_short_title(post.title);
72 if #post.title:gsub("%W+", "-") > 45 then
73 post.shorttitle = post.shorttitle:gsub("%-%w+$", "");
74 end
75 post.url = base_url..post.shorttitle.."/" 73 post.url = base_url..post.shorttitle.."/"
76 post.post = post 74 post.post = post
77 post.updated = post.updated or os.date("!%Y-%m-%dT%H:%M:%SZ", lfs.attributes(post.path).modification); 75 post.updated = post.updated or os.date("!%Y-%m-%dT%H:%M:%SZ", lfs.attributes(post.path).modification);
78 if post.published then 76 if post.published then
79 if not post.published:match("^%d%d%d%d%-%d%d%-%d%dT%d%d:%d%d%:%d%dZ$") then 77 if not post.published:match("^%d%d%d%d%-%d%d%-%d%dT%d%d:%d%d%:%d%dZ$") then

mercurial