Modul:Citation: Unterschied zwischen den Versionen

Ergänzungen
K (decimalPoint)
(Ergänzungen)
Zeile 2: Zeile 2:
local scrollGallery = {
local scrollGallery = {
suite  = 'Citation',
suite  = 'Citation',
serial = '2020-03-23',
serial = '2020-03-24',
}
}


Zeile 23: Zeile 23:
}
}


-- no index: possible parameter names
-- types: reference types for which parameter is valid
-- COinS: COinS key
-- COinS_id: COinS
-- cleanup = true: complete cleanup
local params = {
local params = {
type      = { 'type', 'Typ' },
type      = { 'type', 'Typ', cleanup = true },
author    = { 'Autor', COinS = 'rft.au' },
author    = { 'Autor', COinS = 'rft.au', cleanup = true },
editor    = { 'Herausgeber', 'Hrsg' },
editor    = { 'Herausgeber', 'Hrsg', cleanup = true },
title      = { 'Titel', COinS = 'rft.title' },
title      = { 'Titel', COinS = 'rft.title', cleanup = true },
chapter    = { 'Kapitel', types = 'book', COinS = 'rft.atitle' },
chapter    = { 'Kapitel', types = 'book', COinS = 'rft.atitle', cleanup = true },
collection = { 'Sammelwerk', types = 'collection' },
collection = { 'Sammelwerk', types = 'collection', cleanup = true },
journal    = { 'Zeitschrift', 'Sammelwerk', types = 'journal', COinS = 'rft.jtitle' },
journal    = { 'Zeitschrift', 'Sammelwerk', types = 'journal', COinS = 'rft.jtitle', cleanup = true },
newspaper  = { 'Zeitung', 'Sammelwerk', types = 'newspaper', COinS = 'rft.jtitle' },
newspaper  = { 'Zeitung', 'Sammelwerk', types = 'newspaper', COinS = 'rft.jtitle', cleanup = true },
abbr      = { 'Abk', types = { 'collection', 'journal', 'newspaper' } },
abbr      = { 'Abk', types = { 'collection', 'journal', 'newspaper' }, cleanup = true },
url        = { 'Online', 'URL' },
url        = { 'Online', 'URL', cleanup = true },
articleUrl = { 'Onlineaufsatz', 'Aufsatz-URL', types = { 'collection', 'journal', 'newspaper' } },
articleUrl = { 'Onlineaufsatz', 'Aufsatz-URL', types = { 'collection', 'journal', 'newspaper' }, cleanup = true },
jstor      = { 'JSTOR', types = { 'journal', 'newspaper' } },
jstor      = { 'JSTOR', types = { 'journal', 'newspaper' }, cleanup = true },
KBytes    = { 'KBytes', 'kBytes', 'kbytes' },
KBytes    = { 'KBytes', 'kBytes', 'kbytes', cleanup = true },
accessDate = { 'Zugriff', 'Abruf' },
accessDate = { 'Zugriff', 'Abruf', cleanup = true },
scale      = { 'Maßstab', types = 'map' },
scale      = { 'Maßstab', types = 'map', cleanup = true },
place      = { 'Ort', COinS = 'rft.place' },
place      = { 'Ort', COinS = 'rft.place', cleanup = true },
publisher  = { 'Verlag', types = { 'book', 'map', 'collection' }, COinS = 'rft.pub' },
publisher  = { 'Verlag', types = { 'book', 'map', 'collection' }, COinS = 'rft.pub', cleanup = true },
date      = { 'Datum', 'Jahr', COinS = 'rft.date' },
date      = { 'Datum', 'Jahr', COinS = 'rft.date', cleanup = true },
edition    = { 'Auflage', types = { 'book', 'map', 'collection' }, COinS = 'rft.edition' },
edition    = { 'Auflage', types = { 'book', 'map', 'collection' }, COinS = 'rft.edition', cleanup = true },
volume    = { 'Band', COinS = 'rft.volume' },
volume    = { 'Band', COinS = 'rft.volume', cleanup = true },
issue      = { 'Ausgabe', 'Nummer', 'Heft', types = { 'journal', 'newspaper' }, COinS = 'rft.issue' },
issue      = { 'Ausgabe', 'Nummer', 'Heft', types = { 'journal', 'newspaper' }, COinS = 'rft.issue', cleanup = true },
pages      = { 'Seite', 'Seiten', types = { 'book', 'collection', 'journal', 'newspaper' }, COinS = 'rft.pages' },
pages      = { 'Seite', 'Seiten', types = { 'book', 'collection', 'journal', 'newspaper' }, COinS = 'rft.pages', cleanup = true },
columns    = { 'Spalten', types = { 'book', 'collection', 'journal', 'newspaper' }, COinS = 'rft.pages' },
columns    = { 'Spalten', types = { 'book', 'collection', 'journal', 'newspaper' }, COinS = 'rft.pages', cleanup = true },
extent    = { 'Umfang', 'Seitenanzahl', types = { 'book', 'collection', 'map' } },
extent    = { 'Umfang', 'Seitenanzahl', types = { 'book', 'collection', 'map' } },
series    = { 'Serie', 'Reihe', types = { 'book', 'collection', 'map' }, COinS = 'rft.series' },
series    = { 'Serie', 'Reihe', types = { 'book', 'collection', 'map' }, COinS = 'rft.series', cleanup = true },
series2    = { 'Serie2', 'Reihe2', types = { 'book', 'collection', 'map' } },
series2    = { 'Serie2', 'Reihe2', types = { 'book', 'collection', 'map' }, cleanup = true },
series3    = { 'Serie3', 'Reihe3', types = { 'book', 'collection', 'map' } },
series3    = { 'Serie3', 'Reihe3', types = { 'book', 'collection', 'map' }, cleanup = true },
isbn      = { 'ISBN', types = { 'book', 'collection', 'map', 'journal' }, COinS = 'rft.isbn' },
isbn      = { 'ISBN', types = { 'book', 'collection', 'map', 'journal' }, COinS = 'rft.isbn', cleanup = true },
dnb        = { 'DNB', types = { 'book', 'collection', 'map' } },
dnb        = { 'DNB', types = { 'book', 'collection', 'map' }, cleanup = true },
oclc      = { 'OCLC', types = { 'book', 'collection', 'map' }, COinS_id = 'info:oclcnum' },
oclc      = { 'OCLC', types = { 'book', 'collection', 'map' }, COinS_id = 'info:oclcnum', cleanup = true },
issn      = { 'ISSN', COinS = 'rft.issn' },
issn      = { 'ISSN', COinS = 'rft.issn', cleanup = true },
doi        = { 'DOI', COinS_id = 'info:doi' },
doi        = { 'DOI', COinS_id = 'info:doi', cleanup = true },
language  = { 'Sprache' },
language  = { 'Sprache' },
comment    = { 'Kommentar' },
comment    = { 'Kommentar' },
noError    = { 'noError', 'noerror', 'keinFehler', 'kein Fehler' }
noError    = { 'noError', 'noerror', 'keinFehler', 'kein Fehler', cleanup = true }
}
}


Zeile 97: Zeile 102:
dbJstor = '[[w:JSTOR|JSTOR]] [https://www.jstor.org/stable/%s %s]',
dbJstor = '[[w:JSTOR|JSTOR]] [https://www.jstor.org/stable/%s %s]',
wbAccess = 'Internetabruf am %s',
wbAccess = 'Internetabruf am %s',
wbKBytes = 'Dateigröße %s KByte',
wbKBytes = 'Dateigröße: %s KByte',
wbMBytes = 'Dateigröße %s MByte'
wbMBytes = 'Dateigröße: %s MByte'
}
}


Zeile 130: Zeile 135:
local function addErrorMsg( msg )
local function addErrorMsg( msg )
table.insert( errorMsgs, msg )
table.insert( errorMsgs, msg )
end
local function getErrorMsgs()
local i, j, result
-- remove duplicates
for i = #errorMsgs, 1, -1 do
for j = 1, #errorMsgs - 1, 1 do
if errorMsgs[ i ] == errorMsgs[ j ] then
table.remove( errorMsgs, i )
break
end
end
end
result = table.concat( errorMsgs, ' ' )
if result ~= '' then
result = result .. ' '
end
return result
end
end


Zeile 158: Zeile 182:
-- convert type values if translated
-- convert type values if translated
-- local function getRefType( t )
-- local function getRefType( t )
local function getRefType( t )
local function getRefType( t, default )
     local key, tab
     local result = '', key, tab
     for key, tab in pairs( refTypes ) do
     for key, tab in pairs( refTypes ) do
         if inArray( tab, t ) then
         if inArray( tab, t ) then
             t = key
             result = key
             break
             break
         end
         end
     end
     end
     return t
    if result == '' then
    result = default
    end
     return result
end
end


Zeile 200: Zeile 227:
s = mw.ustring.gsub( s, '%[%[[^%[%]]*|([^%[%]]*)%]%]', '%1' ) -- MediaWiki links
s = mw.ustring.gsub( s, '%[%[[^%[%]]*|([^%[%]]*)%]%]', '%1' ) -- MediaWiki links
s = mw.ustring.gsub( s, '%[%[([^%[%]]*)%]%]', '%1' )
s = mw.ustring.gsub( s, '%[%[([^%[%]]*)%]%]', '%1' )
s = s:gsub( "''+", '' ) -- multiple apostrophes
end
end
return mw.ustring.gsub( s, '</*span%s*/*>', '' )
return mw.ustring.gsub( s, '</*span%s*/*>', '' )
Zeile 209: Zeile 237:
local complete = {}
local complete = {}
local wrongParams = {}
local wrongParams = {}
local aType = getRefType( getArgValue( 'type', frameArgs ) )
local aType = getRefType( getArgValue( 'type', frameArgs ), 'book' )


for key, value in pairs( params ) do
for key, value in pairs( params ) do
Zeile 216: Zeile 244:
complete[ value2 ] = key
complete[ value2 ] = key
args[ key ] = args[ key ] or
args[ key ] = args[ key ] or
cleanupParameters( frameArgs[ value2 ], key ~= 'comment' )
cleanupParameters( frameArgs[ value2 ], key.cleanup )
end
end
args[ key ] = args[ key ] or ''
args[ key ] = args[ key ] or ''
Zeile 242: Zeile 270:


local function getPageNumbers( pages )
local function getPageNumbers( pages )
if not pages then
if not isSet( pages ) then
return ''
return ''
end
end
Zeile 288: Zeile 316:
end
end


i = 0
for key, value in ipairs( { 'url', 'articleUrl' } ) do
for key, value in ipairs( { 'url', 'articleUrl' } ) do
if isSet( args[ value ] ) and uc.isUrl( args[ value ] ) > 2 then
if isSet( args[ value ] ) and uc.isUrl( args[ value ] ) > 2 then
args[ value ] = ''
args[ value ] = ''
i = i + 1
addErrorMsg( texts.noURL )
end
end
end
if i > 0 then
addErrorMsg( texts.noURL )
end
end


i = 0
for key, value in ipairs( { 'dnb', 'oclc', 'jstor', 'KBytes' } ) do
for key, value in ipairs( { 'dnb', 'oclc', 'jstor', 'KBytes' } ) do
if isSet( args[ value ] ) and not args[ value ]:match( '^%d+$' ) then
if isSet( args[ value ] ) and not args[ value ]:match( '^%d+$' ) then
args[ value ] = ''
args[ value ] = ''
i = i + 1
addErrorMsg( texts.wrongValue )
end
end
end
if i > 0 then
addErrorMsg( texts.wrongValue )
end
end


args.edition = args.edition:match( '%d+' ) or ''
if isSet( args.edition ) then
if args.edition == '1' then
args.edition = args.edition:match( '%d+' ) or ''
args.edition = ''
if args.edition == '1' then
args.edition = ''
end
end
end


if args.type ~= 'map' then
if isSet( args.type ) and args.type ~= 'map' then
args.scale = ''
args.scale = ''
end
end
Zeile 658: Zeile 680:


local function prepareForCOinS( args )
local function prepareForCOinS( args )
args.pages = args.pages or ''
args.pages = args.pages:match( '%d+%s*%-%s*%d+' )
args.pages = args.pages:match( '%d+%s*%-%s*%d+' )
or args.pages:match( '%d+' ) or ''
or args.pages:match( '%d+' ) or ''
args.pages = args.pages:gsub( ' ', '' )
args.pages = args.pages:gsub( ' ', '' )
args.columns = args.columns or ''
args.columns = args.columns:match( '%d+%s*%-%s*%d+' )
args.columns = args.columns:match( '%d+%s*%-%s*%d+' )
or args.columns:match( '%d+' ) or ''
or args.columns:match( '%d+' ) or ''
Zeile 669: Zeile 694:


-- only first author
-- only first author
args.author = getFirst( args.author, ';' )
args.author = getFirst( args.author or '', ';' )
local count
local count
_,count = args.author:gsub( ',', ',' )
_,count = args.author:gsub( ',', ',' )
Zeile 676: Zeile 701:
end
end


args.isbn = getFirst( args.isbn, ',' )
args.isbn = getFirst( args.isbn or '', ',' )
args.isbn = args.isbn:match( '[%d%-Xx]+' )
end
end


Zeile 683: Zeile 709:


local function insertCOinS( key, value )
local function insertCOinS( key, value )
table.insert( rft, key .. '=' .. mw.uri.encode( '' .. value ) )
if isSet( value ) then
table.insert( rft, key .. '=' .. mw.uri.encode( '' .. value ) )
end
end
end


for key, value in pairs( params ) do
for key, value in pairs( params ) do
if isSet( args[ key ] ) then
if isSet( args[ key ] ) then
if value.COinS then
if value.COinS and value.COinS ~= 'rft.jtitle=' then
insertCOinS( value.COinS, args[ key ] )
insertCOinS( value.COinS, args[ key ] )
elseif value.COinS_id then
elseif value.COinS_id then
Zeile 743: Zeile 771:
citation = makePeriodical( args )
citation = makePeriodical( args )
else
else
args.type = 'book'
citation = texts.wrongType
citation = texts.wrongType
end
end
Zeile 749: Zeile 778:
prepareForCOinS( args )
prepareForCOinS( args )


return table.concat( errorMsgs, ' ' )
return getErrorMsgs()
.. '<cite style="font-style: normal;" class="citation ' .. args.type
.. '<cite style="font-style: normal;" class="citation ' .. args.type
.. ' printNoLink">' .. citation .. '</cite>' .. makeCOinS( args )
.. ' printNoLink">' .. citation .. '</cite>' .. makeCOinS( args )
Zeile 787: Zeile 816:
local args = frame:getParent().args
local args = frame:getParent().args


args.type = getRefType( getArgValue( 'type', args ) )
args.type = getRefType( getArgValue( 'type', args ), '' )
if not isSet( aType ) then
if not isSet( args.type ) then
if getArgValue( 'scale', args ) ~= '' then
if getArgValue( 'scale', args ) ~= '' then
args.type = 'map'
args.type = 'map'
Anonymer Benutzer