diff options
Diffstat (limited to 'src/ffluci')
-rw-r--r-- | src/ffluci/controller/admin/index.lua | 15 | ||||
-rw-r--r-- | src/ffluci/controller/public/example-action.lua | 49 | ||||
-rw-r--r-- | src/ffluci/controller/public/example-simpleview.lua | 27 | ||||
-rw-r--r-- | src/ffluci/controller/public/index.lua | 32 | ||||
-rw-r--r-- | src/ffluci/template.lua | 4 | ||||
-rwxr-xr-x | src/ffluci/view/example-simpleview/foo.htm | 3 | ||||
-rwxr-xr-x | src/ffluci/view/example-simpleview/index.htm | 6 | ||||
-rw-r--r-- | src/ffluci/view/footer.htm | 6 | ||||
-rw-r--r-- | src/ffluci/view/header.htm | 59 | ||||
-rw-r--r-- | src/ffluci/view/hello.htm | 1 | ||||
-rw-r--r-- | src/ffluci/view/menu.htm | 25 |
11 files changed, 60 insertions, 167 deletions
diff --git a/src/ffluci/controller/admin/index.lua b/src/ffluci/controller/admin/index.lua deleted file mode 100644 index 9aec94c86..000000000 --- a/src/ffluci/controller/admin/index.lua +++ /dev/null @@ -1,15 +0,0 @@ -module(..., package.seeall) - -function dispatcher(request) - require("ffluci.template").render("header") - print("Hello there, Mr. Administrator") - require("ffluci.template").render("footer") -end - -menu = { - descr = "Administrative", - order = 10, - entries = { - {action = "index", descr = "Hello"} - } -}
\ No newline at end of file diff --git a/src/ffluci/controller/public/example-action.lua b/src/ffluci/controller/public/example-action.lua deleted file mode 100644 index 538f5d9d0..000000000 --- a/src/ffluci/controller/public/example-action.lua +++ /dev/null @@ -1,49 +0,0 @@ --- 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 diff --git a/src/ffluci/controller/public/example-simpleview.lua b/src/ffluci/controller/public/example-simpleview.lua deleted file mode 100644 index 61f4ad32c..000000000 --- a/src/ffluci/controller/public/example-simpleview.lua +++ /dev/null @@ -1,27 +0,0 @@ --- This example demonstrates the simple view dispatcher which is the --- most simple way to provide content as it directly renders the --- associated template - --- This example consists of: --- ffluci/controller/index/example-simpleview.lua (this file) --- ffluci/view/example-simpleview/index.htm (the template for action "index") --- ffluci/view/example-simpleview/foo.htm (the template for action "foo") --- ffluci/i18n/example-simpleview.de (the german language file for this module) - --- Try the following address(es) in your browser: --- ffluci/index/example-simpleview --- ffluci/index/example-simpleview/index --- ffluci/index/example-simpleview/foo - -module(..., package.seeall) - -dispatcher = require("ffluci.dispatcher").simpleview - -menu = { - descr = "Example Simpleview", - order = 20, - entries = { - {action = "index", descr = "Simpleview Index"}, - {action = "foo", descr = "Simpleview Foo"} - } -}
\ No newline at end of file diff --git a/src/ffluci/controller/public/index.lua b/src/ffluci/controller/public/index.lua deleted file mode 100644 index 4498c77ed..000000000 --- a/src/ffluci/controller/public/index.lua +++ /dev/null @@ -1,32 +0,0 @@ --- This is a very simple example Hello World FFLuCI controller --- See the other examples for more automated controllers - --- Initialise Lua module system -module(..., package.seeall) - --- This is the module dispatcher. It implements the last step of the --- dispatching process. -function dispatcher(request) - require("ffluci.template").render("header") - print("<h2>Hello World!</h2>") - for k,v in pairs(request) do - print("<div>" .. k .. ": " .. v .. "</div>") - end - require("ffluci.template").render("footer") -end - --- The following part is optional it could be useful for menu generators --- An example menu generator is implemented in the template "menu" - -menu = { - -- This is the menu item description - descr = "Hello World", - - -- This is the order level of the menu entry (lowest goes first) - order = 10, - - -- A list of menu entries in the form action => "description" - entries = { - {action = "index", descr = "Hello World"}, - } -}
\ No newline at end of file diff --git a/src/ffluci/template.lua b/src/ffluci/template.lua index 8c7f07f94..3d6457169 100644 --- a/src/ffluci/template.lua +++ b/src/ffluci/template.lua @@ -39,7 +39,7 @@ viewdir = ffluci.fs.dirname(ffluci.util.__file__()) .. "view/" -- memory: Always compile, do not save compiled files, ignore precompiled -- always: Same as "memory" but also saves compiled files -- smart: Compile on demand, save compiled files, update precompiled -compiler_mode = "smart" +compiler_mode = "memory" -- This applies to compiler modes "always" and "smart" @@ -186,4 +186,4 @@ function render(name, scope) -- Now finally render the thing return view() -end
\ No newline at end of file +end diff --git a/src/ffluci/view/example-simpleview/foo.htm b/src/ffluci/view/example-simpleview/foo.htm deleted file mode 100755 index a0df536f1..000000000 --- a/src/ffluci/view/example-simpleview/foo.htm +++ /dev/null @@ -1,3 +0,0 @@ -<%+header%> -<h1>bar</h1> -<%+footer%>
\ No newline at end of file diff --git a/src/ffluci/view/example-simpleview/index.htm b/src/ffluci/view/example-simpleview/index.htm deleted file mode 100755 index ffe1ccf71..000000000 --- a/src/ffluci/view/example-simpleview/index.htm +++ /dev/null @@ -1,6 +0,0 @@ -<%+header%> -<p><%:descr This is the Simple View-Example.<br /> -This template is ffluci/view/example-simpleview/index.htm and belongs -to the index-Action.%></p> -<p><%:lan The router's LAN IP-Address is:%> <%~network.lan.ipaddr%></p> -<%+footer%>
\ No newline at end of file diff --git a/src/ffluci/view/footer.htm b/src/ffluci/view/footer.htm index 17c7245b6..c43cbb7e4 100644 --- a/src/ffluci/view/footer.htm +++ b/src/ffluci/view/footer.htm @@ -1,3 +1,7 @@ -</div> + </div> + <div class="clear"></div> +</div></div> + +<div class="separator magenta bold">FFLuCI 0.1 - Freifunk Lua Configuration Interface</div> </body> </html>
\ No newline at end of file diff --git a/src/ffluci/view/header.htm b/src/ffluci/view/header.htm index f47388a42..2c0836be5 100644 --- a/src/ffluci/view/header.htm +++ b/src/ffluci/view/header.htm @@ -1,9 +1,56 @@ -<% require("ffluci.http").htmlheader() %> -<html> +<% +local req = require("ffluci.dispatcher").request +local menu = require("ffluci.menu").get()[req.category] +require("ffluci.i18n").loadc("default") +require("ffluci.http").htmlheader() +%><?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> <head> -<title>FFLuCI Examples</title> +<link rel="stylesheet" type="text/css" href="<%=media%>/cascade.css" /> +<title>FFLuCI</title> </head> <body> -<h1>FFLuCI</h1> -<%+menu%> -<div id="content">
\ No newline at end of file +<div id="header"> + <div class="headerlogo left"><img src="<%=media%>/logo.png" alt="Freifunk" /></div> + <div class="whitetext smalltext right"> + OpenWRT Kamikaze<br /> + Freifunk Firmware 2.0-dev<br /> + Load average: 1.00 2.00 3.00<br /> + 1.2.3.4 - host1 + </div> + <div> + <span class="headertitle">Freifunk Kamikaze</span><br /> + <span class="whitetext bold"><%:batmanedition Fledermausedition%></span> + </div> +</div> + +<div class="separator yellow bold"> +<%:path Pfad%>: <a href="<%=controller .. "/" .. req.category%>"><%=req.category%></a> +» <a href="<%=controller .. "/" .. req.category .. "/" .. req.module %>"><%=req.module%></a> +» <a href="<%=controller .. "/" .. req.category .. "/" .. req.module .. "/" .. req.action %>"><%=req.action%></a> +</div> + +<div id="columns"><div id="columnswrapper"> + <div class="sidebar left"> + <% for k,v in pairs(menu) do %> + <div<% if v[".contr"] == req.module then %> class="yellowtext"<% end %>><a href="<%=controller.."/"..req.category.."/"..v[".contr"]%>"><%=translate(v[".contr"], v[".descr"])%></a><% + if v[".contr"] == req.module then %> + <ul><% for key,val in ipairs(v) do %> + <li<% if val.action == req.action then %> class="yellowtext"<% end %>><a href="<%=controller.."/"..req.category.."/"..req.module.."/"..val.action%>"><%=translate(val.action, val.descr)%></a></li> + <% end %></ul> + <% end %></div> + <% end %> + </div> + <div class="sidebar right"> + <div><%:webif Weboberfläche%> + <ul> + <li<% if "public" == req.category then %> class="yellowtext"<% end %>><a href="<%=controller%>/public"><%:public Public%></a></li> + <li<% if "admin" == req.category then %> class="yellowtext"<% end %>><a href="<%=controller%>/admin"><%:admin Admin%></a></li> + </ul> + </div> + <% if "admin" == req.category then %> + <div>Konfiguration<ul><li>x Änderungen</li><li>Anwenden</li><li>Zurücksetzen</li></ul></div> + <% end %> + </div> + <div id="content"> diff --git a/src/ffluci/view/hello.htm b/src/ffluci/view/hello.htm deleted file mode 100644 index 8231b61f9..000000000 --- a/src/ffluci/view/hello.htm +++ /dev/null @@ -1 +0,0 @@ -A very little Hello <%=muh%> diff --git a/src/ffluci/view/menu.htm b/src/ffluci/view/menu.htm deleted file mode 100644 index 8d5c597cf..000000000 --- a/src/ffluci/view/menu.htm +++ /dev/null @@ -1,25 +0,0 @@ -<% -local req = require("ffluci.dispatcher").request -local menu = require("ffluci.menu").get()[req.category] -local menu_module = nil -require("ffluci.i18n").loadc("default") -%> -<div id="menu" style="font-size: 0.8em; padding-bottom: 20px"> - <div id="menu_categories"> - <span style="<% if "public" == req.category then write("font-weight: bold") end %>"><a href="<%=controller%>/public"><%:public Public%></a></span> - <span style="<% if "admin" == req.category then write("font-weight: bold") end %>"><a href="<%=controller%>/admin"><%:admin Admin%></a></span> - </div> - <div id="menu_modules"> -<% for k,v in pairs(menu) do -if v[".contr"] == req.module then menu_module = v end %> - <span style="<% if v[".contr"] == req.module then write("font-weight: bold") end %>"><a href="<%=controller.."/"..req.category.."/"..v[".contr"]%>"><%=translate(v[".contr"], v[".descr"])%></a></span> -<% end %> - </div> -<% if menu_module then %> - <div id="menu_actions"> -<% for k,v in ipairs(menu_module) do %> - <span style="<% if v.action == req.action then write("font-weight: bold") end %>"><a href="<%=controller.."/"..req.category.."/"..req.module.."/"..v.action%>"><%=translate(v.action, v.descr)%></a></span> -<% end %> - </div> -<% end %> -</div> |