]> git.nbdom.net Git - nb.git/commitdiff
lib/lua/nb.lua
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 8 May 2018 01:46:29 +0000 (02:46 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 8 May 2018 01:46:29 +0000 (02:46 +0100)
lib/lua/nb.lua

index ba5d0d5320090ace73a4752427332ae327a63b9a..ecdd745a47a860b8fc5db609966da7b18e706b47 100644 (file)
@@ -33,13 +33,21 @@ function nb:ngx_location_md()
 
        local vars = {}
        -- Extract title from content or filename or dirname
-       vars.title = string.match(content,'^#[\t ]*([^\r\n]+)')
+       --vars.title = string.match(content,'^#[\t ]*([^\r\n]+)')
+--     if not vars.title then
+--             vars.title = string.match(file,'([^/%.]+)%.') -- basename
+--             if vars.title == 'index' then
+--                     vars.title = string.match(file,'/([^/]+)/[^/]+$')
+--             end
+--     end
        if not vars.title then
-               vars.title = string.match(file,'([^/%.]+)%.')
-               if vars.title == 'index' then
-                       vars.title = string.match(file,'/([^/]+)/[^/]+$')
+               local basename = string.match(ngx.var.request_uri,'([^/]+)$')
+               if basename then
+                       local noext = string.match(basename,'([^%.]+)')
+                       vars.title = noext
                end
        end
+       if not vars.title then vars.title = string.match(ngx.var.http_host,'^([^%.]+)') end
 
        local header = nb:readall(ngx.var.document_root .. "/header.html")
        if header then template.render(header,vars) end