-- <<<-
global theNormlPage := object (WebPage)
title: "Norml Page"
base: theSXPrefix
contents
object (WebForm)
formMethod: "get"
contents
object (WebHiddenValue)
name: "dialog"
value: "Norml"
end
object (WebSubmitInput)
contents
"Translate Norml to HTML"
end
object (WebTextArea)
name: "code"
rows: 24
cols: 80
contents
"* Welcome to Norml\r"
"** The Network ORiented Markup Language\r"
"Norml is a very simple syntax that lets you write\r"
"HTML documents without knowing HTML.\r"
"Just write lines of text, and they will be formatted.\r"
"Paragraphs are separated by blank lines.\r"
"\r"
"To make a link, type the name, a star, and the destination,\r"
"all on one line, like so:\r"
"Here's the Kaleida Home Page!*http://www.kaleida.com\r"
" You can begin the next line with a space,\r"
"to keep the link and the next word from running together.\r"
"\r"
"** Headings are prefixed by one or more stars.\r"
"*** The more stars, the lower level the heading.\r"
"\r"
"\tOutlines are prefixed by tabs\r"
"\tLines with the same number of tabs\r"
"\tare on the same level.\r"
"\t\tLines with more tabs\r"
"\t\t\tare deeper\r"
"\t\t\t\tand deeper!\r"
"\t**** You can put headings in outlines.\r"
"\tAnd here's a link in an outline.*scriptx:hello"
"\r"
"You can type any HTML expressions, and they will\r"
"work as expected, so you can learn at your own pace.\r"
"That's about all there is to it. Now go try your hand at the\r"
"Norml form!*scriptx:norml\r"
end
end
end
registerService theWebServer \
(new WebService \
name: "Norml" \
about: "Translate Norml to HTML!" \
handler: (service request params -> HTML theNormlPage))
registerDialog theWebServer \
(new WebDialog \
name: "Norml" \
handler: (dialog props params ->
local result := undefined
local code := props[@code]
if (code == empty) then (
serviceError theWebServer \
"You've submitted a bogus form!"
) else (
code := decodeURL code
guard (
local gr := object (WebPage)
title: "Norml translated to HTML"
base: ""
contents
parseNorml code
end
result := printHTML gr (new String) ok
) catching
all: caught ok
end
result
)
)
)
-- >>>