Several escaping fixes
Updated XML translation system Use the new Table widget for DHCP leases
This commit is contained in:
parent
1d4196b3ff
commit
8e4afe1210
4 changed files with 20 additions and 29 deletions
|
@ -8,16 +8,16 @@ all: build
|
|||
|
||||
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)
|
||||
|
@ -28,6 +28,7 @@ luasource:
|
|||
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
|
||||
|
|
|
@ -92,10 +92,10 @@ function Node._i18n(self, config, section, option, title, description)
|
|||
-- 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", "" )
|
||||
|
@ -483,13 +483,15 @@ Table = class(AbstractSection)
|
|||
|
||||
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)
|
||||
|
|
|
@ -199,6 +199,8 @@ end
|
|||
-- @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("'", "'")
|
||||
|
|
|
@ -30,33 +30,19 @@ if leasefp then
|
|||
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, 3, translate("ipaddress"))
|
||||
|
||||
ip = v:option(DummyValue, "ip", translate("ipaddress"))
|
||||
function ip.cfgvalue(self, section)
|
||||
return leases[section][3]
|
||||
end
|
||||
mac = v:option(DummyValue, 2, translate("macaddress"))
|
||||
|
||||
mac = v:option(DummyValue, "mac", translate("macaddress"))
|
||||
function mac.cfgvalue(self, section)
|
||||
return leases[section][2]
|
||||
end
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue