User:Tommy Kronkvist/Lua

From Wikispecies
Jump to navigation Jump to search



Suggested replacement code for Module:Authority control, based on Lua code at en:Module:Authority control[edit]

Replace:

local function sbnLink( id )
    if not string.match( id, '^IT\\ICCU\\%d%d%d%d%d%d%d%d%d%d$' ) and not string.match( id, '^IT\\ICCU\\%u%u[%d%u]%u\\%d%d%d%d%d%d$' ) then
        return false
    end
    return '[http://id.sbn.it/af/' .. id .. ' ' .. id .. ']' .. getCatForId( 'SBN' )
end

...

    { 'SBN', '[[:w:Istituto Centrale per il Catalogo Unico|SBN]]', 396, sbnLink },

with:

local function iccuLink( id )
	--P396's format regex: \D{2}[A-Z0-3]V\d{6} (e.g. CFIV000163)
	if not id:match( '^%u%u[%u0-3]V%d%d%d%d%d%d$' ) then --legacy: %u used here instead of %D (but the faulty ID cat is empty, out of ~12k uses)
		return false
	end
	return '[https://opac.sbn.it/nome/'..id..' ' .. id .. ']' .. getCatForId( 'ICCU' )
end

...

    { 'ICCU', '[[:w:Istituto Centrale per il Catalogo Unico|ICCU]]', 396, iccuLink },