summaryrefslogtreecommitdiffhomepage
path: root/src/ffluci/controller/public/example-action.lua
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2008-03-02 21:52:58 +0000
committerJo-Philipp Wich <jow@openwrt.org>2008-03-02 21:52:58 +0000
commit3f5de3273c9e103b4909802e339db06fe0b53312 (patch)
tree793ef66c9456665f7b472e214d79b1078fccebe8 /src/ffluci/controller/public/example-action.lua
* new project: ff-luci - Freifunk Lua Configuration Interface
Diffstat (limited to 'src/ffluci/controller/public/example-action.lua')
-rw-r--r--src/ffluci/controller/public/example-action.lua49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/ffluci/controller/public/example-action.lua b/src/ffluci/controller/public/example-action.lua
new file mode 100644
index 0000000000..538f5d9d05
--- /dev/null
+++ b/src/ffluci/controller/public/example-action.lua
@@ -0,0 +1,49 @@
+-- This example demonstrates the action dispatcher which invokes
+-- an appropriate action function named action_"action"
+
+-- This example consists of:
+-- ffluci/controller/index/example-action.lua (this file)
+
+-- Try the following address(es) in your browser:
+-- ffluci/index/example-action
+-- ffluci/index/example-action/sp
+-- ffluci/index/example-action/redir
+
+module(..., package.seeall)
+
+dispatcher = require("ffluci.dispatcher").action
+
+menu = {
+ descr = "Example Action",
+ order = 30,
+ entries = {
+ {action = "index", descr = "Action-Dispatcher Example"},
+ {action = "sp", descr = "Simple View Template Stealing"},
+ {action = "redir", descr = "Hello World Redirector"}
+ }
+}
+
+function action_index()
+ require("ffluci.template").render("header")
+ local formvalue = require("ffluci.http").formvalue
+
+ local x = formvalue("x", nil, true)
+
+ print(x and "x*x: "..tostring(x*x) or "Set ?x= any number")
+ require("ffluci.template").render("footer")
+end
+
+function action_sp()
+ require("ffluci.http")
+ require("ffluci.i18n")
+ require("ffluci.config")
+ require("ffluci.template")
+
+ -- Try uncommenting the next line
+ -- ffluci.i18n.loadc("example-simpleview")
+ ffluci.template.render("example-simpleview/index")
+end
+
+function action_redir()
+ require("ffluci.http").request_redirect("public", "index", "foobar")
+end \ No newline at end of file