Modul:Citation: Unterschied zwischen den Versionen

K
173 Versionen von wikivoyage:Modul:Citation importiert
(+urn, +arxiv, +bibcode)
K (173 Versionen von wikivoyage:Modul:Citation importiert)
 
(21 dazwischenliegende Versionen von einem anderen Benutzer werden nicht angezeigt)
Zeile 2: Zeile 2:
local citation = {
local citation = {
suite  = 'Citation',
suite  = 'Citation',
serial = '2022-08-14',
serial = '2022-10-21',
item  = 56159597
item  = 56159597
}
}


-- module import
-- module import
require( 'Module:No globals' )
-- require( 'strict' )
local cu = require( 'Module:Citation/utilities' )
local cu = require( 'Module:Citation/utilities' )
local cc = require( 'Module:Citation/COinS' )
local cc = require( 'Module:Citation/COinS' )
Zeile 32: Zeile 32:
complete[ value2 ] = key
complete[ value2 ] = key
args[ key ] = args[ key ] or
args[ key ] = args[ key ] or
cu.parameterCleanup( frameArgs[ value2 ] )
( key ~= 'bibcode' and cu.parameterCleanup( frameArgs[ value2 ] ) or frameArgs[ value2 ] )
end
end
args[ key ] = args[ key ] or ''
args[ key ] = args[ key ] or ''
Zeile 77: Zeile 77:
if cu.isSet( args.title ) then
if cu.isSet( args.title ) then
args.title = args.title:gsub( '%s*%.+$', '' )
args.title = args.title:gsub( '%s*%.+$', '' )
end
-- convert book with chapter to collection
if args.type == 'book' and not cu.isSet( args.collection ) and cu.isSet( args.chapter ) then
args.type = 'bookitem'
args.collection, args.title, args.chapter = args.title, args.chapter, ''
args.siteUrl, args.url, args.chapterUrl = args.url, args.chapterUrl, ''
end
end


Zeile 157: Zeile 164:
for _, url in ipairs( ci.unwantedUrls ) do
for _, url in ipairs( ci.unwantedUrls ) do
if args.url:find( url, 1, true ) then
if args.url:find( url, 1, true ) then
cu.addErrorMsg( ci.texts.nounwantedURL )
cu.addErrorMsg( ci.texts.unwantedURL )
break
break
end
end
Zeile 204: Zeile 211:
end
end


local match, country
if cu.isSet( args.urn ) then
if cu.isSet( args.urn ) then
args.urn = args.urn:gsub( '^urn:', '' )
args.urn = args.urn:lower():gsub( '^urn:', '' )
if not ( args.urn:match( '^nbn:de:.+$' ) or args.urn:match( '^nbn:ch:.+$' ) ) then
match, country = args.urn:match( '^(nbn:(%l%l):[%d%l%-%.:/_]+)$' )
if not ( match and country and ci.nbnResolving[ country ] ) then
args.urn = ''
args.urn = ''
table.insert( wrong, 'urn' )
table.insert( wrong, 'urn' )
end
end
end
if cu.isSet( args.urn ) and ci.nbnCheckDigit[ country ] and
not cu.check_UrnNbn( 'urn:' .. args.urn ) then
cu.addErrorMsg( ci.texts.wrongURN )
end
end


Zeile 221: Zeile 234:
args.hdl = ''
args.hdl = ''
table.insert( wrong, 'hdl' )
table.insert( wrong, 'hdl' )
end
if not cu.isSet( args.url ) then
for _, key in ipairs( ci.additionalTitleUrls ) do
if cu.isSet( args[ key ] ) then
args.url = ci.params[ key ].url:format( args[ key ] )
if key == 'urn' then
args.urn = ''
end
break
end
end
end
end


Zeile 236: Zeile 261:


-- See: https://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes
-- See: https://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes
if cu.isSet( args.bibcode ) and not args.bibcode:match( '^[12]%d%d%d%a[%w&%.][%w&%.][%w&%.][%w.]+[%a%.]$' ) then
if cu.isSet( args.bibcode ) and
not ( args.bibcode:len() == 19 and args.bibcode:match( '^[12]%d%d%d%a[%w&%.][%w&%.][%w&%.][%w%.]+[%a%.]$' ) ) then
args.bibcode = ''
args.bibcode = ''
table.insert( wrong, 'bibcode' )
table.insert( wrong, 'bibcode' .. args.bibcode:len() )
end
if cu.isSet( args.bibcode ) then
args.bibcode = args.bibcode:gsub( '%.', '#b#' ) -- keep bibcode periods (full stops)
end
end


Zeile 263: Zeile 292:
end
end


if checkRedundantParams( args, { 'isbn', 'dnb', 'oclc', 'ol', 'asin' } ) or
if checkRedundantParams( args, { 'isbn', 'dnb', 'urn', 'oclc', 'ol', 'asin' } ) or
checkRedundantParams( args, { 'doi', 'hdl', 'jstor' } ) then
checkRedundantParams( args, { 'doi', 'hdl', 'jstor', 'arxiv', 'bibcode' } ) then
cu.addErrorMsg( ci.texts.redundantParams )
cu.addErrorMsg( ci.texts.redundantParams )
end
end
Zeile 532: Zeile 561:
cu.insertItem( result, args.series, ci.formatters.tiSeries )
cu.insertItem( result, args.series, ci.formatters.tiSeries )
makeIsbn( args, result )
makeIsbn( args, result )
if cu.isSet( args.chapter ) and cu.isSet( args.chapterUrl ) then
args.chapter = cu.makeLink( args.chapterUrl, args.chapter )
end
cu.insertItem( result, args.chapter, ci.formatters.tiChapter )
cu.insertItem( result, args.chapter, ci.formatters.tiChapter )
makePages( args, result )
makePages( args, result )
Zeile 694: Zeile 726:
if cu.isSet( args.access ) then
if cu.isSet( args.access ) then
citation = citation
citation = citation
.. '&nbsp;<span style="position:relative; top: -2px;">'
.. '&nbsp;<span class="voy-cite-access">'
.. ci.accessTypes[ args.access ].file .. '</span>'
.. ci.accessTypes[ args.access ].file .. '</span>'
end
end