No edit summary |
No edit summary |
||
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) |
Revision as of 11:00, 8 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 .. '|30px|link=' .. args.url .. ']]')
end
return span
end
return NewsSource