No edit summary |
No edit summary |
||
Line 5: | Line 5: | ||
function NewsItem.main(frame) | function NewsItem.main(frame) | ||
local args = getArgs(frame) | local args = getArgs(frame) | ||
local container = mw.html.create('span'):addClass('newsItem') | local container = mw.html.create('span'):addClass('newsItem') | ||
if args.date then | if args.date then | ||
local date = mw.html.create('span'):addClass('news-date'):wikitext(args.date) | local date = mw.html.create('span'):addClass('news-date'):wikitext(mw.text.split(args.date, ' ')[1]) | ||
container:node(date) | container:node(date) | ||
end | end | ||
Line 24: | Line 19: | ||
if args.url then | if args.url then | ||
if args.title 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 .. ']') | container:wikitext('[' .. args.url .. ' ' .. args.title .. ']') | ||
else | else | ||
container:wikitext('[' .. args.url .. ']') | container:wikitext('[' .. args.url .. ']') | ||
end | end | ||
end | |||
if args.author then | |||
local link = args.authorlink == nil and args.author or args.author .. '|' .. args.authorlink | |||
container:wikitext(' by [[' ..link .. ']]') | |||
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 | end | ||
Revision as of 17:06, 6 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)
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
local link = args.authorlink == nil and args.author or args.author .. '|' .. args.authorlink
container:wikitext(' by [[' ..link .. ']]')
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