Open main menu

Changes

Module:Authority control

1,177 bytes added, 06:48, 6 April 2013
Created page with 'function outputError( message, cat ) local str = '<span class="error">' .. message .. '</span>' if cat then str = str .. '[[Category:' .. cat .. ...'
function outputError( message, cat )
local str = '<span class="error">' .. message .. '</span>'
if cat then
str = str .. '[[Category:' .. cat .. ']]'
end
return str
end

function viafLink( id )
if not string.match( id, '^%d+$' ) then
return outputError( 'The VIAF id ' .. id .. ' is not valid.', 'Wikipedia articles with faulty authority control identifiers (VIAF)' )
end
return '<span class="uid">[http://viaf.org/viaf/' .. id .. ' ' .. id .. ']</span>'
end

local config = {
{ 'VIAF', '[[Virtual International Authority File|VIAF]]', 0, viafLink }
}

local p = {}

function p.authorityControl( frame )
local parentArgs = frame.getParent().args
--Create rows
local lines = {}
for k, conf in config do
if parentArgs[conf[0]] and parentArgs[conf[0]] ~= '' then
table.append( lines, conf[1] .. ': ' .. conf[3]( parentArgs[conf[0]] ) )
end
end

local Navbox = require('Module:Navbox')
return navbox._navbox( {
name = 'Authority control',
bodyclass = 'hlist',
group1 = '[[Authority control]]',
list1 = table.concat( lines, '*' )
} )
end
Anonymous user