Modul:Citation/COinS: Unterschied zwischen den Versionen

+ project, type(args), PATH
KKeine Bearbeitungszusammenfassung
(+ project, type(args), PATH)
Zeile 3: Zeile 3:
suite  = 'Citation',
suite  = 'Citation',
sub    = 'COinS',  
sub    = 'COinS',  
serial = '2020-03-27',
serial = '2020-03-30',
}
}


Zeile 11: Zeile 11:
-- module import
-- module import
local cu = require( 'Module:Citation/utilities' )
local cu = require( 'Module:Citation/utilities' )
local ci = require( 'Module:Citation/i18n' )


function cc.prepareForCOinS( args )
function cc.prepareForCOinS( args )
Zeile 42: Zeile 43:
end
end


args.isArchived = nil
for key, value in pairs( args ) do
for key, value in pairs( args ) do
args[ key ] = mw.ustring.gsub( args[ key ], ' ', ' ' )
args[ key ] = mw.ustring.gsub( args[ key ], ' ', ' ' )
Zeile 78: Zeile 78:
local function insertCOinS( key, value )
local function insertCOinS( key, value )
if cu.isSet( value ) then
if cu.isSet( value ) then
table.insert( rft, key .. '=' .. mw.uri.encode( '' .. value ) )
table.insert( rft, key .. '=' .. mw.uri.encode( '' .. value, 'PATH' ) )
end
end
end
end
-- make COinS (ContextObjects in Spans, OpenURL) format
-- https://groups.niso.org/apps/group_public/download.php/14833/z39_88_2004_r2010.pdf
-- https://www.oclc.org/developer/develop/web-services/worldcat-knowledge-base-api/openurl-resource.en.html


-- handle titles
-- handle titles
-- maps handled like books
if args.type == 'book' or args.type == 'map' or args.type == 'collection' then
if args.type == 'book' or args.type == 'map' or args.type == 'collection' then
table.insert( rft, 'rft_val_fmt=' .. mw.uri.encode( 'info:ofi/fmt:kev:mtx:book' ) )
table.insert( rft, 'rft_val_fmt='
.. mw.uri.encode( 'info:ofi/fmt:kev:mtx:book', 'PATH' ) )
insertCOinS( 'rft.title', args.title )
insertCOinS( 'rft.title', args.title )
if args.type == 'collection' then
if args.type == 'collection' then
Zeile 94: Zeile 100:
insertCOinS( 'rft.btitle', args.title )
insertCOinS( 'rft.btitle', args.title )
end
end
-- newspaper is now handled like a journal to improve data import
elseif args.type == 'journal' or args.type == 'newspaper' then
elseif args.type == 'journal' or args.type == 'newspaper' then
table.insert( rft, 'rft_val_fmt=' .. mw.uri.encode( 'info:ofi/fmt:kev:mtx:journal' ) )
table.insert( rft, 'rft_val_fmt='
.. mw.uri.encode( 'info:ofi/fmt:kev:mtx:journal', 'PATH' ) )
table.insert( rft, 'rft.genre=journal' )
table.insert( rft, 'rft.genre=journal' )
insertCOinS( 'rft.title', args.title )
insertCOinS( 'rft.title', args.title )
Zeile 104: Zeile 113:
insertCOinS( 'rft.jtitle', args.newspaper )
insertCOinS( 'rft.jtitle', args.newspaper )
end
end
-- else -- 'newspaper'
-- else -- 'newspaper'
-- table.insert( rft, 'rft_val_fmt=' .. mw.uri.encode( 'info:ofi/fmt:kev:mtx:dc' ) )
-- table.insert( rft, 'rft_val_fmt='
-- .. mw.uri.encode( 'info:ofi/fmt:kev:mtx:dc', 'PATH' ) )
-- insertCOinS( 'rft.type', 'newspaperArticle' )
-- insertCOinS( 'rft.type', 'newspaperArticle' )
-- insertCOinS( 'rft.title', args.title )
-- insertCOinS( 'rft.title', args.title )
-- insertCOinS( 'rft.atitle', args.title )
-- insertCOinS( 'rft.atitle', args.title )
-- insertCOinS( 'rft.source', args.newspaper )
-- insertCOinS( 'rft.source', args.newspaper )
else -- web
 
table.insert( rft, 'rft_val_fmt=' .. mw.uri.encode( 'info:ofi/fmt:kev:mtx:dc' ) )
-- handle web
-- DCMI: Dublin Core™ Metadata
-- https://www.dublincore.org/specifications/dublin-core/dces/
else
table.insert( rft, 'rft_val_fmt='
.. mw.uri.encode( 'info:ofi/fmt:kev:mtx:dc', 'PATH' ) )
insertCOinS( 'rft.type', 'webpage' )
insertCOinS( 'rft.type', 'webpage' )
insertCOinS( 'rft.creator', args.author )
insertCOinS( 'rft.creator', args.author )
Zeile 123: Zeile 139:
if #rft > 2 then
if #rft > 2 then
for key, value in pairs( params ) do
for key, value in pairs( params ) do
if cu.isSet( args[ key ] ) then
if cu.isSet( args[ key ] ) and type( args[ key ] ) == 'string' then
if value.COinS and value.COinS ~= 'rft.jtitle' and value.COinS ~= 'rft.title' then
if value.COinS and value.COinS ~= 'rft.jtitle' and value.COinS ~= 'rft.title' then
insertCOinS( value.COinS, args[ key ] )
insertCOinS( value.COinS, args[ key ] )
elseif value.COinS_id and args[ key ] then
elseif value.COinS_id and args[ key ] then
table.insert( rft, 'rft_id=' ..
table.insert( rft, 'rft_id=' ..
mw.uri.encode( value.COinS_id .. '/' .. args[ key ] ) )
mw.uri.encode( value.COinS_id .. '/' .. args[ key ], 'PATH' ) )
end
end
end
end
end
end


table.insert( rft, 1, 'rfr_id='
.. mw.uri.encode( 'info/sid:/' .. ci.project.name, 'PATH' ) )
table.insert( rft, 1, 'ctx_ver=Z39.88-2004' )
table.insert( rft, 1, 'ctx_ver=Z39.88-2004' )
rft = table.concat( rft, '&' )
rft = table.concat( rft, '&' )
return '<span title="' .. rft .. '" class="Z3988"></span>'
return '<span title="' .. rft .. '" class="Z3988"></span>'
end
end
Anonymer Benutzer