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 bsw@613: local file_name = basepath .. "/locale/help/" .. id .. "." .. lang .. ".txt.html" bsw@613: local file = io.open(file_name) bsw@613: if file ~= nil then bsw@613: local help_text = file:read("*a") bsw@613: if #help_text > 0 then bsw@613: found_help = true bsw@613: ui.container{ bsw@613: attr = { class = "wiki" }, bsw@613: content = function() bsw@613: slot.put(help_text) bsw@613: end bsw@613: } bsw@613: break 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