build: luabuild gccbuild
-luabuild: lua$(LUA_TARGET) i18n
+luabuild: i18n lua$(LUA_TARGET)
gccbuild: compile
compile:
clean: luaclean
-i18n: luasource
- [ -n "$(XSLTPROC)" ] && for i in dist$(LUCI_MODULEDIR)/i18n/*.xml; do [ -f "$$i" ]\
- && { $(XSLTPROC) $(MAKEPATH)i18n-lua-xhtml1.xsl $$i > $${i/.xml/.lua}; rm $$i; }; done || true
+i18n:
+ [ -n "$(XSLTPROC)" ] && for i in luasrc/i18n/*.xml; do [ -f "$$i" ]\
+ && $(XSLTPROC) $(MAKEPATH)i18n-lua-xhtml1.xsl $$i > $${i/.xml/.lua}; done || true
luasource:
mkdir -p dist$(LUA_MODULEDIR)
cp -a lua/* dist$(LUA_MODULEDIR) -R 2>/dev/null || true
cp -a htdocs/* dist$(HTDOCS) -R 2>/dev/null || true
for i in $$(find dist -name .svn); do rm $$i -rf || true; done
+ for i in dist$(LUCI_MODULEDIR)/i18n/*.xml; do [ -f "$$i" ] && rm $$i; done || true
luastrip: luasource
-- i18n loaded?
if type(luci.i18n) == "table" then
- local key = config:gsub("[^%w]+", "")
+ local key = config and config:gsub("[^%w]+", "") or ""
if section then key = key .. "_" .. section:lower():gsub("[^%w]+", "") end
- if option then key = key .. "_" .. option:lower():gsub("[^%w]+", "") end
+ if option then key = key .. "_" .. tostring(option):lower():gsub("[^%w]+", "") end
self.title = title or luci.i18n.translate( key, option or section or config )
self.description = description or luci.i18n.translate( key .. "_desc", "" )
function Table.__init__(self, form, data, ...)
local datasource = {}
+ datasource.config = "table"
self.data = data
function datasource.get(self, section, option)
- return data[option]
+ return data[section][option]
end
- AbstractSection.__init__(self, datasource, nil, ...)
+ AbstractSection.__init__(self, datasource, "table", ...)
+ self.template = "cbi/tblsection"
end
function Table.cfgsections(self)
-- @param value String value containing the data to escape
-- @return String value containing the escaped data
function pcdata(value)
+ if not value then return end
+ value = tostring(value)
value = value:gsub("&", "&")
value = value:gsub('"', """)
value = value:gsub("'", "'")
end
if leases then
- v = m2:section(TypedSection, "_virtual", translate("dhcp_leases_active"))
+ v = m2:section(Table, leases, translate("dhcp_leases_active"))
v.anonymous = true
v.rowcolors = true
- v.template = "cbi/tblsection"
- function v.cfgsections(self)
- local sections = {}
- for i=1,#leases do
- table.insert(sections, i)
- end
- return sections
- end
-
- ip = v:option(DummyValue, "ip", translate("ipaddress"))
- function ip.cfgvalue(self, section)
- return leases[section][3]
- end
+ ip = v:option(DummyValue, 3, translate("ipaddress"))
- mac = v:option(DummyValue, "mac", translate("macaddress"))
- function mac.cfgvalue(self, section)
- return leases[section][2]
- end
+ mac = v:option(DummyValue, 2, translate("macaddress"))
- ltime = v:option(DummyValue, "time", translate("dhcp_timeremain"))
- function ltime.cfgvalue(self, section)
+ ltime = v:option(DummyValue, 1, translate("dhcp_timeremain"))
+ function ltime.cfgvalue(self, ...)
+ local value = DummyValue.cfgvalue(self, ...)
return luci.tools.webadmin.date_format(
- os.difftime(tonumber(leases[section][1]), os.time())
+ os.difftime(tonumber(value), os.time())
)
end
end