Module:Authority control: Διαφορά μεταξύ των αναθεωρήσεων
Εμφάνιση
Περιεχόμενο που διαγράφηκε Περιεχόμενο που προστέθηκε
Tpt (συζήτηση | συνεισφορές) Χωρίς σύνοψη επεξεργασίας |
Tpt (συζήτηση | συνεισφορές) μΧωρίς σύνοψη επεξεργασίας |
||
Γραμμή 1: | Γραμμή 1: | ||
function |
function addCatForId( frame, id ) |
||
local title = mw.title.getCurrentTitle() |
local title = mw.title.getCurrentTitle() |
||
local namespace = title.namespace |
local namespace = title.namespace |
||
if namespace == 0 then |
if namespace == 0 then |
||
frame:preprocess( '[[Category:Wikipedia articles with ' .. id .. ' identifiers]]' ) |
|||
elseif namespace == 2 and not title.isSubpage then |
elseif namespace == 2 and not title.isSubpage then |
||
frame:preprocess( '[[Category:User pages with ' .. id .. ' identifiers]]' ) |
|||
else |
else |
||
frame:preprocess( '[[Category:Miscellaneous pages with ' .. id .. ' identifiers]]' ) |
|||
end |
end |
||
end |
end |
||
Γραμμή 33: | Γραμμή 33: | ||
local link = params[4]( val ) |
local link = params[4]( val ) |
||
if link then |
if link then |
||
table.insert( elements, params[2] .. ': <span class="uid">' .. link .. '</span>' |
table.insert( elements, params[2] .. ': <span class="uid">' .. link .. '</span>' ) |
||
addCatForId( frame, params[1] ) |
|||
else |
else |
||
table.insert( elements, '<span class="error">The ' .. params[1] .. ' id ' .. val .. ' is not valid.</span>[[Category:Wikipedia articles with faulty authority control identifiers (' .. params[1] .. ')]]' ) |
table.insert( elements, '<span class="error">The ' .. params[1] .. ' id ' .. val .. ' is not valid.</span>' ) |
||
frame:preprocess( '[[Category:Wikipedia articles with faulty authority control identifiers (' .. params[1] .. ')]]' ) |
|||
end |
end |
||
Έκδοση από την 07:26, 6 Απριλίου 2013
![](http://upload.wikimedia.org/wikipedia/commons/thumb/4/43/Test_Template_Info-Icon_-_Version_%282%29.svg/50px-Test_Template_Info-Icon_-_Version_%282%29.svg.png)
function addCatForId( frame, id )
local title = mw.title.getCurrentTitle()
local namespace = title.namespace
if namespace == 0 then
frame:preprocess( '[[Category:Wikipedia articles with ' .. id .. ' identifiers]]' )
elseif namespace == 2 and not title.isSubpage then
frame:preprocess( '[[Category:User pages with ' .. id .. ' identifiers]]' )
else
frame:preprocess( '[[Category:Miscellaneous pages with ' .. id .. ' identifiers]]' )
end
end
function viafLink( id )
if not string.match( id, '^%d+$' ) then
return false
end
return '[http://viaf.org/viaf/' .. id .. ' ' .. id .. ']'
end
local conf = {
{ 'VIAF', '[[Virtual International Authority File|VIAF]]', 0, viafLink }
}
local p = {}
function p.authorityControl( frame )
local parentArgs = frame:getParent().args
--Create rows
local elements = {}
for k, params in pairs( conf ) do
local val = parentArgs[params[1]]
if val and val ~= '' then
local link = params[4]( val )
if link then
table.insert( elements, params[2] .. ': <span class="uid">' .. link .. '</span>' )
addCatForId( frame, params[1] )
else
table.insert( elements, '<span class="error">The ' .. params[1] .. ' id ' .. val .. ' is not valid.</span>' )
frame:preprocess( '[[Category:Wikipedia articles with faulty authority control identifiers (' .. params[1] .. ')]]' )
end
end
end
local Navbox = require('Module:Navbox')
return Navbox._navbox( {
name = 'Authority control',
bodyclass = 'hlist',
group1 = '[[Authority control]]',
list1 = table.concat( elements, '*' )
} )
end
return p