diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/cbi/luasrc/cbi.lua | 9 | ||||
-rw-r--r-- | libs/web/luasrc/dispatcher.lua | 34 | ||||
-rw-r--r-- | libs/web/luasrc/i18n.lua | 4 |
3 files changed, 31 insertions, 16 deletions
diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua index ebca729bb..18d84e52f 100644 --- a/libs/cbi/luasrc/cbi.lua +++ b/libs/cbi/luasrc/cbi.lua @@ -59,12 +59,15 @@ function load(cbimap, ...) local upldir = "/lib/uci/upload/" local cbidir = luci.util.libpath() .. "/model/cbi/" - assert(luci.fs.stat(cbimap) or luci.fs.stat(cbidir..cbimap..".lua"), - "Model not found!") + assert(luci.fs.stat(cbimap) or + luci.fs.stat(cbidir..cbimap..".lua") or + luci.fs.stat(cbidir..cbimap..".lua.gz"), + "Model not found!") local func, err = loadfile(cbimap) if not func then - func, err = loadfile(cbidir..cbimap..".lua") + func, err = loadfile(cbidir..cbimap..".lua") or + loadfile(cbidir..cbimap..".lua.gz") end assert(func, err) diff --git a/libs/web/luasrc/dispatcher.lua b/libs/web/luasrc/dispatcher.lua index 565e995d1..519473ea4 100644 --- a/libs/web/luasrc/dispatcher.lua +++ b/libs/web/luasrc/dispatcher.lua @@ -355,7 +355,7 @@ end --- Generate the dispatching index using the best possible strategy. function createindex() local path = luci.util.libpath() .. "/controller/" - local suff = ".lua" + local suff = { ".lua", ".lua.gz" } if luci.util.copcall(require, "luci.fastindex") then createindex_fastindex(path, suff) @@ -366,14 +366,16 @@ end --- Generate the dispatching index using the fastindex C-indexer. -- @param path Controller base directory --- @param suffix Controller file suffix -function createindex_fastindex(path, suffix) +-- @param suffixes Controller file suffixes +function createindex_fastindex(path, suffixes) index = {} if not fi then fi = luci.fastindex.new("index") - fi.add(path .. "*" .. suffix) - fi.add(path .. "*/*" .. suffix) + for _, suffix in ipairs(suffixes) do + fi.add(path .. "*" .. suffix) + fi.add(path .. "*/*" .. suffix) + end end fi.scan() @@ -384,12 +386,16 @@ end --- Generate the dispatching index using the native file-cache based strategy. -- @param path Controller base directory --- @param suffix Controller file suffix -function createindex_plain(path, suffix) - local controllers = util.combine( - luci.fs.glob(path .. "*" .. suffix) or {}, - luci.fs.glob(path .. "*/*" .. suffix) or {} - ) +-- @param suffixes Controller file suffixes +function createindex_plain(path, suffixes) + local controllers = { } + for _, suffix in ipairs(suffixes) do + util.combine( + controllers, + luci.fs.glob(path .. "*" .. suffix) or {}, + luci.fs.glob(path .. "*/*" .. suffix) or {} + ) + end if indexcache then local cachedate = fs.mtime(indexcache) @@ -416,7 +422,11 @@ function createindex_plain(path, suffix) index = {} for i,c in ipairs(controllers) do - local module = "luci.controller." .. c:sub(#path+1, #c-#suffix):gsub("/", ".") + local module = "luci.controller." .. c:sub(#path+1, #c):gsub("/", ".") + for _, suffix in ipairs(suffixes) do + module = module:gsub(suffix.."$", "") + end + local mod = require(module) local idx = mod.index diff --git a/libs/web/luasrc/i18n.lua b/libs/web/luasrc/i18n.lua index 4b3adf7eb..4db9c3343 100644 --- a/libs/web/luasrc/i18n.lua +++ b/libs/web/luasrc/i18n.lua @@ -47,7 +47,9 @@ end function load(file, lang, force) lang = lang and lang:gsub("_", "-") or "" if force or not loaded[lang] or not loaded[lang][file] then - local f = loadfile(i18ndir .. file .. "." .. lang .. ".lua") + local f = loadfile(i18ndir .. file .. "." .. lang .. ".lua") or + loadfile(i18ndir .. file .. "." .. lang .. ".lua.gz") + if f then table[lang] = table[lang] or {} setfenv(f, table[lang]) |