Modul:Cite tweet: Unterschied zwischen den Versionen
K
Use the right concatenation operator
(Lua translation of Template:Cite_tweet designed to deal with very heavy usage on pages.) |
K (Use the right concatenation operator) |
||
Zeile 15: | Zeile 15: | ||
local args = frame.args | local args = frame.args | ||
local cite_args = { | local cite_args = { | ||
url = 'https://twitter.com/' | url = 'https://twitter.com/' .. ((args.user and args.number) and (args.user .. '/status/' .. args.number) or ''), | ||
title = (args.title or ''):gsub('https*://', ''), | title = (args.title or ''):gsub('https*://', ''), | ||
['script-title'] = args['script-title'], | ['script-title'] = args['script-title'], | ||
Zeile 21: | Zeile 21: | ||
language = args.language, | language = args.language, | ||
['author-link'] = args['author-link'] or args.authorlink, | ['author-link'] = args['author-link'] or args.authorlink, | ||
others = _if(args.retweet) and ('Retweeted by ' | others = _if(args.retweet) and ('Retweeted by ' .. args.retweet), | ||
via = args.link == 'no' and 'Twitter' or '[[Twitter]]', | via = args.link == 'no' and 'Twitter' or '[[Twitter]]', | ||
type = 'Tweet', | type = 'Tweet', | ||
Zeile 33: | Zeile 33: | ||
} | } | ||
if _if(args.last1 or args.last) then | if _if(args.last1 or args.last) then | ||
cite_args.author = (args.last1 or args.last) | cite_args.author = (args.last1 or args.last) .. | ||
(_if(args.first1 or args.first) and (', ' | (_if(args.first1 or args.first) and (', ' .. (args.first1 or args.first)) or '') .. | ||
'[@' | '[@' .. (args.user or '') .. ']' | ||
elseif _if(args.author1 or args.author) then | elseif _if(args.author1 or args.author) then | ||
cite_args.author = (args.author1 or args.author) | cite_args.author = (args.author1 or args.author) .. '[@' .. (args.user or '') .. ']' | ||
elseif _if(args['author-link']) then | elseif _if(args['author-link']) then | ||
cite_args.author = args['author-link'] | cite_args.author = args['author-link'] .. '[@' .. (args.user or '') .. ']' | ||
else | else | ||
cite_args.author = '@' | cite_args.author = '@' .. args.user | ||
end | end | ||
cite_args.date = args.date or (_if(args.number) and TwitterSnowflake.snowflakeToDate{ args = {id_str = args.number} }) | cite_args.date = args.date or (_if(args.number) and TwitterSnowflake.snowflakeToDate{ args = {id_str = args.number} }) | ||
Zeile 71: | Zeile 71: | ||
if errors[1] then | if errors[1] then | ||
local last = errors[#errors] | local last = errors[#errors] | ||
errors[#errors] = last:sub(1, #last - 1) | errors[#errors] = last:sub(1, #last - 1) .. ' ([[Template:Cite_tweet#Error_detection|help]])' | ||
local error_out = error_template:rep(#errors):format(unpack(errors)) | local error_out = error_template:rep(#errors):format(unpack(errors)) | ||
if mw.title.getCurrentTitle():inNamespace(0) then | if mw.title.getCurrentTitle():inNamespace(0) then | ||
error_out = error_out | error_out = error_out .. '[[Category:Cite tweet templates with errors]]' | ||
end | end | ||
output = output | output = output .. error_out | ||
end | end | ||
return output | return output |