diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2014-12-03 15:17:05 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2015-01-08 16:26:20 +0100 |
commit | 1bb4822dca6113f73e3bc89e2acf15935e6f8e92 (patch) | |
tree | 35e16f100466e4e00657199b38bb3d87d52bf73f /applications/luci-app-splash/luasrc/model | |
parent | 9edd0e46c3f880727738ce8ca6ff1c8b85f99ef4 (diff) |
Rework LuCI build system
* Rename subdirectories to their repective OpenWrt package names
* Make each LuCI module its own standalone package
* Deploy a shared luci.mk which is used by each module Makefile
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Diffstat (limited to 'applications/luci-app-splash/luasrc/model')
-rw-r--r-- | applications/luci-app-splash/luasrc/model/cbi/splash/splash.lua | 87 | ||||
-rw-r--r-- | applications/luci-app-splash/luasrc/model/cbi/splash/splashtext.lua | 66 |
2 files changed, 153 insertions, 0 deletions
diff --git a/applications/luci-app-splash/luasrc/model/cbi/splash/splash.lua b/applications/luci-app-splash/luasrc/model/cbi/splash/splash.lua new file mode 100644 index 0000000000..206ef70531 --- /dev/null +++ b/applications/luci-app-splash/luasrc/model/cbi/splash/splash.lua @@ -0,0 +1,87 @@ +--[[ +LuCI - Lua Configuration Interface + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 +]]-- + +require("luci.model.uci") + +m = Map("luci_splash", translate("Client-Splash"), translate("Client-Splash is a hotspot authentification system for wireless mesh networks.")) + +s = m:section(NamedSection, "general", "core", translate("General")) +s.addremove = false + +s:option(Value, "leasetime", translate("Clearance time"), translate("Clients that have accepted the splash are allowed to use the network for that many hours.")) +local redir = s:option(Value, "redirect_url", translate("Redirect target"), translate("Clients are redirected to this page after they have accepted the splash. If this is left empty they are redirected to the page they had requested.")) +redir.rmempty = true + +s:option(Value, "limit_up", translate("Upload limit"), translate("Clients upload speed is limited to this value (kbyte/s)")) +s:option(Value, "limit_down", translate("Download limit"), translate("Clients download speed is limited to this value (kbyte/s)")) + +s:option(DummyValue, "_tmp", "", + translate("Bandwidth limit for clients is only activated when both up- and download limit are set. " .. + "Use a value of 0 here to completely disable this limitation. Whitelisted clients are not limited.")) + +s = m:section(TypedSection, "iface", translate("Interfaces"), translate("Interfaces that are used for Splash.")) + +s.template = "cbi/tblsection" +s.addremove = true +s.anonymous = true + +local uci = luci.model.uci.cursor() + +zone = s:option(ListValue, "zone", translate("Firewall zone"), + translate("Splash rules are integrated in this firewall zone")) + +uci:foreach("firewall", "zone", + function (section) + zone:value(section.name) + end) + +iface = s:option(ListValue, "network", translate("Network"), + translate("Intercept client traffic on this Interface")) + +uci:foreach("network", "interface", + function (section) + if section[".name"] ~= "loopback" then + iface:value(section[".name"]) + end + end) + +uci:foreach("network", "alias", + function (section) + iface:value(section[".name"]) + end) + + +s = m:section(TypedSection, "whitelist", translate("Whitelist"), + translate("MAC addresses of whitelisted clients. These do not need to accept the splash and are not bandwidth limited.")) + +s.template = "cbi/tblsection" +s.addremove = true +s.anonymous = true +s:option(Value, "mac", translate ("MAC Address")) + + +s = m:section(TypedSection, "blacklist", translate("Blacklist"), + translate("MAC addresses in this list are blocked.")) + +s.template = "cbi/tblsection" +s.addremove = true +s.anonymous = true +s:option(Value, "mac", translate ("MAC Address")) + +s = m:section(TypedSection, "subnet", translate("Allowed hosts/subnets"), + translate("Destination hosts and networks that are excluded from splashing, i.e. they are always allowed.")) + +s.template = "cbi/tblsection" +s.addremove = true +s.anonymous = true +s:option(Value, "ipaddr", translate("IP Address")) +s:option(Value, "netmask", translate("Netmask"), translate("optional when using host addresses")).rmempty = true + +return m diff --git a/applications/luci-app-splash/luasrc/model/cbi/splash/splashtext.lua b/applications/luci-app-splash/luasrc/model/cbi/splash/splashtext.lua new file mode 100644 index 0000000000..00c5aba947 --- /dev/null +++ b/applications/luci-app-splash/luasrc/model/cbi/splash/splashtext.lua @@ -0,0 +1,66 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2008 Steven Barth <steven@midlink.org> +Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> +Copyright 2010 Manuel Munz <freifunk@somakoma.de> + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 +]]-- + +local fs = require "nixio.fs" + +local splashtextfile = "/usr/lib/luci-splash/splashtext.html" +local splashtextinclude = "/usr/lib/luci-splash/splashtextinclude.html" + + +f = SimpleForm("splashtext", translate("Edit the complete splash text"), + translate("You can enter your own text that is displayed to clients here.<br />" .. + "It is possible to use the following markers: " .. + "###COMMUNITY###, ###COMMUNITY_URL###, ###CONTACTURL###, ###LEASETIME###, ###LIMIT### and ###ACCEPT###.")) + +t = f:field(TextValue, "text") +t.rmempty = true +t.rows = 30 +function t.cfgvalue() + return fs.readfile(splashtextfile) or "" +end + +function f.handle(self, state, data) + if state == FORM_VALID then + if data.text then + fs.writefile(splashtextfile, data.text:gsub("\r\n", "\n")) + else + fs.unlink(splashtextfile) + end + end + return true +end + +g = SimpleForm("splashtextinclude", translate("Include your own text in the default splash"), + translate("As an alternative to editing the complete splash text you can also just include some custom text in the default splash page by entering it here.")) + +t = g:field(TextValue, "text") +t.rmempty = true +t.rows = 30 +function t.cfgvalue() + return fs.readfile(splashtextinclude) or "" +end + +function g.handle(self, state, data) + if state == FORM_VALID then + if data.text then + fs.writefile(splashtextinclude, data.text:gsub("\r\n", "\n")) + else + fs.unlink(splashtextinclude) + end + end + return true +end + + +return f, g |