Module:Cite tweet: Difference between revisions

From Sekaipedia
Content added Content deleted
(Created page with "local p = {} function p.main(frame) local args = frame:getParent().args return p._main(args) end function p._main(args) local content = ' (%s). "[%s %s]" (Tweet) –...")
 
m (use snowflake instead of link)
 
Line 9: Line 9:
function p._main(args)
function p._main(args)
local content = ' (%s). "[%s %s]" (Tweet) – via Twitter.'
local content = ' (%s). "[https://twitter.com/%s/status/%s %s]" (Tweet) – via Twitter.'
content = string.format(
content = string.format(
content,
content,
args['date'] or '',
args['date'] or '',
args['link'] or '',
args['handle'] or '',
args['snowflake'] or '',
args['title'] or ''
args['title'] or ''
)
)

Latest revision as of 08:15, 12 November 2021

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

local p = {}

function p.main(frame)
	local args = frame:getParent().args
	
	return p._main(args)
end

function p._main(args)
	
	local content = ' (%s). "[https://twitter.com/%s/status/%s %s]" (Tweet) – via Twitter.'
	
	content = string.format(
		content,
		args['date'] or '',
		args['handle'] or '',
		args['snowflake'] or '',
		args['title'] or ''
	)
	
	if args['author'] then
		content = string.format(
			'%s [@%s]' .. content,
			args['author'] or '',
			args['handle'] or ''
		)
	else
		content = string.format(
			'@%s' .. content,
			args['handle'] or ''
		)
	end
	
	local ref = mw.getCurrentFrame():extensionTag{
		name = 'ref',
		content = content,
		args = {
			name = args['ref name'],
			group = args['ref group']
		}
	}
	
	return ref
end

return p
Cookies help us deliver our services. By using our services, you agree to our use of cookies.