Модуль:Песочница/Abiyoyo/Autosorting: различия между версиями
[отпатрулированная версия] | [отпатрулированная версия] |
Содержимое удалено Содержимое добавлено
Abiyoyo (обсуждение | вклад) Нет описания правки |
Abiyoyo (обсуждение | вклад) Нет описания правки |
||
Строка 50:
if options.param == nil then return true end
if frameArgs[options.param] == nil or frameArgs[options.param] == '' then
return true
end
return false
end
Строка 77 ⟶ 75 :
local namespace = mw.title.getCurrentTitle().namespace
if hasValue(
return true
end
Строка 567 ⟶ 565 :
end
--- Gets
local function
if type(node) ~= 'table' then return nil end
if type(node.global) ~= 'table' then return nil end
for k,
if option == 'ignoreNSChecks' then
globals[k] = v▼
globals.ignoreNSChecks = globals.ignoreNSChecks or option
else
▲ globals[k] = v
end▼
end
debLog:write('Globals set: '..mw.dumpObject(globals), 'setGlobalOptions')
return globals
end▼
--- Global options processing
debLog:write('Categorization denied', 'processGlobalOptions')
end▼
local from = frameArgs[globals.fromParamName]
if from ~= nil and from ~= '' then
return false▼
end▼
end
end
return true
end
Строка 633 ⟶ 657 :
end
--- Loads list of strings with rules' IDs from array 'node', and returns an
-- array with those of them, which are also exist as indexes in 'ruleMap'
▲local function entityCheck(frameArgs)
-- @return array with valid rules
▲ local from = frameArgs.from
▲ if from ~= nil and from ~= '' then
▲ if not mw.wikibase.isValidEntityId( from ) then
▲ debLog:write('Entity ID is not valid: |from=' .. from, 'initChecks')
▲ return false
▲ end
▲ if not mw.wikibase.entityExists( from ) then
▲ debLog:write('Entity does not exist: |from=' .. from, 'initChecks')
▲ return false
▲ end
▲ end
▲ return true
▲end
local function getRules(ruleMap, node)
local rules = getConfigNode(node, 'rules')
if type(rules) ~= 'table' then return nil end
local
local i = 1
for _, ruleName in ipairs(rules) do
if ruleMap[ruleName] then
i = i + 1
end
end
if next(
debLog:write('No valid rulenames found', 'getRules', 'warn')
return nil
end
debLog:write('Valid
return
end
--- Executes a function, corresponding to rule with id 'ruleName'
--@param frameArgs table
--@param ruleName string with rule id
local function processRule(frameArgs, ruleName, preset )▼
--@param preset table with preset
--@param node node with rules
--@return result of a called function or nil
local myname = 'processRule'
debLog:write('Invoked with: '..
-- check if function name is present
if isEmpty(
debLog:write('No function specified', myname, 'warn')
return nil
end
-- проверки валидности имени функции обработчика из конфига
local funcName =
if type( funcName ) ~= 'string' then
debLog:write('Function name is not a string: ' .. funcName, myname, 'warn')
Строка 700 ⟶ 713 :
return ''
end
debLog:write(funcName .. '
return funcResult
end
Строка 706 ⟶ 719 :
---Processes rules from array of IDs in ruleList
--@return concatenated result of rules
local function processRuleList(ruleList, node, frameArgs, preset)
local result = ''
for _, ruleName in ipairs(ruleList) do
local ruleResult = processRule(
if ruleResult == nil then
debLog:write('Rule returned nil', 'processRuleList', 'warn')
Строка 782 ⟶ 795 :
-- inits and checks
getConfig(frameArgs)
if not
return nil, '
end
-- get preset enriched with defaults
local preset = getPreset(config.presets, presetName)
Строка 807 ⟶ 820 :
-- process rules and concat result
local rulesResult = processRuleList(ruleList, config.rules, frameArgs, preset)
if rulesResult == nil then
return nil, 'Rules result is nil'
|