poelzi@133: local id = param.get_id(atom.string) poelzi@133: poelzi@133: if not id then poelzi@133: id = "index" poelzi@133: else poelzi@133: -- sanity check. Only allow letters, digits and _- poelzi@133: id = string.match(id, "[%a%d_-]*") poelzi@133: end poelzi@133: poelzi@133: if not app.html_title.title then poelzi@133: app.html_title.title = _("Help #{id}", { id = id }) poelzi@133: end poelzi@133: poelzi@133: local basepath = request.get_app_basepath() poelzi@133: local found_help = false poelzi@133: -- we try to load any help file that fits best poelzi@133: for x,lang in ipairs{locale.get("lang"), "en"} do poelzi@133: for x,htype in ipairs{"_full", ""} do poelzi@133: local file_name = basepath .. "/locale/help/" .. id .. htype .. "." .. lang .. ".txt.html" poelzi@133: local file = io.open(file_name) poelzi@133: if file ~= nil then poelzi@133: local help_text = file:read("*a") poelzi@133: if #help_text > 0 then poelzi@133: found_help = true poelzi@133: ui.container{ poelzi@133: attr = { class = "wiki" }, poelzi@133: content = function() poelzi@133: slot.put(help_text) poelzi@133: end poelzi@133: } poelzi@133: break poelzi@133: end poelzi@133: end poelzi@133: end poelzi@133: end poelzi@133: poelzi@133: if not found_help then poelzi@133: ui.field.text{ value = _("Missing help text: #{id}.#{lang}.txt", { id = id, lang = locale.get("lang") }) } poelzi@133: end