dev = 1,
}
-if ngx.var.PRODUCTION == 'yes' then nb.dev = 0 end
+if ngx and ngx.var.PRODUCTION == 'yes' then nb.dev = 0 end
+
function nb:readall(file)
-- local f = io.open(file) or error("Could not open file: " .. file)
local f = io.open(file)
-- Default first tld domain
if not vars.title then vars.title = string.match(ngx.var.http_host,'^([^%.]+)') end
- local header = nb:readall(fheader)
- if header then template.render(header,vars) end
+ local ishtml = true
-- content = '{(header.html)}{*markdown[[' .. content .. ']]*}{footer.html)}'
- content = template.output(template.compile(content)(vars))
if string.match(file,'%.md$') then
-- Markdown
discount = require("discount")
content = content:gsub("(<" .. tag .. ">) +","%1")
end
- ngx.print(content)
+ -- ngx.print(content)
+
+ elseif string.match(file,'%.html?$') then
- else --if string.match(file,'%.html$') then
- -- Html
- -- template.render(content,vars)
- ngx.print(content)
+ else
+ ishtml = false
+ end
+ if ishtml and file ~= fheader and file ~= ffooter then
+ local header = self:readall(fheader)
+ local footer = nb:readall(ffooter)
+ content = header .. content .. footer
end
- local footer = nb:readall(ffooter)
- if footer then template.render(footer,vars) end
+ template.render(content,vars)
ngx.exit(0)
end