Documentation for this module may be created at Module:NewsSource/doc
local getArgs = require('Module:Arguments').getArgs
local NewsSource = {}
local cargo = mw.ext.cargo
function NewsSource.main(frame)
local args = getArgs(frame)
local span = mw.html.create('span')
local currentDate = os.date('%Y-%m-%d')
local tables = 'Logos'
local fields = '_pageName, logoLight, logoDark, logoAll, start, end, iconLight, iconDark, iconAll'
local cargoArgs = {
where = '_pageName="' .. args.source .. '" AND (start is NULL OR start < "' .. currentDate .. '") AND (end is NULL OR end > "' .. currentDate .. '")'
}
local results = cargo.query(tables, fields, cargoArgs)
if #results > 0 then
local result = results[1]
local icon = result.iconAll or result.iconLight or result.iconDark or result.logoAll or result.logoLight or result.logoDark or 'Team placeholder light.png'
span:wikitext('[[File:' .. icon .. '|30px|link=' .. args.url .. ']]')
else
span:wikitext('[[File:' .. args.source .. '|30px|link=' .. args.url .. ']]')
end
-- atag:node(span)
return span
end
return NewsSource