generate nav
This commit is contained in:
parent
68f533e6c3
commit
5190019fc3
|
@ -7,6 +7,7 @@ meta = {
|
||||||
|
|
||||||
webdir = "webtest" -- web output directory
|
webdir = "webtest" -- web output directory
|
||||||
gemdir = "gemtest" -- gemini output directory
|
gemdir = "gemtest" -- gemini output directory
|
||||||
|
-- TODO templates in spanish
|
||||||
templates = {
|
templates = {
|
||||||
webEn = {
|
webEn = {
|
||||||
header = { path = "pageheader.html", template = ""},
|
header = { path = "pageheader.html", template = ""},
|
||||||
|
@ -112,6 +113,8 @@ function firstPass()
|
||||||
-- table to store the lines to write to file
|
-- table to store the lines to write to file
|
||||||
local lines = { web = {}, gem = {} }
|
local lines = { web = {}, gem = {} }
|
||||||
|
|
||||||
|
local navlines = { "<ul>" }
|
||||||
|
|
||||||
-- convert one line at a time
|
-- convert one line at a time
|
||||||
local count = 1
|
local count = 1
|
||||||
for line in f:lines() do
|
for line in f:lines() do
|
||||||
|
@ -159,9 +162,13 @@ function firstPass()
|
||||||
out.web = closeTags()
|
out.web = closeTags()
|
||||||
|
|
||||||
elseif string.match( line, "^#+") then -- HEADERS
|
elseif string.match( line, "^#+") then -- HEADERS
|
||||||
-- TODO create nav
|
|
||||||
local title, level = getHeader( line )
|
local title, level = getHeader( line )
|
||||||
|
|
||||||
|
-- add h1 to navigation
|
||||||
|
if level==1 then
|
||||||
|
table.insert(navlines,string.format("<li><a href='#%s'>%s</a></li>",title,title))
|
||||||
|
end
|
||||||
|
|
||||||
local close = closeTags()
|
local close = closeTags()
|
||||||
out.web = string.format("%s<h%d>%s</h%d>",close,level,title,level)
|
out.web = string.format("%s<h%d>%s</h%d>",close,level,title,level)
|
||||||
|
|
||||||
|
@ -260,6 +267,9 @@ function firstPass()
|
||||||
table.insert( lines.web, close )
|
table.insert( lines.web, close )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
table.insert( navlines, "</ul>" )
|
||||||
|
pagemeta.navcontent = table.concat( navlines, "\n" )
|
||||||
|
|
||||||
-- set templates
|
-- set templates
|
||||||
pagemeta.outs.web.templates = templates.webEn
|
pagemeta.outs.web.templates = templates.webEn
|
||||||
pagemeta.outs.gem.templates = templates.gemEn
|
pagemeta.outs.gem.templates = templates.gemEn
|
||||||
|
@ -483,6 +493,7 @@ local n = genIndex()
|
||||||
-- converting from gmo to gmi and html and calculating incoming links
|
-- converting from gmo to gmi and html and calculating incoming links
|
||||||
print(string.format("convirtiendo %d páginas...",n))
|
print(string.format("convirtiendo %d páginas...",n))
|
||||||
firstPass()
|
firstPass()
|
||||||
|
|
||||||
-- second pass, write incoming links
|
-- second pass, write incoming links
|
||||||
print("escribiendo incoming links...")
|
print("escribiendo incoming links...")
|
||||||
secondPass()
|
secondPass()
|
||||||
|
|
Loading…
Reference in New Issue