From: Nicolas Boisselier Date: Mon, 11 Jun 2018 12:15:08 +0000 (+0100) Subject: lib/lua/nb.lua X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=42020dcfb1407c0ea71d4ac26788817a89e50b9d;p=nb.git lib/lua/nb.lua --- diff --git a/lib/lua/nb.lua b/lib/lua/nb.lua index 7cc7483d..0fa62487 100644 --- a/lib/lua/nb.lua +++ b/lib/lua/nb.lua @@ -54,10 +54,15 @@ function nb:ngx_location_tmpl(fheader,ffooter) local content = self:readall(file) if ngx.ctx.tmpl_content then content = ngx.ctx.tmpl_content end if not content then return end + if ngx.var.request_uri:match('^/dev/') then + --content = template.compile(content,vars)(context) + --ngx.print(content) + --return + end local ishtml = true - if false then + if false and string.match(file,'%.md$') then template.markdown = require "resty.hoedown" -- ngx.say('zaza' .. template.markdown.html.flags.table) --content = self:md2html(content) @@ -76,9 +81,9 @@ function nb:ngx_location_tmpl(fheader,ffooter) elseif string.match(file,'%.html?$') then local i = '<[^>]+>' -- Extract title from h1 - if not vars.title then vars.title = string.match(content,']*>([^>]+)',1) end + if not vars.title then vars.title = string.match(content:gsub('(]*>)<[^>]+>','%1'),']*>([^<>]+)',1) end -- Extract title from h2 - if not vars.title then vars.title = string.match(content,']*>([^>]+)',1) end + if not vars.title then vars.title = string.match(content:gsub('(]*>)<[^>]+>','%1'),']*>([^<>]+)',1) end elseif not ngx.ctx.tmpl_content then ishtml = false