Модуль:Сущность/data: различия между версиями
Pok (обсуждение | вклад) Нет описания правки |
Pok (обсуждение | вклад) Нет описания правки |
||
| Строка 697: | Строка 697: | ||
end | end | ||
local function | local function extract_whitelist_search_strings(keyFilter) | ||
if not | if not keyFilter or not keyFilter.hasWhitelist then | ||
return | return nil | ||
end | |||
local strings = {} | |||
for sw, keys in pairs(keyFilter.whitelist) do | |||
if type(keys) == "table" then | |||
for key in pairs(keys) do | |||
strings[#strings + 1] = key | |||
end | |||
end | |||
end | end | ||
if | if #strings == 0 then | ||
return | return nil | ||
end | end | ||
return strings | |||
end | |||
local function content_matches_whitelist(content, searchStrings) | |||
if not searchStrings then | |||
return true | |||
end | |||
if not content then | |||
return false | |||
end | end | ||
for _, s in ipairs(searchStrings) do | |||
if | if string.find(content, s, 1, true) then | ||
return true | return true | ||
end | end | ||
| Строка 756: | Строка 758: | ||
local protoHasWhitelist = next(protoWhitelistSet) ~= nil | local protoHasWhitelist = next(protoWhitelistSet) ~= nil | ||
local anyEntityWhitelist = compHasWhitelist or protoHasWhitelist | local anyEntityWhitelist = compHasWhitelist or protoHasWhitelist | ||
local whitelistSearchStrings = extract_whitelist_search_strings(keyFilter) | |||
local function processEntity(kind, name, isStore) | local function processEntity(kind, name, isStore) | ||
| Строка 769: | Строка 773: | ||
onMissing(kind, name, isStore, tplPath) | onMissing(kind, name, isStore, tplPath) | ||
end | end | ||
return | |||
end | |||
if not content_matches_whitelist(content, whitelistSearchStrings) then | |||
return | return | ||
end | end | ||
| Строка 777: | Строка 785: | ||
end | end | ||
local extra = "" | local extra = "" | ||
local paramNames = get_template_params(tplPath, content) | |||
if dp then | |||
local dataPage = tplPath .. ".json" | local dataPage = tplPath .. ".json" | ||
extra = get_selective_extra(id, dataPage, paramNames) | extra = get_selective_extra(id, dataPage, paramNames) | ||