Module:NewsSource: Difference between revisions
From TwogPedia
             (Created page with "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 < "' .. cur...")  | 
				No edit summary  | 
				||
| Line 23: | Line 23: | ||
		span:wikitext('[[File:' .. args.source .. '|30px|link=' .. args.url .. ']]')  | 		span:wikitext('[[File:' .. args.source .. '|30px|link=' .. args.url .. ']]')  | ||
	end  | 	end  | ||
	return span  | 	return span  | ||
end  | end  | ||
return NewsSource  | return NewsSource  | ||
Revision as of 23:06, 7 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="' .. 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
No categories