1 -- This example demonstrates the action dispatcher which invokes
2 -- an appropriate action function named action_"action"
4 -- This example consists of:
5 -- ffluci/controller/index/example-action.lua (this file)
7 -- Try the following address(es) in your browser:
8 -- ffluci/index/example-action
9 -- ffluci/index/example-action/sp
10 -- ffluci/index/example-action/redir
12 module(..., package.seeall)
14 dispatcher = require("ffluci.dispatcher").action
17 descr = "Example Action",
20 {action = "index", descr = "Action-Dispatcher Example"},
21 {action = "sp", descr = "Simple View Template Stealing"},
22 {action = "redir", descr = "Hello World Redirector"}
26 function action_index()
27 require("ffluci.template").render("header")
28 local formvalue = require("ffluci.http").formvalue
30 local x = formvalue("x", nil, true)
32 print(x and "x*x: "..tostring(x*x) or "Set ?x= any number")
33 require("ffluci.template").render("footer")
37 require("ffluci.http")
38 require("ffluci.i18n")
39 require("ffluci.config")
40 require("ffluci.template")
42 -- Try uncommenting the next line
43 -- ffluci.i18n.loadc("example-simpleview")
44 ffluci.template.render("example-simpleview/index")
47 function action_redir()
48 require("ffluci.http").request_redirect("public", "index", "foobar")