115 |
115 |
116 msg_info("%s post%s processed", #posts, #posts ~= 1 and "s" or ""); |
116 msg_info("%s post%s processed", #posts, #posts ~= 1 and "s" or ""); |
117 |
117 |
118 msg_info(" - - - "); |
118 msg_info(" - - - "); |
119 |
119 |
120 local unpublished = 0; |
120 local unpublished, removed_posts = 0, {}; |
121 for n, post in ipairs(posts) do |
121 for n, post in ipairs(posts) do |
122 if post.content and (not post.layout or layouts[post.layout]) then |
122 if post.content and (not post.layout or layouts[post.layout]) then |
123 lfs.mkdir(output_dir..post.shorttitle); |
123 lfs.mkdir(output_dir..post.shorttitle); |
124 local outfile, err = io.open(output_dir..post.shorttitle.."/index.html", "w+"); |
124 local outfile, err = io.open(output_dir..post.shorttitle.."/index.html", "w+"); |
125 if outfile then |
125 if outfile then |
142 outfile:close(); |
142 outfile:close(); |
143 if not post.published then |
143 if not post.published then |
144 -- Not published yet, hide it |
144 -- Not published yet, hide it |
145 --msg_info("Hiding unpublished post"); |
145 --msg_info("Hiding unpublished post"); |
146 unpublished = unpublished + 1; |
146 unpublished = unpublished + 1; |
147 posts[n] = nil; |
147 table.insert(removed_posts, n); |
148 end |
148 end |
149 else |
149 else |
150 msg_error("Failed to write HTML: %s", err); |
150 msg_error("Failed to write HTML: %s", err); |
151 end |
151 end |
152 if post.published then |
152 if post.published then |
153 msg_info("Published: %s", post.shorttitle); |
153 msg_info("Published: %s", post.shorttitle); |
154 else |
154 else |
155 msg_info("Generated: %s", post.shorttitle); |
155 msg_info("Generated: %s", post.shorttitle); |
156 end |
156 end |
157 end |
157 end |
|
158 end |
|
159 |
|
160 local removed = 0; |
|
161 for _, n in ipairs(removed_posts) do |
|
162 table.remove(posts, n-removed); |
|
163 removed = removed + 1; |
158 end |
164 end |
159 |
165 |
160 -- Do main page |
166 -- Do main page |
161 local main_tpl = templates.init(layouts_dir.."/main.html"); |
167 local main_tpl = templates.init(layouts_dir.."/main.html"); |
162 |
168 |