Modul:Cite tweet: Unterschied zwischen den Versionen

K
13 Versionen von wpen:Module:Cite_tweet importiert
K (Use the right concatenation operator)
K (13 Versionen von wpen:Module:Cite_tweet importiert)
 
(11 dazwischenliegende Versionen von 7 Benutzern werden nicht angezeigt)
Zeile 4: Zeile 4:


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


Zeile 29: Zeile 29:
['archive-url'] = args['archive-url'] or args.archiveurl,
['archive-url'] = args['archive-url'] or args.archiveurl,
['url-status'] = args['url-status'] or args['dead-url'] or args.deadurl,
['url-status'] = args['url-status'] or args['dead-url'] or args.deadurl,
quote = args.quote,
ref = args.ref,
ref = args.ref,
df = args.df
df = args.df
Zeile 35: Zeile 36:
cite_args.author = (args.last1 or args.last) ..
cite_args.author = (args.last1 or args.last) ..
(_if(args.first1 or args.first) and (', ' .. (args.first1 or args.first)) or '') ..
(_if(args.first1 or args.first) and (', ' .. (args.first1 or args.first)) or '') ..
'[@' .. (args.user 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) .. '[@' .. (args.user or '') .. ']'
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'] .. '[@' .. (args.user or '') .. ']'
cite_args.author = args['author-link'] .. ' [@' .. (args.user or '') .. ']'
else
else
cite_args.author = '@' .. args.user
cite_args.author = '@' .. (args.user or '')
end
if cite_args.author:find ('[Tt]witter') then
cite_args.author = '((' .. cite_args.author .. '))'
end
if _if(tonumber(args.number)) then
cite_args.date = args.date or (_if(args.number) and TwitterSnowflake.snowflakeToDate{ args = {id_str = args.number} })
else
cite_args.date = args.date
end
end
cite_args.date = args.date or (_if(args.number) and TwitterSnowflake.snowflakeToDate{ args = {id_str = args.number} })
frame.args = cite_args
frame.args = cite_args
Zeile 50: Zeile 58:
-- Error checking
-- Error checking
local error_template = '<span class="cs1-visible-error error citation-comment">%s</span> '
local error_template = '<span class="cs1-visible-error citation-comment">%s</span>'
local errors = {}
local errors = {}
if not (_if(args.title) or _if(args['script-title']) or args.user or args.number or args.date) then
if not (_if(args.title) or _if(args['script-title']) or args.user or args.number or args.date) then
Zeile 57: Zeile 65:
end
end
if not _if(args.user) then
if not _if(args.user) then
errors[1 + #errors] = 'Missing or empty <kbd>&#124;user=</kbd>;'
errors[1 + #errors] = ' Missing or empty <kbd>&#124;user=</kbd>;'
end
end
if not _if(args.number) then
if not _if(args.number) then
errors[1 + #errors] = 'Missing or empty <kbd>&#124;number=</kbd>;'
errors[1 + #errors] = ' Missing or empty <kbd>&#124;number=</kbd>;'
end
end
errors[1 + #errors] = TwitterSnowflake.datecheck{ args = {
errors[1 + #errors] = TwitterSnowflake.datecheck{ args = {
id_str = args.number,
id_str = args.number or '',
date = args.date,
date = args.date or '',
error1 = '<kbd>&#124;date=</kbd> mismatches calculated date from <kbd>&#124;number=</kbd> by two or more days;',
error1 = ' <kbd>&#124;date=</kbd> mismatches calculated date from <kbd>&#124;number=</kbd> by two or more days;',
error2  = 'Missing or empty <kbd>&#124;date=</kbd>, and posted before November 4, 2010;',
error2  = ' Missing or empty <kbd>&#124;date=</kbd>, and posted before November 4, 2010;',
error3 = 'Invalid <kbd>&#124;number=</kbd> parameter;'
error3 = ' Invalid <kbd>&#124;number=</kbd> parameter;'
}}
}}
if errors[1] then
if errors[1] then