Module:Higher education task force: Difference between revisions
Appearance
Content deleted Content added
No edit summary |
No edit summary |
||
Line 110: | Line 110: | ||
--[[------------------------< generateTaskforceParameters >--------------------------------- |
|||
Generates the WikiProject banner parameters for a comma-separated list of task force codes. |
|||
Parameters: |
|||
* frame: The frame object. |
|||
Returns: |
|||
* A string containing the WikiProject banner parameters for the task forces. |
|||
]]---------------------------------------------------------------------------- |
|||
function p.generateTaskforceParameters(frame,trable) |
|||
local args = getArgs(frame, { parentFirst = true }) |
|||
local taskforcesStr = p._main(args) |
|||
taskforcesStr = args[1] |
|||
if not taskforcesStr then |
|||
return "oops" .. args[2] |
|||
end |
|||
local taskforceCodes = mw.text.split(taskforcesStr, ",", true, true) -- Split by comma, trim whitespace, remove empty strings |
|||
local paramsStr = "" |
|||
local tfCounter = 1 |
|||
for _, code in ipairs(taskforceCodes) do |
|||
local tfData = p._main({code}) |
|||
if tfData then |
|||
trable = p.tab2arg(trable,string.format("|tf %d=%dyes", tfCounter,tfCounter)) |
|||
paramsStr = paramsStr .. "\n\n\n" |
|||
trable = p.tab2arg(trable,string.format("|TF_%d_LINK=%s", tfCounter, tfData.link)) |
|||
paramsStr = paramsStr .. "\n\n\n" |
|||
trable = p.tab2arg(trable,string.format("|TF_%d_NAME=%s", tfCounter, tfData.name)) |
|||
paramsStr = paramsStr .. "\n\n\n" |
|||
trable = p.tab2arg(trable,string.format("|TF_%d_NESTED=%s", tfCounter, tfData.nested)) |
|||
paramsStr = paramsStr .. "\n\n\n" |
|||
trable = p.tab2arg(trable,string.format("|TF_%d_IMAGE=%s", tfCounter, tfData.image)) |
|||
paramsStr = paramsStr .. "\n\n\n" |
|||
trable = p.tab2arg(trable,string.format("|TF_%d_MAIN_CAT=%s", tfCounter, tfData.category)) |
|||
paramsStr = paramsStr .. "\n\n\n" |
|||
tfCounter = tfCounter + 1 |
|||
end |
|||
end |
|||
return trable |
|||
end |
|||
function p.kludge(frame) |
|||
local retstr = [===[{{#invoke:WikiProject banner|main |
|||
|PROJECT = Higher education/lua |
|||
|BANNER_NAME = Template:WikiProject Higher education |
|||
|substcheck=<includeonly>{{subst:</includeonly><includeonly>substcheck}}</includeonly> |
|||
|category={{{category|}}} |
|||
|listas={{{listas|}}} |
|||
|IMAGE_LEFT = Graduation hat.svg |
|||
|QUALITY_SCALE = extended |
|||
|class={{{class|}}} |
|||
|ASSESSMENT_LINK = Wikipedia:WikiProject Higher education/Assessment |
|||
|ASSESSMENT_CAT = Higher education |
|||
|MAIN_ARTICLE = \[\[higher education\]\], \[\[university|universities\]\] and \[\[college\]\]s |
|||
|MAIN_TEXT= This _PAGETYPE_ is within the scope of '''\[\[Wikipedia:WikiProject Higher education|WikiProject Higher education\]\]''', a collaborative effort to improve the coverage of \[\[higher education\]\], \[\[university|universities\]\], and [[college]]s on Wikipedia. Please visit the project page to join the \[\[Wikipedia talk:WikiProject Higher education|discussion\]\], and see the project's \[\[Wikipedia:College and university article guideline|article guideline\]\] for useful advice. |
|||
]===] |
|||
retstr = retstr .. p.generateTaskforceParameters(frame) |
|||
retstr = retstr .. [===[|MAIN_CAT = WikiProject Higher education articles |
|||
|attention={{{attention|}}} |
|||
|collaboration-candidate={{{collaboration-nom|}}} |
|||
|collaboration-current={{{collaboration-now|}}} |
|||
|collaboration-past={{{collaboration-past|}}} |
|||
|COLL_LINK = Wikipedia:WikiProject Higher education/COTM#{{FULLPAGENAME}} |
|||
|COLL_TEXT = Collaboration of the Month |
|||
|COLL_IMAGE = WPUNICOTF.png |
|||
|COLL_CANDIDATE_CAT = WikiProject Universities COTM candidates |
|||
|COLL_CURRENT_CAT = Higher education collaborations |
|||
|COLL_PAST_CAT = Higher education collaborations |
|||
}}<noinclude> |
|||
{{documentation}} |
|||
</noinclude>]===] |
|||
return retstr |
|||
end |
|||
function p.ma1(frame,s1,s2) |
function p.ma1(frame,s1,s2) |
||
frame[s1]=s2 |
frame[s1]=s2 |
||
Line 234: | Line 157: | ||
end |
end |
||
function p.mrkludge(frame) |
|||
local trable={} |
|||
trable = p.tab2arg(trable,"|category={{{category|}}}") |
|||
trable = p.tab2arg(trable,"|listas={{{listas|}}}") |
|||
trable = p.tab2arg(trable,"|QUALITY_SCALE = extended") |
|||
trable = p.tab2arg(trable,"|class={{{class|}}}") |
|||
trable = p.tab2arg(trable,"|ASSESSMENT_LINK = Wikipedia:WikiProject Higher education/Assessment") |
|||
trable = p.tab2arg(trable,"|ASSESSMENT_CAT = Higher education") |
|||
trable = p.tab2arg(trable,"|MAIN_ARTICLE = [[higher education]], [[university|universities]] and [[college]]s") |
|||
trable = p.tab2arg(trable,"|MAIN_TEXT= This _PAGETYPE_ is within the scope of '''[[Wikipedia:WikiProject Higher education|WikiProject Higher education]]''', a collaborative effort to improve the coverage of [[higher education]], [[university|universities]], and [[college]]s on Wikipedia. Please visit the project page to join the [[Wikipedia talk:WikiProject Higher education|discussion]], and see the project's [[Wikipedia:College and university article guideline|article guideline]] for useful advice.") |
|||
trable = p.generateTaskforceParameters(frame,trable) |
|||
trable = p.tab2arg(trable,"|MAIN_CAT = WikiProject Higher education articles") |
|||
trable = p.tab2arg(trable,"|attention={{{attention|}}}") |
|||
trable = p.tab2arg(trable,"|collaboration-candidate={{{collaboration-nom|}}}") |
|||
trable = p.tab2arg(trable,"|collaboration-current={{{collaboration-now|}}}") |
|||
trable = p.tab2arg(trable,"|collaboration-past={{{collaboration-past|}}}") |
|||
trable = p.tab2arg(trable,"|COLL_LINK=Wikipedia:WikiProject Higher education/COTM#{{FULLPAGENAME}}") |
|||
trable = p.tab2arg(trable,"|COLL_TEXT=Collaboration of the Month") |
|||
trable = p.tab2arg(trable,"|COLL_CANDIDATE_CAT=WikiProject Universities COTM candidates") |
|||
trable = p.tab2arg(trable,"|COLL_CURRENT_CAT=Higher education collaborations") |
|||
trable = p.tab2arg(trable,"|COLL_PAST_CAT=Higher education collaborations") |
|||
p.ma1(trable,"substcheck","<includeonly>{{subst:</includeonly><includeonly>substcheck}}</includeonly>") |
|||
p.ma1(trable,"COLL_IMAGE","WPUNICOTF.png") |
|||
trable["1"]="main" |
|||
trable["PROJECT"]="Higher education/lua" |
|||
trable["BANNER_NAME"] = "Template:WikiProject Higher education" |
|||
trable = p.tab2arg(trable,"|IMAGE_LEFT=Graduation hat.svg") |
|||
return banner.main(trable) |
|||
end |
|||
function p.printargs(frame) |
function p.printargs(frame) |
Revision as of 20:55, 21 April 2025
require("strict")
local yesNo = require("Module:Yesno")
local getArgs = require("Module:Arguments").getArgs
local banner = require("Module:WikiProject_banner")
local p = {}
--[[------------------------< _main >---------------------------------
Internal function to retrieve data for a task force.
]]----------------------------------------------------------------------------
function p._main(args, data)
local dataModule = require('Module:Higher education task force/data')
local taskForceCode = args.code or args[1]
local taskForceData
if taskForceCode then
taskForceCode = taskForceCode:match('^%s*(.-)%s*$'):lower() -- trim whitespace and put in lower case
taskForceData = dataModule[taskForceCode]
end
return taskForceData
end
--[[------------------------< getName >---------------------------------
Gets the full name of a task force.
]]----------------------------------------------------------------------------
function p.getName(frame)
local args = getArgs(frame, { parentFirst = true })
local tfData = p._main(args)
if tfData then
return tfData.name
end
return nil
end
--[[------------------------< getNestedName >---------------------------------
Gets the nested name of a task force.
]]----------------------------------------------------------------------------
function p.getNestedName(frame)
local args = getArgs(frame, { parentFirst = true })
local tfData = p._main(args)
if tfData then
return tfData.nested
end
return nil
end
--[[------------------------< getImage >---------------------------------
Gets the image filename for a task force.
]]----------------------------------------------------------------------------
function p.getImage(frame)
local args = getArgs(frame, { parentFirst = true })
local tfData = p._main(args)
if tfData then
return tfData.image
end
return nil
end
--[[------------------------< getCategory >---------------------------------
Gets the category name for a task force.
]]----------------------------------------------------------------------------
function p.getCategory(frame)
local args = getArgs(frame, { parentFirst = true })
local tfData = p._main(args)
if tfData then
return tfData.category
end
return nil
end
--[[------------------------< getLink >---------------------------------
Gets the project link for a task force.
]]----------------------------------------------------------------------------
function p.getLink(frame)
local args = getArgs(frame, { parentFirst = true })
local tfData = p._main(args)
if tfData then
return tfData.link
end
return nil
end
--[[------------------------< getCanonicalCode >---------------------------------
Gets the canonical code for a task force.
]]----------------------------------------------------------------------------
function p.getCanonicalCode(frame)
local args = getArgs(frame, { parentFirst = true })
local tfData = p._main(args)
if tfData then
return tfData.canonicalCode
end
return nil
end
function p.main(frame)
local args = getArgs(frame, { parentFirst = true })
return p._main(args)
end
function p.hello(frame)
return "|MAIN_TEXT = feline"
end
function p.tab2arg(trable,r)
local t = mw.text.split(r, "=", true, true) -- Split by comma, trim whitespace, remove empty strings
local x = mw.text.split(t[1], "|", true, true) -- Split by comma, trim whitespace, remove empty strings
trable[x[2] ]=t[2]
return trable
end
function p.ma1(frame,s1,s2)
frame[s1]=s2
end
function p.fudgeTaskforceParameters(frame)
local args = getArgs(frame, { parentFirst = true })
local taskforcesStr = ""
taskforcesStr = args["HEET_TASKFORCE"]
if not taskforcesStr then
return "oops"
end
local taskforceCodes = mw.text.split(taskforcesStr, ",", true, true) -- Split by comma, trim whitespace, remove empty strings
local paramsStr = ""
local tfCounter = 1
local trable=args
for _, code in ipairs(taskforceCodes) do
local tfData = p._main({code})
if tfData then
trable = p.tab2arg(trable,string.format("|tf %d=%dyes", tfCounter,tfCounter))
paramsStr = paramsStr .. "\n\n\n"
trable = p.tab2arg(trable,string.format("|TF_%d_LINK=%s", tfCounter, tfData.link))
paramsStr = paramsStr .. "\n\n\n"
trable = p.tab2arg(trable,string.format("|TF_%d_NAME=%s", tfCounter, tfData.name))
paramsStr = paramsStr .. "\n\n\n"
trable = p.tab2arg(trable,string.format("|TF_%d_NESTED=%s", tfCounter, tfData.nested))
paramsStr = paramsStr .. "\n\n\n"
trable = p.tab2arg(trable,string.format("|TF_%d_IMAGE=%s", tfCounter, tfData.image))
paramsStr = paramsStr .. "\n\n\n"
trable = p.tab2arg(trable,string.format("|TF_%d_MAIN_CAT=%s", tfCounter, tfData.category))
paramsStr = paramsStr .. "\n\n\n"
tfCounter = tfCounter + 1
end
end
frame.args=trable
return frame
end
function p.fudge(frame)
local oframe=frame
frame=p.fudgeTaskforceParameters(frame)
return banner.main(oframe)
end
function p.printargs(frame)
local str=getArgs(frame, { parentFirst = true })
return str[1]
end
function p.tester(frame)
local str=""
str = str .. "hello"
local r="|IMAGE_LEFT =Graduation hat.svg"
local t = mw.text.split(r, "=", true, true) -- Split by comma, trim whitespace, remove empty strings
local x = mw.text.split(t[1], "|", true, true) -- Split by comma, trim whitespace, remove empty strings
return t[2]
end
p[''] = function (frame) return p._main(frame.args) end
return p