Mô đun:Cite tweet

local p = {}
local TwitterSnowflake = require('Mô đun:TwitterSnowflake')
local CiteWeb = require('Mô đun:Cite web')['']

local function _if(arg)
	return arg and arg ~= '' or nil
end

p.main = function(frame)
	frame.args = frame:getParent().args
	return p[''](frame)
end

p[''] = function(frame)
	local args = frame.args
	local cite_args = {
		url 		= 'https://twitter.com/' .. ((args.user and args.number) and (args.user .. '/status/' .. args.number) or ''),
		title		= (args.title or ''):gsub('https*://', ''),
		['script-title'] = args['script-title'],
		['trans-title'] = args['trans-title'],
		language	= args.language,
		['author-link'] = args['author-link'] or args.authorlink,
		others		= _if(args.retweet) and ('Retweet của ' .. args.retweet),
		via 		= args.link == 'no' and 'Twitter' or '[[Twitter]]',
		type		= 'Tweet',
		location	= args.location,
		['access-date'] = args['access-date'] or args.accessdate,
		['archive-date'] = args['archive-date'] or args.archivedate,
		['archive-url'] = args['archive-url'] or args.archiveurl,
		['url-status'] = args['url-status'] or args['dead-url'] or args.deadurl,
		ref			= args.ref,
		df			= args.df
	}
	if _if(args.last1 or args.last) then
		cite_args.author = (args.last1 or args.last) ..
			(_if(args.first1 or args.first) and (', ' .. (args.first1 or args.first)) or '') ..
			' [@' .. (args.user or '') .. ']'
	elseif _if(args.author1 or args.author) then
		cite_args.author = (args.author1 or args.author) .. ' [@' .. (args.user or '') .. ']'
	elseif _if(args['author-link']) then
		cite_args.author = args['author-link'] .. ' [@' .. (args.user or '') .. ']'
	else
		cite_args.author = '@' .. (args.user or '')
	end
	cite_args.date = args.date or (_if(args.number) and TwitterSnowflake.snowflakeToDate{ args = {id_str = args.number} })
	
	frame.args = cite_args
	local output = CiteWeb(frame)
	frame.args = args
	
	-- Error checking
	local error_template = '<span class="cs1-visible-error error citation-comment">%s</span>'
	local errors = {}
	if not (_if(args.title) or _if(args['script-title']) or args.user or args.number or args.date) then
		-- No title; error message is provided by CS1 module.
		errors[1] = ';'
	end
	if not _if(args.user) then
		errors[1 + #errors] = ' Thiếu hoặc trống <kbd>&#124;user=</kbd>;'
	end
	if not _if(args.number) then
		errors[1 + #errors] = ' Thiếu hoặc trống <kbd>&#124;number=</kbd>;'
	end
	errors[1 + #errors] = TwitterSnowflake.datecheck{ args = {
		id_str	= args.number or '',
		date	= args.date or '',
		error1	= ' <kbd>&#124;date=</kbd> ngày tính toán không khớp từ <kbd>&#124;number=</kbd> bởi hai hoặc nhiều ngày;',
		error2  = ' Thiếu hoặc trống <kbd>&#124;date=</kbd>, và đã đăng trước ngày 4 tháng 11 năm 2010;',
		error3	= ' Tham số <kbd>&#124;number=</kbd> không hợp lệ;'
	}}
	if errors[1] then
		local last = errors[#errors]
		errors[#errors] = last:sub(1, #last - 1) .. ' ([[Bản mẫu:Chú thích tweet#Phát hiện lỗi|trợ giúp]])'
		local error_out = error_template:rep(#errors):format(unpack(errors)) 
		if mw.title.getCurrentTitle():inNamespace(0) then
			error_out = error_out .. '[[Thể loại:Bản mẫu chú thích tweet có lỗi]]'
		end
		output = output .. error_out
	end
	return output
end

return p
Chúng tôi bán
Bài viết liên quan
[Light Novel Rating] Fate/Zero – Cuộc chiến Chén Thánh trên giấy
[Light Novel Rating] Fate/Zero – Cuộc chiến Chén Thánh trên giấy
Chén Thánh (Holy Grail) là một linh vật có khả năng hiện thực hóa mọi điều ước dù là hoang đường nhất của chủ sở hữu. Vô số pháp sư từ khắp nơi trên thế giới do vậy đều khao khát trở thành kẻ nắm giữ món bảo bối có một không hai này
Sung Il-Hwan: Thợ Săn Hạng S Huyền Thoại và Hành Trình Bảo Vệ Gia Đình
Sung Il-Hwan: Thợ Săn Hạng S Huyền Thoại và Hành Trình Bảo Vệ Gia Đình
Sung Il-Hwan (성일환) là một Thợ săn hạng S người Hàn Quốc và là cha của Jinwoo và Jinah
Sự kiện
Sự kiện "Di Lặc giáng thế" - ánh sáng giữa Tam Giới suy đồi
Trong Black Myth: Wukong, phân đoạn Thiên Mệnh Hầu cùng Trư Bát Giới yết kiến Di Lặc ở chân núi Cực Lạc là một tình tiết rất thú vị và ẩn chứa nhiều tầng nghĩa.
Nhân vật Suzune Horikita - Classroom of the Elite
Nhân vật Suzune Horikita - Classroom of the Elite
Nếu mình không thể làm gì, thì cứ đà này mình sẽ kéo cả lớp D liên lụy mất... Những kẻ mà mình xem là không cùng đẳng cấp và vô giá trị... Đến khi có chuyện thì mình không chỉ vô dụng mà lại còn dùng bạo lực ra giải quyết. Thật là ngớ ngẩn...