Модуль:Песочница/Pok: различия между версиями
Pok (обсуждение | вклад) Нет описания правки |
Pok (обсуждение | вклад) Нет описания правки |
||
| Строка 1: | Строка 1: | ||
local p = {} | local p = {} | ||
local | local p = {} | ||
local BASE_USER = "IanComradeBot/" | |||
local CURRENT_PROJECT | |||
local function find_ancestor_arg(name) | |||
local f = mw.getCurrentFrame() | local f = mw.getCurrentFrame() | ||
while f do | |||
local | local v = f:getArgument(name) | ||
if | if v and v ~= "" then return v end | ||
f = f:getParent() | |||
end | end | ||
return nil | return nil | ||
end | end | ||
local function | local function resolve_project(pagePath) | ||
if | if pagePath and pagePath ~= "" then return pagePath end | ||
if | if CURRENT_PROJECT and CURRENT_PROJECT ~= "" then return CURRENT_PROJECT end | ||
return | local candidate = find_ancestor_arg("Название") or find_ancestor_arg("project") or find_ancestor_arg("path") | ||
if candidate and candidate ~= "" then | |||
CURRENT_PROJECT = candidate | |||
return candidate | |||
end | |||
return nil | |||
end | end | ||
local function get_module_name(pagePath) | local function get_module_name(pagePath) | ||
local | local project = resolve_project(pagePath) or "default" | ||
return "Module:" .. BASE_USER .. project .. "/data" | |||
return "Module:" .. | |||
end | end | ||
p.get_module_name = get_module_name | p.get_module_name = get_module_name | ||
p._debug_get_cached = function() return CURRENT_PROJECT end | |||
local function load_cached_data(moduleName) | local function load_cached_data(moduleName) | ||