Module:NewsItem: Difference between revisions

From TwogPedia
No edit summary
Tag: Manual revert
No edit summary
Line 11: Line 11:
container:node(date)
container:node(date)
end
end
 
if args.lang then
if args._pageName then
container:node(Flags.icon(args.lang))
container:wikitext(' [[' .. args._pageName .. ']]')
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
end
if args.author then
if args.author then
container:wikitext(' by [[' ..args.author .. ']]')
local link = args.authorlink == nil and args.author or args.author .. '|' .. args.authorlink
end
container:wikitext(' by [[' ..link .. ']]')
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
end

Revision as of 20:48, 4 May 2023

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)
	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._pageName then
		container:wikitext(' [[' .. args._pageName .. ']]')
	end
	
	if args.author then
		local link = args.authorlink == nil and args.author or args.author .. '|' .. args.authorlink
		container:wikitext(' by [[' ..link .. ']]')
	end
	
	return container
end

return NewsItem