meta = { domain = "compudanzas.net", title = "compudanzas", description = "explorations of computing at a human scale", fecha = os.date("%Y-%m-%d") } webdir = "web" -- web output directory gemdir = "gem" -- gemini output directory templates = { webEn = { header = { path = "pageheader.html", template = ""}, footer = { path = "pagefooter.html", template = ""}, incoming = { path = "pageincoming.html", template = ""} }, webEs = { header = { path = "pageheader_es.html", template = ""}, footer = { path = "pagefooter_es.html", template = ""}, incoming = { path = "pageincoming_es.html", template = ""} }, gemEn = { header = { path = "pageheader.gmi", template = ""}, footer = { path = "pagefooter.gmi", template = ""}, incoming = { path = "pageincoming.gmi", template = ""} }, gemEs = { header = { path = "pageheader.gmi", template = ""}, footer = { path = "pagefooter_es.gmi", template = ""}, incoming = { path = "pageincoming_es.gmi", template = ""} }, } pages = {} function slugify( s ) return (string.gsub( s, "%s", "_" )) end function spacify( s ) -- opposite of slugify (?) return (string.gsub( s, "_", " ")) end function fillTemplate( template, pagemeta ) return ( string.gsub( template, "({.-})", function (key) local var = string.sub(key,2,-2) -- remove { } return meta[var] or pagemeta[var] end) ) end function getHeader( line ) -- returns title, level local head, title = string.match(line,"^(#+)%s*(.-)$") return title, #head end function getLink( line ) -- returns dest, text return string.match( line, "^=>%s*(%S-)%s+(.-)$") end function isImagePath( text ) return text:match(".jpg$") or text:match(".gif$") or text:match(".png$") end function sanitize( line ) -- replace relevant html entities return line:gsub("<","<"):gsub(">",">") end function closeTags() local close = "" if flags.list then close = "\n" flags.list = false elseif flags.p then close = "

\n" flags.p = false elseif flags.gallery then close = "\n" flags.gallery = false end return close end function insertIncoming( pagename, incomingname ) if incomingname == "pages" then return false end local incoming = pages[pagename].incoming for i = 1, #incoming do if incoming[i] == incomingname then return false end end table.insert( incoming, incomingname) return true end function firstPass() -- load templates for _,t in pairs(templates) do -- read templates for k,subtemp in pairs( t ) do local f = assert(io.open(string.format("templates/%s",subtemp.path),"r")) subtemp.template = f:read("a") f:close() end end -- for each page: -- convert gmo to gmi and html -- and calculate incoming links for name,page in pairs(pages) do local pagemeta = pages[name] local gmopath = string.format("src/%s.gmo", pagemeta.slug) -- open file local f = assert( io.open(gmopath, "r") ) -- initialize flags flags = { list = false, pre = false , p = false, gallery = false } -- table to store the lines to write to file local lines = { web = {}, gem = {} } local navlines = { "