liquid_feedback_frontend
annotate app/main/help/show.lua @ 133:fa55c8ded9fd
add wiki syntax help
add help display module
add links to the wiki editors that link to a help page of the selected wiki syntax.
add help display module
add links to the wiki editors that link to a help page of the selected wiki syntax.
author | Daniel Poelzleithner <poelzi@poelzi.org> |
---|---|
date | Tue Oct 05 16:18:39 2010 +0200 (2010-10-05) |
parents | |
children | d0f99272f675 |
rev | line source |
---|---|
poelzi@133 | 1 local id = param.get_id(atom.string) |
poelzi@133 | 2 |
poelzi@133 | 3 if not id then |
poelzi@133 | 4 id = "index" |
poelzi@133 | 5 else |
poelzi@133 | 6 -- sanity check. Only allow letters, digits and _- |
poelzi@133 | 7 id = string.match(id, "[%a%d_-]*") |
poelzi@133 | 8 end |
poelzi@133 | 9 |
poelzi@133 | 10 if not app.html_title.title then |
poelzi@133 | 11 app.html_title.title = _("Help #{id}", { id = id }) |
poelzi@133 | 12 end |
poelzi@133 | 13 |
poelzi@133 | 14 local basepath = request.get_app_basepath() |
poelzi@133 | 15 local found_help = false |
poelzi@133 | 16 -- we try to load any help file that fits best |
poelzi@133 | 17 for x,lang in ipairs{locale.get("lang"), "en"} do |
poelzi@133 | 18 for x,htype in ipairs{"_full", ""} do |
poelzi@133 | 19 local file_name = basepath .. "/locale/help/" .. id .. htype .. "." .. lang .. ".txt.html" |
poelzi@133 | 20 local file = io.open(file_name) |
poelzi@133 | 21 if file ~= nil then |
poelzi@133 | 22 local help_text = file:read("*a") |
poelzi@133 | 23 if #help_text > 0 then |
poelzi@133 | 24 found_help = true |
poelzi@133 | 25 ui.container{ |
poelzi@133 | 26 attr = { class = "wiki" }, |
poelzi@133 | 27 content = function() |
poelzi@133 | 28 slot.put(help_text) |
poelzi@133 | 29 end |
poelzi@133 | 30 } |
poelzi@133 | 31 break |
poelzi@133 | 32 end |
poelzi@133 | 33 end |
poelzi@133 | 34 end |
poelzi@133 | 35 end |
poelzi@133 | 36 |
poelzi@133 | 37 if not found_help then |
poelzi@133 | 38 ui.field.text{ value = _("Missing help text: #{id}.#{lang}.txt", { id = id, lang = locale.get("lang") }) } |
poelzi@133 | 39 end |