jorvick

changeset 15
e784e417a3e2
parent 14
7e9c3f32ec0a
equal deleted inserted replaced
14:7e9c3f32ec0a 15:e784e417a3e2
4 4
5 local commands = {}; 5 local commands = {};
6 6
7 function commands.build() 7 function commands.build()
8 require "jorvick.build"; 8 require "jorvick.build";
9 end
10
11 function commands.publish(post)
12 local f, err = io.open(post);
13 if not f then
14 print("Can't open post: "..(err or "unknown error"));
15 end
16
17 local f2, err = io.open(post..".published", "w+");
18 local in_header;
19 for line in f:lines() do
20 if in_header == nil and line:match("^%-%-%-%s*$") then
21 in_header = true;
22 elseif in_header == true and line:match("^%-%-%-%s*$") then
23 f2:write("published: "..os.date("!%Y-%m-%dT%H:%M:%SZ"), "\n");
24 in_header = false;
25 end
26 f2:write(line, "\n");
27 end
28 f:close();
29 f2:close();
30 os.rename(post..".published", post);
31 print("Post marked as published. Run build to update site.");
9 end 32 end
10 33
11 function commands.create(...) 34 function commands.create(...)
12 local title = table.concat({...}, " "); 35 local title = table.concat({...}, " ");
13 if #title == 0 then 36 if #title == 0 then

mercurial