diff options
Diffstat (limited to 'notYetAnotherWiki.lua')
| -rwxr-xr-x | notYetAnotherWiki.lua | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/notYetAnotherWiki.lua b/notYetAnotherWiki.lua index 65137b5..37bbd94 100755 --- a/notYetAnotherWiki.lua +++ b/notYetAnotherWiki.lua | |||
| @@ -216,85 +216,4 @@ for k, v in pairs(sites) do | |||
| 216 | 216 | ||
| 217 | end | 217 | end |
| 218 | 218 | ||
| 219 | local h = io.open(file, 'r') | ||
| 220 | if nil ~= h then | ||
| 221 | local cm = h:read('*a') | ||
| 222 | local result = '' | ||
| 223 | local body, metadata, err = lcmark.convert(cm, "html", {smart = true, yaml_metadata = true, columns = 0}) | ||
| 224 | |||
| 225 | if nil == body then print('oops! ' .. err) else | ||
| 226 | local bod, err = lcmark.compile_template(body) | ||
| 227 | if nil == bod then print('oops! ' .. err) else | ||
| 228 | local templateFile = metadata.template | ||
| 229 | if nil == file then | ||
| 230 | templateFile = nil | ||
| 231 | else | ||
| 232 | if nil == templateFile then templateFile = 'default' end | ||
| 233 | templateFile = templateFile .. '.template' | ||
| 234 | for m, x in pairs(globalData) do | ||
| 235 | if nil == metadata[m] then metadata[m] = x else print('metadata already has ' .. m) end | ||
| 236 | end | ||
| 237 | end | ||
| 238 | |||
| 239 | if nil ~= v.files then | ||
| 240 | for m, x in ipairs(v.files) do | ||
| 241 | metadata.menu = metadata.menu .. x.URL .. '\n' | ||
| 242 | end | ||
| 243 | end | ||
| 244 | if nil ~= v.subs then | ||
| 245 | for m, x in pairs(v.subs) do | ||
| 246 | metadata.header = metadata.header .. x.URL | ||
| 247 | end | ||
| 248 | end | ||
| 249 | |||
| 250 | local num = #(v.bits) | ||
| 251 | local trail = '<a href="' .. string.rep('../', num) .. '">home</a> ' | ||
| 252 | local p = v.parent | ||
| 253 | for i = 1, num do | ||
| 254 | trail = trail .. '<a href="' .. string.rep('../', num - i) .. '">' .. v.bits[i] .. '</a> ' | ||
| 255 | end | ||
| 256 | trail = trail .. w.name | ||
| 257 | metadata.trail = trail | ||
| 258 | |||
| 259 | metadata.body = lcmark.apply_template(bod, metadata) | ||
| 260 | |||
| 261 | local tm = '' | ||
| 262 | if nil ~= templateFile then | ||
| 263 | local h = io.open(templateFile, 'r') | ||
| 264 | if nil ~= h then | ||
| 265 | tm = tm .. h:read('*a') | ||
| 266 | h:close() | ||
| 267 | else | ||
| 268 | print('oops! No such file ' .. templateFile) | ||
| 269 | end | ||
| 270 | |||
| 271 | local template, err = lcmark.compile_template(tm) | ||
| 272 | if nil == template then print('oops! ' .. err) else | ||
| 273 | result = lcmark.apply_template(template, metadata) | ||
| 274 | end | ||
| 275 | else | ||
| 276 | result = body | ||
| 277 | end | ||
| 278 | |||
| 279 | if ('' ~= result) and (nil ~= file) then | ||
| 280 | local base = path .. w.name .. '.HTML' | ||
| 281 | print(base) | ||
| 282 | local a, e = io.open(base, 'w') | ||
| 283 | if nil == a then print('Could not open ' .. base .. ' - ' .. e) else | ||
| 284 | a:write(result) | ||
| 285 | a:close() | ||
| 286 | end | ||
| 287 | else | ||
| 288 | print('') | ||
| 289 | end | ||
| 290 | end | ||
| 291 | end | ||
| 292 | 219 | ||
| 293 | h:close() | ||
| 294 | else | ||
| 295 | print('oops! No such file ' .. file) | ||
| 296 | end | ||
| 297 | |||
| 298 | end | ||
| 299 | end | ||
| 300 | end | ||
