Module:Authority control

function outputError( message, cat ) local str = ' ' .. message .. ' '   if cat then str = str .. ''   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 ' [http://viaf.org/viaf/' .. id .. ' ' .. id .. '] ' end

local config = { { 'VIAF', '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