No edit summary |
No edit summary |
||
(One intermediate revision by one other user not shown) | |||
Line 12: | Line 12: | ||
local fields = '_pageName, logoLight, logoDark, logoAll, start, end, iconLight, iconDark, iconAll' | local fields = '_pageName, logoLight, logoDark, logoAll, start, end, iconLight, iconDark, iconAll' | ||
local cargoArgs = { | local cargoArgs = { | ||
where = '_pageName="' .. args.source .. '" AND (start is NULL OR start < "' .. currentDate .. '") AND (end is NULL OR end > "' .. currentDate .. '")' | where = '_pageName="Company/' .. args.source .. '" AND (start is NULL OR start < "' .. currentDate .. '") AND (end is NULL OR end > "' .. currentDate .. '")' | ||
} | } | ||
local results = cargo.query(tables, fields, cargoArgs) | local results = cargo.query(tables, fields, cargoArgs) | ||
Line 21: | Line 21: | ||
span:wikitext('[[File:' .. icon .. '|30px|link=' .. args.url .. ']]') | span:wikitext('[[File:' .. icon .. '|30px|link=' .. args.url .. ']]') | ||
else | else | ||
span:wikitext('[[File:' .. args.source .. '|30px|link=' .. args.url .. ']]') | span:wikitext('[[File:' .. args.source .. '.png|30px|link=' .. args.url .. ']]') | ||
end | end | ||
return span | return span |
Latest revision as of 22:31, 9 May 2023
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="Company/' .. 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 .. '.png|30px|link=' .. args.url .. ']]')
end
return span
end
return NewsSource