# HG changeset patch # User Daniel Poelzleithner # Date 1286288319 -7200 # Node ID fa55c8ded9fd55c8239f02629929d12eca0bb91e # Parent 90d16ad8d6d213713d9a511532a259774349539a 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. diff -r 90d16ad8d6d2 -r fa55c8ded9fd .hgignore --- a/.hgignore Tue Oct 05 14:30:29 2010 +0200 +++ b/.hgignore Tue Oct 05 16:18:39 2010 +0200 @@ -1,2 +1,5 @@ tmp -.+~ \ No newline at end of file +.+~ + +syntax: regexp +^locale/help/.*\.html diff -r 90d16ad8d6d2 -r fa55c8ded9fd app/main/draft/new.lua --- a/app/main/draft/new.lua Tue Oct 05 14:30:29 2010 +0200 +++ b/app/main/draft/new.lua Tue Oct 05 16:18:39 2010 +0200 @@ -56,9 +56,39 @@ { id = "rocketwiki", name = "RocketWiki" }, { id = "compat", name = _"Traditional wiki syntax" } }, + attr = {id = "formatting_engine"}, foreign_id = "id", foreign_name = "name" } + ui.tag{ + tag = "div", + content = function() + ui.tag{ + tag = "label", + attr = { class = "ui_field_label" }, + content = function() slot.put(" ") end, + } + ui.tag{ + content = function() + ui.link{ + text = _"Syntax help", + module = "help", + view = "show", + id = "wikisyntax", + attr = {onClick="this.href=this.href.replace(/wikisyntax[^.]*/g, 'wikisyntax_'+getElementById('formatting_engine').value)"} + } + slot.put(" ") + ui.link{ + text = _"(new window)", + module = "help", + view = "show", + id = "wikisyntax", + attr = {target = "_blank", onClick="this.href=this.href.replace(/wikisyntax[^.]*/g, 'wikisyntax_'+getElementById('formatting_engine').value)"} + } + end + } + end + } ui.field.text{ label = _"Content", name = "content", diff -r 90d16ad8d6d2 -r fa55c8ded9fd app/main/help/show.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/main/help/show.lua Tue Oct 05 16:18:39 2010 +0200 @@ -0,0 +1,39 @@ +local id = param.get_id(atom.string) + +if not id then + id = "index" +else + -- sanity check. Only allow letters, digits and _- + id = string.match(id, "[%a%d_-]*") +end + +if not app.html_title.title then + app.html_title.title = _("Help #{id}", { id = id }) +end + +local basepath = request.get_app_basepath() +local found_help = false +-- we try to load any help file that fits best +for x,lang in ipairs{locale.get("lang"), "en"} do + for x,htype in ipairs{"_full", ""} do + local file_name = basepath .. "/locale/help/" .. id .. htype .. "." .. lang .. ".txt.html" + local file = io.open(file_name) + if file ~= nil then + local help_text = file:read("*a") + if #help_text > 0 then + found_help = true + ui.container{ + attr = { class = "wiki" }, + content = function() + slot.put(help_text) + end + } + break + end + end + end +end + +if not found_help then + ui.field.text{ value = _("Missing help text: #{id}.#{lang}.txt", { id = id, lang = locale.get("lang") }) } +end diff -r 90d16ad8d6d2 -r fa55c8ded9fd app/main/initiative/new.lua --- a/app/main/initiative/new.lua Tue Oct 05 14:30:29 2010 +0200 +++ b/app/main/initiative/new.lua Tue Oct 05 16:18:39 2010 +0200 @@ -128,10 +128,40 @@ { id = "rocketwiki", name = "RocketWiki" }, { id = "compat", name = _"Traditional wiki syntax" } }, + attr = {id = "formatting_engine"}, foreign_id = "id", foreign_name = "name", value = param.get("formatting_engine") } + ui.tag{ + tag = "div", + content = function() + ui.tag{ + tag = "label", + attr = { class = "ui_field_label" }, + content = function() slot.put(" ") end, + } + ui.tag{ + content = function() + ui.link{ + text = _"Syntax help", + module = "help", + view = "show", + id = "wikisyntax", + attr = {onClick="this.href=this.href.replace(/wikisyntax[^.]*/g, 'wikisyntax_'+getElementById('formatting_engine').value)"} + } + slot.put(" ") + ui.link{ + text = _"(new window)", + module = "help", + view = "show", + id = "wikisyntax", + attr = {target = "_blank", onClick="this.href=this.href.replace(/wikisyntax[^.]*/g, 'wikisyntax_'+getElementById('formatting_engine').value)"} + } + end + } + end + } ui.field.text{ label = _"Draft", name = "draft", diff -r 90d16ad8d6d2 -r fa55c8ded9fd locale/help/wikisyntax.en.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locale/help/wikisyntax.en.txt Tue Oct 05 16:18:39 2010 +0200 @@ -0,0 +1,6 @@ +==== Wiki Help ==== + +You can choose between this different syntaxes: + +[wikisyntax_rocketwiki.html RocketWiki] +[wikisyntax_compat.html Traditional wiki syntax] diff -r 90d16ad8d6d2 -r fa55c8ded9fd locale/help/wikisyntax_compat.en.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locale/help/wikisyntax_compat.en.txt Tue Oct 05 16:18:39 2010 +0200 @@ -0,0 +1,5 @@ +<- [wikisyntax.html Wiki Help] + +==== CompatWiki ==== + +FIXME \ No newline at end of file diff -r 90d16ad8d6d2 -r fa55c8ded9fd locale/help/wikisyntax_rocketwiki.en.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/locale/help/wikisyntax_rocketwiki.en.txt Tue Oct 05 16:18:39 2010 +0200 @@ -0,0 +1,72 @@ +<- [wikisyntax.html Wiki Help] + +==== RocketWiki ==== +- ++Headings++ +-- ==== Main Heading (H1) ==== +-- === Heading (H2) === +-- == Sub-Heading (H3) == +-- = Sub-Sub-Heading (H4) = +- ++Horizontal line++ +-- --- +- ++Unnumbered lists++ +-- - Toplevel Entry +-- -- Sub Entry +- ++Numbered list++ +-- # Toplevel Entry +-- ## Sub Entry +- ++Font style++ +-- {{**bold**}} +-- {{//italic//}} +-- {{__underlined__}} +-- {{++big++}} +-- {{%%small%%}} +-- {{||monospaced||}} +-- {{&&no line break&&}} +-- {{$$stylename: use a specific CSS style$$}} +-- {{{{no special interpretation of formatting characters}}}} +- ++Quotes++ +-- {{""normal english quotes""}} +-- {{"""single english quotes"""}} +-- {{,,normal german quotes''}} +-- {{,,,single german quotes'''}} +-- {{<>}} +-- {{<<>>}} +- ++Text flow++ +-- non-breaking(_)space +-- soft(-)hypen +- ++Special characters++ +-- {{{EUR}}} sign +-- German umlauts: {{{Ae} {Oe} {Ue} {ae} {oe} {ue}}} +-- German SZ-ligature: {{{sz} or {ss}}} +-- Mid{{{.}}}dot +-- Ellipsis {{{...}}} +-- Arrows {{{->} {=>} {<->}}} etc. +-- {{{C} 2009, Registered{R}, Trademark{TM}}} +-- {{360{deg} 0{'} 0{''}}} => 360{deg} 0{'} 0{''} +-- {{{1/4} + {1/2} = {3/4}}} => {1/4} + {1/2} = {3/4} +-- {{10{%o} = 1%}} => 10{%o} = 1% +-- {{(5 {-} 1) {x} 3 {/} 4 {=} 3}} => (5 {-} 1) {x} 3 {/} 4 {=} 3 +- ++Dashes++ +-- En{{{--}}}Dash +-- Em{{{---}}}Dash +- ++Images++ +-- {{[http://example.org/embedded_image.jpg]}} +-- {{[http://example.org/embedded_image.jpeg]}} +-- {{[http://example.org/embedded_image.gif]}} +-- {{[http://example.org/embedded_image.png]}} +-- {{[stylename: http://example.org/image_with_CSS_style.png]}} +-- {{[http://example.org/image.png Image with alternative text]}} +- ++Links++ +-- {{[http://example.org/ normal link with text]}} +-- {{[http://example.org/ http://example.org/image_for_link.png]}} +-- {{[http://example.org/ http://example.org/image.png Alternative text]}} +-- {{[http://example.org/image.png! Link to image]}} +- ++DIVs++ +-- @@id: + DIV contents + @@ +- ++CSS styles for multiple paragraphs++ +-- $$style: + ... + $$ +