Module:NewsItem: Difference between revisions

From TwogPedia
No edit summary
Tag: Reverted
No edit summary
Tag: Reverted
Line 6: Line 6:
local args = getArgs(frame)
local args = getArgs(frame)
mw.log('ARGS ON')
mw.log('ARGS ON')
mw.log(args)
mw.logObject(args)
local container = mw.html.create('span'):addClass('newsItem')
local container = mw.html.create('span'):addClass('newsItem')

Revision as of 16:11, 10 October 2022

Documentation for this module may be created at Module:NewsItem/doc

local getArgs = require('Module:Arguments').getArgs
local Flags = require('Module:Flags')
local NewsItem = {}

function NewsItem.main(frame)
	local args = getArgs(frame)
	mw.log('ARGS ON')
	mw.logObject(args)
	local container = mw.html.create('span'):addClass('newsItem')
	
	if args.date then
		local date = mw.html.create('span'):addClass('news-date'):wikitext(mw.text.split(args.date, ' ')[1])
		container:node(date)
	end
	
	if args.lang then
		container:node(Flags.icon(args.lang))
	else 
		container:node(Flags.icon('usuk'))
	end
	
	if args.url then
		if args.title and args.trans_title then
			container:wikitext('[' .. args.url .. ' ' .. args.title .. '] (' .. args.trans_title .. ')')
		elseif args.title then
			container:wikitext('[' .. args.url .. ' ' .. args.title .. ']')
		else
			container:wikitext('[' .. args.url .. ']')
		end
	end
	
	if args.author then
		container:wikitext(' by [[' ..args.author .. ']]')
	end
	
	if args.source then
		container:wikitext(' on [[' .. args.source .. ']]')
	end
	
	if args.event then
		container:wikitext(' at [[' .. args.event .. ']]')
	end
	
	if args.trans_lang then
		if args.translator then
			container:wikitext(' (translated into ' .. Flags.icon(args.trans_lang) .. 'by [[' .. args.translator .. ']])')	
		else
			container:wikitext(' (translated into ' .. Flags.icon(args.trans_lang) .. ')')	
		end
	end
	
	if args.note then
		container:node(mw.html.create('small'):wikitext(' (Note: ' .. args.note .. ')'))
	end
	
	return container
end

return NewsItem