Module:WikiProject banner/sandbox: Difference between revisions

Content deleted Content added
first attempt at reading config file
m Removed protection from "Module:WikiProject banner/sandbox"
 
(25 intermediate revisions by 2 users not shown)
Line 485:
add_category(category)
end
page_assessment(project,if class, or importance) then
page_assessment(project, class, importance)
end
if args.HOOK_IMPORTANCE then
table.insert(rows, args.HOOK_IMPORTANCE)
Line 861 ⟶ 863:
local category = parent_args.category or args.category or true
local demo_page = parent_args.demo_page
local config, project
if args.project then -- check for config Filepage
args.PROJECTproject = args.project
local config_file = mw.title.new('Template:WikiProject ' .. args.project .. '/config')
if config_file.exists then -- map paraters from config File
local config = mw.loadJsonData(config_file.fullText)
else
args.MAIN_TEXT = config.text
args.MAIN_CAT = config.category
args.class = config.assessment.quality and parent_args.class or nil
args.ASSESSMENT_LINK = config.assessment.link
local tfn = 0
for trigger, cfg in pairs(config.taskforces) do
tfn = tfn + 1 -- increment task force counter
args['tf '..tfn] = parent_args[trigger]
args['TF_'..tfn..'_NAME'] = config.taskforces[trigger].name
args['TF_'..tfn..'_LINK'] = config.taskforces[trigger].link
args['TF_'..tfn..'_NESTED'] = config.taskforces[trigger].nested
args['TF_'..tfn..'_IMAGE'] = config.taskforces[trigger].image
args['TF_'..tfn..'_MAIN_CAT'] = config.taskforces[trigger].category
end
args.attention = config.notes.attention and parent_args[config.notes.attention.parameter] or nil
if config.notes.collaboration then
args.COLL_LINK = config.notes.collaboration.link
args.COLL_TEXT = config.notes.collaboration.name
args.COLL_IMAGE = config.notes.collaboration.image
args['collaboration-candidate'] = parent_args[config.notes.collaboration.candidate.parameter]
args.COLL_CANDIDATE_CAT = config.notes.collaboration.candidate.category
args['collaboration-current'] = parent_args[config.notes.collaboration.current.parameter]
args.COLL_CURRENT_CAT = config.notes.collaboration.current.category
args['collaboration-past'] = parent_args[config.notes.collaboration.past.parameter]
args.COLL_PAST_CAT = config.notes.collaboration.past.category
end
else -- config file does not exist
return nil
end
end
if config then -- use config file
if parent_args.taskforce then -- split comma-separated list
for taskforce in mw.text.gsplit(parent_args.taskforce, ',%s*') do
parent_args[taskforce] = 'yes'
end
end
args, raw_args = require(auxiliary).map_config(config, parent_args) -- map parameters from config page
args.PROJECT = project
end
local on_template_page = false
Line 927 ⟶ 913:
if on_template_page then
local templatepage = require('Module:WikiProject banner/templatepage' .. (sandbox or '')).templatepage
return templatepage(args, raw_args, inactive_status, config)
else
return unknown_parameters