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 |