dofile("wb_usr.lua") lngCount = nil lngSuffix = nil lngIndex = nil lngNext = nil linkCount = 1 function readFile(filename) local file = io.open(filename) local text = file:read("*a") file:close() return text end function writeFile(filename, text) local file = io.open(filename, "w") file:write(text) file:close() end -- ##################################################################### htmlFiles = {} function addHtmlFile(v) if v then -- only up to "#" local j = string.find(v, "#") if j then f = string.sub(v, 0, j-1) else f = v end htmlFiles[f] = f end end -- ##################################################################### function writeIndexFile() print("Writing \"../index"..lngSuffix..".html\".") local wb_index = readFile("template_index.html") wb_index = string.gsub(wb_index, "WB_TITLE", wb_usr.messages[lngIndex].title) wb_index = string.gsub(wb_index, "WB_START_SIZE", wb_usr.start_size) wb_index = string.gsub(wb_index, "WB_START_PAGE", lngIndex.."/"..wb_usr.tree.link) if (lngCount > 1) then wb_index = string.gsub(wb_index, "WB_LNG", lngSuffix) else wb_index = string.gsub(wb_index, "WB_LNG", "") end writeFile("../index"..lngSuffix..".html", wb_index) end -- ##################################################################### function writeTitleFile() print("Writing \"../wb_title"..lngSuffix..".html\".") local wb_title = readFile("template_wb_title.html") wb_title = string.gsub(wb_title, "WB_BAR_TITLE", wb_usr.messages[lngIndex].bar_title) wb_title = string.gsub(wb_title, "WB_TITLE_BGCOLOR", wb_usr.title_bgcolor) wb_title = string.gsub(wb_title, "WB_SEARCH_LINK", wb_usr.search_link) wb_title = string.gsub(wb_title, "WB_COPYRIGHT_LINK", wb_usr.copyright_link) wb_title = string.gsub(wb_title, "WB_COPYRIGHT_NAME", wb_usr.copyright_name) wb_title = string.gsub(wb_title, "WB_CONTACT", wb_usr.contact) if (lngCount > 1) then wb_title = string.gsub(wb_title, "WB_LNG", lngSuffix) else wb_title = string.gsub(wb_title, "WB_LNG", "") end writeFile("../wb_title"..lngSuffix..".html", wb_title) end -- ##################################################################### function writeIndent(file, level) -- base identation file:write(" ") for i = 1, level*2, 1 do file:write(" ") end end function getNodeName(node) local name = nil if (node.name[lngIndex]) then name = node.name[lngIndex] else name = node.name["nl"] end if not name then error("Name not found.") end return name end function writeNode(file, node, opened, level, folder_index, folder_suffix, node_suffix, child_prefix) if (node.folder) then -- folder -- box image writeIndent(file, level) file:write("
") folder_suffix = folder_suffix .. "." .. folder_index file:write(child_prefix.."") if (node.link) then file:write(""..getNodeName(node).."") addHtmlFile(node.link) linkCount = linkCount + 1 else file:write(" "..getNodeName(node)) end file:write("
\n") -- folder div writeIndent(file, level) if (opened) then file:write(""..child_prefix..""..getNodeName(node).."
\n") addHtmlFile(node.link) linkCount = linkCount + 1 else -- separator leaf writeIndent(file, level) file:write("") local sep_child_prefix = string.gsub(child_prefix, "/vertline", "/sepvertline") sep_child_prefix = string.gsub(sep_child_prefix, "/blank", "/sepblank") file:write(sep_child_prefix.."
\n") end end end function writeTree(file) -- root node file:write("