Modul:Citation: Unterschied zwischen den Versionen
formatters, checkRedundantParams, unwantedUrls
(pattern) |
(formatters, checkRedundantParams, unwantedUrls) |
||
| Zeile 2: | Zeile 2: | ||
local citation = { | local citation = { | ||
suite = 'Citation', | suite = 'Citation', | ||
serial = '2022-08- | serial = '2022-08-12', | ||
item = 56159597 | item = 56159597 | ||
} | } | ||
| Zeile 55: | Zeile 55: | ||
end | end | ||
return args | return args | ||
end | |||
local function checkRedundantParams( args, keys ) | |||
local i = 0 | |||
for _, key in ipairs( keys ) do | |||
if cu.isSet( args[ key ] ) then | |||
i = i + 1 | |||
if i > 1 then | |||
return true | |||
end | |||
end | |||
end | |||
return false | |||
end | end | ||
| Zeile 139: | Zeile 152: | ||
args[ value ] = '' | args[ value ] = '' | ||
cu.addErrorMsg( ci.texts.noURL ) | cu.addErrorMsg( ci.texts.noURL ) | ||
end | |||
end | |||
if cu.isSet( args.url ) then | |||
for _, url in ipairs( ci.unwantedUrls ) do | |||
if args.url:find( url, 1, true ) then | |||
cu.addErrorMsg( ci.texts.nounwantedURL ) | |||
break | |||
end | |||
end | end | ||
end | end | ||
| Zeile 211: | Zeile 232: | ||
cu.addErrorMsg( ci.texts.accessNoUrl ) | cu.addErrorMsg( ci.texts.accessNoUrl ) | ||
end | end | ||
end | |||
if checkRedundantParams( args, { 'isbn', 'dnb', 'oclc', 'ol', 'asin' } ) or | |||
checkRedundantParams( args, { 'doi', 'hdl', 'jstor' } ) then | |||
cu.addErrorMsg( ci.texts.redundantParams ) | |||
end | end | ||
| Zeile 225: | Zeile 251: | ||
text = ci.texts.wrongIssn | text = ci.texts.wrongIssn | ||
end | end | ||
return ci. | return ci.params.issn.format:gsub( 'xx1xx', issn ) | ||
.. cx.check_issn( { args = { [ 1 ] = issn, error = text } } ) | .. cx.check_issn( { args = { [ 1 ] = issn, error = text } } ) | ||
end | end | ||
| Zeile 314: | Zeile 340: | ||
li._linkISBNSet( { isbn = args.isbn, ignoreError = args.ignoreError } ) ) | li._linkISBNSet( { isbn = args.isbn, ignoreError = args.ignoreError } ) ) | ||
elseif cu.isSet( args.dnb ) then | elseif cu.isSet( args.dnb ) then | ||
cu.insertItem2( tab, args.dnb, args.dnb, ci. | cu.insertItem2( tab, args.dnb, args.dnb, ci.params.dnb.format ) | ||
elseif cu.isSet( args.oclc ) then | elseif cu.isSet( args.oclc ) then | ||
cu.insertItem2( tab, args.oclc, args.oclc, ci. | cu.insertItem2( tab, args.oclc, args.oclc, ci.params.oclc.format ) | ||
elseif cu.isSet( args.ol ) then | elseif cu.isSet( args.ol ) then | ||
local prefix = { | local prefix = { | ||
| Zeile 324: | Zeile 350: | ||
}; | }; | ||
local link = prefix[ args.ol:sub( -1 ) ] .. args.ol | local link = prefix[ args.ol:sub( -1 ) ] .. args.ol | ||
cu.insertItem2( tab, link, args.ol:sub( 3 ), ci. | cu.insertItem2( tab, link, args.ol:sub( 3 ), ci.params.ol.format ) | ||
elseif cu.isSet( args.asin ) then | elseif cu.isSet( args.asin ) then | ||
cu.insertItem2( tab, args.asin, args.asin, ci. | cu.insertItem2( tab, args.asin, args.asin, ci.params.asin.format ) | ||
end | end | ||
if cu.isSet( args.issn ) then | if cu.isSet( args.issn ) then | ||
| Zeile 353: | Zeile 379: | ||
end | end | ||
if cu.isSet( args.doi ) then | if cu.isSet( args.doi ) then | ||
cu.insertItem2( tab, cu.encodeHandle( args.doi ), args.doi, ci. | cu.insertItem2( tab, cu.encodeHandle( args.doi ), args.doi, ci.params.doi.format ) | ||
elseif cu.isSet( args.hdl ) then | elseif cu.isSet( args.hdl ) then | ||
cu.insertItem2( tab, cu.encodeHandle( args.hdl ), args.hdl, ci. | cu.insertItem2( tab, cu.encodeHandle( args.hdl ), args.hdl, ci.params.hdl.format ) | ||
else | |||
-- JSTOR = doi:10.2307 | |||
cu.insertItem2( tab, args.jstor, args.jstor, ci.params.jstor.format ) | |||
end | end | ||
cu.insertItem2( tab, args. | cu.insertItem2( tab, args.pmid, args.pmid, ci.params.pmid.format ) | ||
end | end | ||