gluon-core: make old site_config library reference new one, not the other way around

This commit is contained in:
Matthias Schiffer 2017-08-11 21:29:41 +02:00
parent ee6afaced9
commit 13b325355d
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C
2 changed files with 22 additions and 21 deletions

View File

@ -1,4 +1,23 @@
local site = require 'gluon.site_config' local site = (function()
local config = '/lib/gluon/site.json'
local json = require 'luci.jsonc'
local decoder = json.new()
local sink = decoder:sink()
local file = assert(io.open(config))
while true do
local chunk = file:read(2048)
if not chunk or chunk:len() == 0 then break end
sink(chunk)
end
file:close()
return assert(decoder:get())
end)()
local wrap local wrap

View File

@ -1,29 +1,11 @@
local function get_site_config() local site = require 'gluon.site'
local config = '/lib/gluon/site.json'
local json = require 'luci.jsonc'
local decoder = json.new()
local sink = decoder:sink()
local file = assert(io.open(config))
while true do
local chunk = file:read(2048)
if not chunk or chunk:len() == 0 then break end
sink(chunk)
end
file:close()
return assert(decoder:get())
end
local setmetatable = setmetatable local setmetatable = setmetatable
module 'gluon.site_config' module 'gluon.site_config'
setmetatable(_M, { setmetatable(_M, {
__index = get_site_config(), __index = site(),
}) })
return _M return _M