liquid_feedback_frontend
view 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 | 
 line source
     1 local id = param.get_id(atom.string)
     3 if not id then
     4   id = "index"
     5 else
     6   -- sanity check. Only allow letters, digits and _-
     7   id = string.match(id, "[%a%d_-]*")
     8 end
    10 if not app.html_title.title then
    11   app.html_title.title = _("Help #{id}", { id = id })
    12 end
    14 local basepath = request.get_app_basepath() 
    15 local found_help = false
    16 -- we try to load any help file that fits best
    17 for x,lang in ipairs{locale.get("lang"), "en"} do
    18   for x,htype in ipairs{"_full", ""} do
    19     local file_name = basepath .. "/locale/help/" .. id .. htype .. "." .. lang .. ".txt.html"
    20     local file = io.open(file_name)
    21     if file ~= nil then
    22       local help_text = file:read("*a")
    23       if #help_text > 0 then
    24         found_help = true
    25         ui.container{
    26           attr = { class = "wiki" },
    27           content = function()
    28             slot.put(help_text)
    29           end
    30         }
    31         break
    32       end
    33     end
    34   end
    35 end
    37 if not found_help then
    38   ui.field.text{ value = _("Missing help text: #{id}.#{lang}.txt", { id = id, lang = locale.get("lang") }) }
    39 end
