liquid_feedback_frontend
annotate app/main/help/show.lua @ 154:6b6c82f9ca9f
speedup member image loading when non set
we can add the location of the default file directy instead of going through another slow request
we can add the location of the default file directy instead of going through another slow request
author | Daniel Poelzleithner <poelzi@poelzi.org> |
---|---|
date | Fri Oct 08 15:25:10 2010 +0200 (2010-10-08) |
parents | fa55c8ded9fd |
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 |