#!/usr/bin/env texlua -- $Id: $ local config_file = './website.conf' if not lfs.isfile (config_file) then error (config_file..' not found.') end conf=dofile(config_file) local title = conf.title -- local header_template = [===[ @@TITLE@@ @_STYLE_@ ]===] local function process_header (replacements, lang, page) local header = {} local lines = header_template:explode('\n') for _,line in ipairs(lines) do if line:match('@_STYLE_@') then if conf[lang][page].style then header[#header+1] = conf[lang][page].style end else for k,v in pairs(replacements) do line=line:gsub(k,v) end -- print(line) header[#header+1] = line end end return table.concat(header, '\n') end local function menuitem_link (item, target) return ' \n \n \n' end local function menuitem_nolink (item) return ' \n \n \n' end for _,lang in ipairs (conf.languages) do for _,page in ipairs (conf.pages) do local filename = conf.target_directory..'/'..lang..'-'..page..'.html' print('Target File: '..filename) fh = assert(io.open(filename, 'wb')) if conf.title == conf[lang][page].head then conf[lang].replacements['@@TITLE@@'] = conf.title else conf[lang].replacements['@@TITLE@@'] = conf.title..': '..conf[lang][page].head end fh:write(process_header(conf[lang].replacements, lang, page)) for _,item in ipairs (conf.pages) do if item == page then fh:write(menuitem_nolink(conf[lang][item].head)) else fh:write(menuitem_link(conf[lang][item].head, lang..'-'..item..'.html')) end end fh:write('
'..item..'
'..item..'
\n\n
\n\n') --[====[ insert contents here ]====] local html_file = 'contents/'..lang..'/'..page..'.in.html' local md_file = 'contents/'..lang..'/'..page..'.md' local html_body = '

Sorry, no contents available so far

' -- print (md_file) if lfs.isfile (html_file) then print ('\tInput File: '..html_file) local html_in = assert(io.open(html_file, 'r')) html_body = html_in:read('*all') elseif lfs.isfile (md_file) then print ('\tInput File: '..md_file) local md_in = assert(io.popen('pandoc '..md_file, 'r')) html_body = md_in:read('*all') end -- print(html_body) fh:write(html_body) -- fh:write('

\n Hello world!\n Insert HTML stuff here.\n

\n') fh:write('\n
\n\n\n') fh:close() end end -- Local Variables: -- mode: Lua -- lua-indent-level: 2 -- indent-tabs-mode: nil -- coding: utf-8-unix -- End: -- vim:set tabstop=2 expandtab: