Modul:Citation/COinS: Unterschied zwischen den Versionen

K
43 Versionen von wikivoyage:Modul:Citation/COinS importiert
(creator removed)
K (43 Versionen von wikivoyage:Modul:Citation/COinS importiert)
 
(15 dazwischenliegende Versionen von einem anderen Benutzer werden nicht angezeigt)
Zeile 3: Zeile 3:
suite  = 'Citation',
suite  = 'Citation',
sub    = 'COinS',  
sub    = 'COinS',  
serial = '2022-08-12'
serial = '2022-10-21'
}
}


Zeile 12: Zeile 12:


-- module import
-- module import
require( 'Module:No globals' )
-- require( 'strict' )
local ci = require( 'Module:Citation/i18n' )
local ci = require( 'Module:Citation/i18n' )
local cu = require( 'Module:Citation/utilities' )
local cu = require( 'Module:Citation/utilities' )
Zeile 22: Zeile 22:
end
end


s = s:match( '%d+%s*%-%s*%d+' ) or s:match( '%d+' ) or
s = s:match( '%a*%d+%s*%-%s*%a*%d+' ) or s:match( '%a*%d+' ) or
-- Roman numerals
-- Roman numerals
s:match( '[Cc]*[LlXxVvIi]+%s*%-%s*[Cc]*[LlXxVvIi]+' ) or
s:match( '[Cc]*[LlXxVvIi]+%s*%-%s*[Cc]*[LlXxVvIi]+' ) or
Zeile 55: Zeile 55:
args.pages = args.columns
args.pages = args.columns
end
end
args.extent = args.extent:match( '%d+' )


-- only first author
-- only first author
args.author = cu.getFirst( args.author or '', ';' )
args.author = cu.getFirst( args.author or '', ';' )
local count
local s, count
_,count = args.author:gsub( ',', ',' )
s, count = args.author:gsub( ',', ',' )
if count > 1 then
if count > 1 then
args.author = cu.getFirst( args.author, ',' )
args.author = cu.getFirst( args.author, ',' )
Zeile 89: Zeile 90:
table.insert( rft, 'rft_val_fmt='
table.insert( rft, 'rft_val_fmt='
.. mw.uri.encode( 'info:ofi/fmt:kev:mtx:book', 'PATH' ) )
.. mw.uri.encode( 'info:ofi/fmt:kev:mtx:book', 'PATH' ) )
insertCOinS( 'rft.title', args.title )
if args.type == 'bookitem' then
if args.type == 'bookitem' then
table.insert( rft, 'rft.genre=bookitem' )
table.insert( rft, 'rft.genre=bookitem' )
Zeile 103: Zeile 103:
table.insert( rft, 'rft_val_fmt='
table.insert( rft, 'rft_val_fmt='
.. mw.uri.encode( 'info:ofi/fmt:kev:mtx:journal', 'PATH' ) )
.. mw.uri.encode( 'info:ofi/fmt:kev:mtx:journal', 'PATH' ) )
table.insert( rft, 'rft.genre=journal' )
table.insert( rft, 'rft.genre=article' )
insertCOinS( 'rft.title', args.title )
insertCOinS( 'rft.atitle', args.title )
insertCOinS( 'rft.atitle', args.title )
if args.type == 'journal' then
insertCOinS( 'rft.jtitle', args.type == 'journal' and args.journal or args.newspaper )
insertCOinS( 'rft.jtitle', args.journal )
else
insertCOinS( 'rft.jtitle', args.newspaper )
end
 
-- else -- 'newspaper'
-- table.insert( rft, 'rft_val_fmt='
-- .. mw.uri.encode( 'info:ofi/fmt:kev:mtx:dc', 'PATH' ) )
-- insertCOinS( 'rft.type', 'newspaperArticle' )
-- insertCOinS( 'rft.title', args.title )
-- insertCOinS( 'rft.atitle', args.title )
-- insertCOinS( 'rft.source', args.newspaper )


-- handle web
-- handle web
Zeile 136: Zeile 123:
if #rft > 2 then
if #rft > 2 then
local prefix
local prefix
local rftUrl = ( cu.isSet( args.url ) and not args.url:find( 'doi.org/', 1, true ) )
and args.url or ''
for key, value in pairs( ci.params ) do
for key, value in pairs( ci.params ) do
if cu.isSet( args[ key ] ) and value.COinS then
if cu.isSet( args[ key ] ) and value.COinS then
Zeile 147: Zeile 136:
table.insert( rft, 'rft_id=' ..
table.insert( rft, 'rft_id=' ..
mw.uri.encode( value.COinS .. '/' .. args[ key ], 'PATH' ) )
mw.uri.encode( value.COinS .. '/' .. args[ key ], 'PATH' ) )
elseif prefix == 'url' then
elseif prefix == 'url' and rftUrl == '' then
table.insert( rft, 'rft_id=' ..
rftUrl = value.url:format( args[ key ] )
mw.uri.encode( args[ key ], 'PATH' ) )
elseif prefix == 'jst' then
if not cu.isSet( args.doi ) then
table.insert( rft, 'rft_id=' ..
mw.uri.encode( 'info:doi/' .. value.doi:format( args[ key ] ), 'PATH' ) )
end
if rftUrl == '' then
rftUrl = value.url:format( args[ key ] )
end
end
end
end
end
end
end
end
if rftUrl ~= '' then
if rftUrl:match( '^//' ) then
rftUrl = 'https:' .. rftUrl
end
table.insert( rft, 'rft_id=' .. mw.uri.encode( rftUrl, 'PATH' ) )
end
end


Zeile 161: Zeile 163:
:addClass( 'Z3988' )
:addClass( 'Z3988' )
:attr( 'title', table.concat( rft, '&' ) )
:attr( 'title', table.concat( rft, '&' ) )
:css( 'display', 'none' )
)
)
end
end