Difference between revisions of "Module:Authority control"
Jump to navigation
Jump to search
en>Tpt (←Created page with 'function outputError( message, cat ) local str = '<span class="error">' .. message .. '</span>' if cat then str = str .. '[[Category:' .. cat .. ...') |
en>Tpt m |
||
| Line 38: | Line 38: | ||
} ) | } ) | ||
end | end | ||
| + | |||
| + | return p | ||
Revision as of 06:53, 6 April 2013
Documentation for this module may be created at Module:Authority control/doc
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
return p