liquid_feedback_frontend

diff 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.
author Daniel Poelzleithner <poelzi@poelzi.org>
date Tue Oct 05 16:18:39 2010 +0200 (2010-10-05)
parents
children d0f99272f675
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/app/main/help/show.lua	Tue Oct 05 16:18:39 2010 +0200
     1.3 @@ -0,0 +1,39 @@
     1.4 +local id = param.get_id(atom.string)
     1.5 +
     1.6 +if not id then
     1.7 +  id = "index"
     1.8 +else
     1.9 +  -- sanity check. Only allow letters, digits and _-
    1.10 +  id = string.match(id, "[%a%d_-]*")
    1.11 +end
    1.12 +
    1.13 +if not app.html_title.title then
    1.14 +  app.html_title.title = _("Help #{id}", { id = id })
    1.15 +end
    1.16 +
    1.17 +local basepath = request.get_app_basepath() 
    1.18 +local found_help = false
    1.19 +-- we try to load any help file that fits best
    1.20 +for x,lang in ipairs{locale.get("lang"), "en"} do
    1.21 +  for x,htype in ipairs{"_full", ""} do
    1.22 +    local file_name = basepath .. "/locale/help/" .. id .. htype .. "." .. lang .. ".txt.html"
    1.23 +    local file = io.open(file_name)
    1.24 +    if file ~= nil then
    1.25 +      local help_text = file:read("*a")
    1.26 +      if #help_text > 0 then
    1.27 +        found_help = true
    1.28 +        ui.container{
    1.29 +          attr = { class = "wiki" },
    1.30 +          content = function()
    1.31 +            slot.put(help_text)
    1.32 +          end
    1.33 +        }
    1.34 +        break
    1.35 +      end
    1.36 +    end
    1.37 +  end
    1.38 +end
    1.39 +
    1.40 +if not found_help then
    1.41 +  ui.field.text{ value = _("Missing help text: #{id}.#{lang}.txt", { id = id, lang = locale.get("lang") }) }
    1.42 +end

Impressum / About Us