Importer, Bürokraten, Moderatoren (CommentStreams), Strukturierte-Diskussionen-Bots, Oberflächenadministratoren, Push-Abonnementverwalter, Oversighter, Administratoren, Kampagnenbearbeiter (Hochladeassistent)
855
Bearbeitungen
KKeine Bearbeitungszusammenfassung |
K (43 Versionen von wikivoyage:Modul:Citation/COinS importiert) |
||
| (29 dazwischenliegende Versionen von einem anderen Benutzer werden nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
-- documentation | -- documentation | ||
local | local citationCOinS = { | ||
suite = 'Citation', | suite = 'Citation', | ||
sub = 'COinS', | sub = 'COinS', | ||
serial = ' | serial = '2022-10-21' | ||
} | } | ||
-- module variable | -- module variable and administration | ||
local cc = {} | local cc = { | ||
moduleInterface = citationCOinS | |||
} | |||
-- module import | -- module import | ||
-- 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' ) | ||
function cc.prepareForCOinS( args ) | function cc.prepareForCOinS( args ) | ||
local function pagesMatch( s ) | local function pagesMatch( s ) | ||
if not cu.isSet( s ) then | if not cu.isSet( s ) then | ||
| Zeile 21: | 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 38: | Zeile 39: | ||
end | end | ||
if s == '' then | if s == '' then | ||
cu.addErrorMsg( texts.wrongPages ) | cu.addErrorMsg( ci.texts.wrongPages ) | ||
end | end | ||
return s | return s | ||
| Zeile 54: | 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 | ||
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 71: | Zeile 73: | ||
function cc.makeCOinS( args ) | function cc.makeCOinS( args ) | ||
local rft = {} | local rft = {} | ||
local function insertCOinS( key, value ) | local function insertCOinS( key, value ) | ||
| Zeile 85: | Zeile 87: | ||
-- handle titles | -- handle titles | ||
-- maps handled like books | -- maps handled like books | ||
if args.type == 'book' or args.type == 'map' or args.type == ' | if args.type == 'book' or args.type == 'map' or args.type == 'bookitem' then | ||
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' ) ) | ||
if args.type == 'bookitem' then | |||
if args.type == ' | |||
table.insert( rft, 'rft.genre=bookitem' ) | table.insert( rft, 'rft.genre=bookitem' ) | ||
insertCOinS( 'rft.atitle', args.title ) | insertCOinS( 'rft.atitle', args.title ) | ||
| Zeile 102: | 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= | table.insert( rft, 'rft.genre=article' ) | ||
insertCOinS( 'rft.atitle', args.title ) | insertCOinS( 'rft.atitle', args.title ) | ||
insertCOinS( 'rft.jtitle', args.type == 'journal' and args.journal or args.newspaper ) | |||
-- handle web | -- handle web | ||
| Zeile 126: | Zeile 114: | ||
.. mw.uri.encode( 'info:ofi/fmt:kev:mtx:dc', 'PATH' ) ) | .. mw.uri.encode( 'info:ofi/fmt:kev:mtx:dc', 'PATH' ) ) | ||
insertCOinS( 'rft.type', 'webpage' ) | insertCOinS( 'rft.type', 'webpage' ) | ||
insertCOinS( 'rft.title', args.title ) | insertCOinS( 'rft.title', args.title ) | ||
insertCOinS( 'rft.source', args.website ) | insertCOinS( 'rft.source', args.website ) | ||
| Zeile 135: | Zeile 122: | ||
if #rft > 2 then | if #rft > 2 then | ||
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 ] ) then | if cu.isSet( args[ key ] ) and value.COinS then | ||
if value.COinS | if key == 'date' and args.dateFormat == 'R' then | ||
insertCOinS( value.COinS, args[ key ] ) | insertCOinS( value.COinS, string.sub( args[ key ], 1, 4 ) ) | ||
elseif value.COinS ~= 'rft.jtitle' and value.COinS ~= 'rft.title' then | |||
prefix = value.COinS:sub( 1, 3 ) | |||
if prefix == 'rft' then | |||
insertCOinS( value.COinS, args[ key ] ) | |||
elseif prefix == 'inf' then | |||
table.insert( rft, 'rft_id=' .. | |||
mw.uri.encode( value.COinS .. '/' .. args[ key ], 'PATH' ) ) | |||
elseif prefix == 'url' and rftUrl == '' then | |||
rftUrl = value.url:format( args[ key ] ) | |||
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 | |||
if rftUrl ~= '' then | |||
if rftUrl:match( '^//' ) then | |||
rftUrl = 'https:' .. rftUrl | |||
end | |||
table.insert( rft, 'rft_id=' .. mw.uri.encode( rftUrl, 'PATH' ) ) | |||
end | end | ||