Modul:Pages with authority control identifiers
Videz
Mogoče bi radi ustvarili dokumentacijsko stran za ta Scribunto modul Urejevalci lahko preizkušate ta modul v peskovniku (uredi | primerjava) in testnihprimerih (ustvari). Prosimo, da dodate kategorije v /dok podstran. Podstrani te predloge. |
require('Module:No globals')
local p = {}
local ac_conf = require('Modul:Authority control/peskovnik').conf
local rmCats = require('Modul:Suppress categories').main
local currentTitle = mw.title.getCurrentTitle()
local title = currentTitle.text
local isCat = (currentTitle.namespace == 14)
--[[==========================================================================]]
--[[ Local Utility Functions ]]
--[[==========================================================================]]
local function whichTOC( frame )
--local pageCount = mw.site.stats.pagesInCategory(title, 'pages')
--if pageCount > 1200 then
-- return frame:expandTemplate{ title = 'TOC Obsežna kategorija' }
--elseif pageCount > 100 then
-- return frame:expandTemplate{ title = 'Kategorija TOC', args = { align = 'center' } }
--end
--return ''
-- standardize TOC behavior via {{CatAutoTOC}}
return frame:expandTemplate{ title = 'CatAutoTOC', args = { align = 'center' } }
end
local function redCatCheck( catName ) --catName == 'Blah', not 'Category:Blah', not '[[Kategorija:Blah]]'
if catName and catName ~= '' and mw.title.new(catName, 14).exists == false then
return '[[Category:Pages with authority control identifiers red-linked category]]'
end
return ''
end
local function getExample(conf, id)
if id == "WORLDCATID" then
return "[https://www.worldcat.org/identities/lccn-n78039510 WorldCat]"
else
return rmCats(conf[3](conf[5]))
end
end
--[[==========================================================================]]
--[[ Local Category-Specific Functions ]]
--[[==========================================================================]]
--For indirect use on [[Category:<catType> with multiple identifiers]],
-- i.e. on [[Category:Wikipedia articles with multiple identifiers]]
local function multiple( frame, catType, pre, post )
local txCatMore = frame:expandTemplate{ title = 'Cat more', args = { 'Wikipedija:Normativna kontrola' } }
local txEmptyCat = frame:expandTemplate{ title = 'Prazna kategorija' }
local txWPCat = frame:expandTemplate{ title = 'Projektna kategorija', args = { hidden = 'yes', tracking = 'yes' } }
local txQ = frame:expandTemplate{ title = 'Q', args = { 'Q7245' } }
local txWdpl1 = frame:expandTemplate{ title = 'P', args = { 'P213' } }
local txWdpl2 = frame:expandTemplate{ title = 'P', args = { 'P244' } }
local txTOC = whichTOC( frame )
local ex = 'Na primer, '..txQ..' vsebuje več IDjev za '..txWdpl1..', '..txWdpl2..', itd.<br/>'
local only = 'Strani v tej kategoriji se dodajo le preko [[Modul:Authority control]].'
if catType and catType == 'strani' then
txEmptyCat = ''
txWPCat = frame:expandTemplate{ title = 'Projektna kategorija' }
ex = ''
only = ''
end
local outString = txCatMore..txEmptyCat..txWPCat..txTOC..'\n'..ex..only
return (pre or '')..outString..(post or '')
end
--For use in [[Kategorija:Strani s podatki o normativni kontroli]],
-- i.e. on [[Kategorija:Strani z identifikatorji VIAF]]
local function pages( frame, id )
if id == 'multiple' then
local pagesCat = 'Strani s podatki o normativni kontroli'
local pagesCatFull = '[[Kategorija:'..pagesCat..']]'..redCatCheck(pagesCat)
return multiple( frame, 'strani', '', pagesCatFull )
end
for _, conf in pairs( ac_conf ) do
if conf.category == id or conf[1] == id then
local linktarget = conf.link or conf[1] .. ' (identifikator)'
local wdpl = ':d:Property:P'..conf[2]
local txCatMore = frame:expandTemplate{ title = 'Cat more', args = {'Wikipedija:Normativna kontrola', linktarget, wdpl} }
local txWPCat = frame:expandTemplate{ title = 'Projektna kategorija' }
local pagesCat = 'Strani s podatki o normativni kontroli'
local outString = txCatMore..txWPCat..'\n'..
'[[Kategorija:'..pagesCat..'|'..id..']]'..redCatCheck(pagesCat)
return outString
end
end
return ''
end
--For use in [[Kategorija:Razne strani s podatki o normativni kontroli]],
-- i.e. on [[Kategorija:Razne strani z identifikatorji VIAF]]
local function misc( frame, id )
if id == 'multiple' then
local link = id
local txCatExplain = frame:expandTemplate{ title = 'Razlaga kategorije',
args = { 'pages, other than main user pages or Wikipedia articles, using {{[[Predloga:Normativna kontrola|Normativna kontrola]]}} z identifikatorji'..link..'.' } }
local idCat = 'Strani z identifikatorji '..id..''
local miscCat = 'Razne strani s podatki o normativni kontroli'
local idCatFull = '[[Kategorija:'..idCat..']]'..redCatCheck(idCat)
local miscCatFull = '[[Kategorija:'..miscCat..'|'..id..']]'..redCatCheck(miscCat)
return multiple( frame, 'misc', txCatExplain, idCatFull..miscCatFull )
end
for _, conf in pairs( ac_conf ) do
if conf.category == id or conf[1] == id then
local linktarget = conf.link or conf[1] .. ' (identifikator)'
local link = '[['..linktarget..'|'..conf[1]..']]'
local example = 'Identifikator ' .. conf[1].. ' se pojavi kot '..getExample(conf, id)..' v poglavju '..conf[2]..'.'
local wdpl = ':d:Property:P'..conf[3]
local txCatExplain = frame:expandTemplate{ title = 'Razlaga kategorije',
args = { 'pages, other than main user pages or Wikipedia articles, using {{[[Predloga:Normativna kontrola|Normativna kontrola]]}} z identifikatorji '..link..'. '..example } }
local txCatMore = frame:expandTemplate{ title = 'Cat more', args = {'Wikipedija:Normativna kontrola', wdpl} }
local txEmptyCat = frame:expandTemplate{ title = 'Prazna kategorija' }
local txWPCat = frame:expandTemplate{ title = 'Projektna kategorija', args = { hidden = 'yes', tracking = 'yes' } }
local txTOC = whichTOC( frame )
local idCat = 'Strani z identifikatorji '..id..''
local miscCat = 'Razne strani s podatki o normativni kontroli'
local outString = txCatExplain..txCatMore..txEmptyCat..txWPCat..txTOC..'\n'..
'Pages in this category should only be added by [[Modul:Authority control]].'..
'[[Category:'..idCat..']]'..redCatCheck(idCat)..
'[[Category:'..miscCat..'|'..id..']]'..redCatCheck(miscCat)
return outString
end
end
return ''
end
--For use in [[Category:User pages with authority control information]],
-- i.e. on [[Category:User pages with VIAF identifiers]]
local function user( frame, id )
if id == 'multiple' then
local idCat = 'Strani z identifikatorji '..id..''
local userCat = 'User pages with authority control information'
local idCatFull = '[[Category:'..idCat..']]'..redCatCheck(idCat)
local userCatFull = '[[Category:'..userCat..'|'..id..']]'..redCatCheck(userCat)
return multiple( frame, 'user', '', idCatFull..userCatFull )
end
for _, conf in pairs( ac_conf ) do
if conf.category == id or conf[1] == id then
local linktarget = conf.link or conf[1] .. ' (identifikator)' local wdpl = ':d:Property:P'..conf[3]
local txCatMore = frame:expandTemplate{ title = 'Cat more', args = {'Wikipedija:Normativna kontrola', linktarget, wdpl} }
local txEmptyCat = frame:expandTemplate{ title = 'Prazna kategorija' }
local txWPCat = frame:expandTemplate{ title = 'Projektna kategorija', args = { hidden = 'yes', tracking = 'yes' } }
local txTOC = whichTOC( frame )
local idCat = 'Strani z identifikatorji '..id..''
local userCat = 'User pages with authority control information'
local outString = txCatMore..txEmptyCat..txWPCat..txTOC..'\n'..
'Pages in this category should only be added by [[Modul:Authority control]].'..
'[[Category:'..idCat..']]'..redCatCheck(idCat)..
'[[Category:'..userCat..'|'..id..']]'..redCatCheck(userCat)
return outString
end
end
return ''
end
--For use in [[Kategorija:Wikipedijini članki s podatki o normativni kontroli]],
-- i.e. on [[Kategorija:Wikipedijini članki z identifikatorji VIAF]]
local function wp( frame, id )
if id == 'multiple' then
local link = id
local txCatExplain = frame:expandTemplate{ title = 'Razlaga kategorije', args = {'članki z '..link..' identifikatorji. Prosimo da ne dodajate [[Wikipedija:Kategorizacija#Ustvarjanje podkategorij|podkategorije]].'} }
local idCat = 'Strani z identifikatorji '..id..''
local wpCat = 'Wikipedijini članki s podatki o normativni kontroli'
local idCatFull = '[[Kategorija:'..idCat..']]'..redCatCheck(idCat)
local wpCatFull = '[[Kategorija:'..wpCat..'|'..id..']]'..redCatCheck(wpCat)
return multiple( frame, 'wp', txCatExplain, idCatFull..wpCatFull )
end
for _, conf in pairs( ac_conf ) do
if conf.category == id or conf[1] == id then
local linktarget = conf.link or conf[1] .. ' (identifikator)' local link = '[['..linktarget..'|'..conf[1]..']]'
local wdpl = ':d:Property:P'..conf[3]
local example = 'Identifikator ' .. conf[1].. ' se pojavi kot '..getExample(conf, id)..' v poglavju '..conf[2]..'.'
local txCatExplain = frame:expandTemplate{ title = 'Razlaga kategorije', args = {'članki z '..link..' identifikatorji.'..example..' Prosimo da ne dodajate [[Wikipedija:Kategorizacija#Ustvarjanje podkategorij|podkategorije]].'} }
local txCatMore = frame:expandTemplate{ title = 'Cat more', args = {'Wikipedija:Normativna kontrola', wdpl} }
local txEmptyCat = frame:expandTemplate{ title = 'Prazna kategorija' }
local txWPCat = frame:expandTemplate{ title = 'Projektna kategorija', args = { hidden = 'yes', tracking = 'yes' } }
local txTOC = whichTOC( frame )
local idCat = 'Strani z identifikatorji '..id..''
local wpCat = 'Wikipedijini članki s podatki o normativni kontroli'
local outString = txCatExplain..txCatMore..txEmptyCat..txWPCat..txTOC..'\n'..
'Pages in this category should only be added by [[Modul:Authority control]].'..
'[[Kategorija:'..idCat..']]'..redCatCheck(idCat)..
'[[Kategorija:'..wpCat..'|'..id..']]'..redCatCheck(wpCat)
return outString
end
end
return ''
end
--For use in [[Category:Wikipedia articles with faulty authority control information]],
-- i.e. on [[Category:Wikipedia articles with faulty VIAF identifiers]]
local function wpfaulty( frame, id )
for _, conf in pairs( ac_conf ) do
if conf.category == id or conf[1] == id then
local linktarget = conf.link or conf[1] .. ' (identifikator)'
local wdpl = ':d:Property:P'..conf[3]
local txCatMore = frame:expandTemplate{ title = 'Cat more', args = {'Wikipedija:Normativna kontrola', linktarget, wdpl} }
local txEmptyCat = frame:expandTemplate{ title = 'Prazna kategorija' }
local txWPCat = frame:expandTemplate{ title = 'Projektna kategorija', args = { hidden = 'yes', tracking = 'yes' } }
local txDirtyCat = frame:expandTemplate{ title = 'Pollutedcat' }
local txTOC = whichTOC( frame )
local idCat = 'Strani z identifikatorji '..id..''
local wpfCat = 'Wikipedia articles with faulty authority control information'
local outString = txCatMore..txEmptyCat..txWPCat..txDirtyCat..txTOC..'\n'..
'Pages in this category should only be added by [[Modul:Authority control]].'..
'[[Kategorija:'..idCat..']]'..redCatCheck(idCat)..
'[[Kategorija:'..wpfCat..'|'..id..']]'..redCatCheck(wpfCat)
return outString
end
end
return ''
end
--[[==========================================================================]]
--[[ Main/External Call ]]
--[[==========================================================================]]
function p.autoDetect( frame )
if isCat then
local pagesID = mw.ustring.match(title, 'Strani z identifikatorji ([%w%.%- ]+)')
local miscID = mw.ustring.match(title, 'Razne strani z identifikatorji ([%w%.%- ]+)')
local userID = mw.ustring.match(title, 'Uporabniške strani z identifikatorji ([%w%.%- ]+)')
local wpfaultyID = mw.ustring.match(title, 'Wikipedijini članki z okvarjenimi identifikatorji ([%w%.%- ]+)')
local wpID = mw.ustring.match(title, 'Wikipedijini članki z identifikatorji ([%w%.%- ]+)')
if pagesID then return pages( frame, pagesID )
elseif miscID then return misc( frame, miscID )
elseif userID then return user( frame, userID )
elseif wpfaultyID then return wpfaulty( frame, wpfaultyID ) --must be before wpID check, in case they both match
elseif wpID then return wp( frame, wpID ) --to keep the regex simple
else return '[[Kategorija:Strani z neznano kategorijo identifikatorjev normativne kontrole]]'
end
end
return ''
end
return p