gluon/package/gluon-announce/files/usr/lib/lua/gluon/announce.lua
Jan-Philipp Litza 15a80aaffd Switch from luci-lib-json to luci-lib-jsonc
Apart from replacing a patch for the former by two patches for latter,
this involved minimal adaptations of the lua scripts in the following
packages:

* gluon-announce
* gluon-announced
* gluon-mesh-batman-adv-core
* gluon-status-page
2015-08-30 21:05:13 +02:00

34 lines
601 B
Lua

#!/usr/bin/lua
module('gluon.announce', package.seeall)
fs = require 'nixio.fs'
uci = require('luci.model.uci').cursor()
util = require 'luci.util'
local function collect_entry(entry)
if fs.stat(entry, 'type') == 'dir' then
return collect_dir(entry)
else
return setfenv(loadfile(entry), _M)()
end
end
function collect_dir(dir)
local ret = { [{}] = true }
for entry in fs.dir(dir) do
if entry:sub(1, 1) ~= '.' then
local ok, val = pcall(collect_entry, dir .. '/' .. entry)
if ok then
ret[entry] = val
else
io.stderr:write(val, '\n')
end
end
end
return ret
end