モジュール:Pages with authority control identifiers
Wikimedia module / ウィキペディア フリーな encyclopedia
require('Module:No globals')
local p = {} local ac_conf = require('Module:Authority control').conf local rmCats = require('Module:Suppress categories').main local currentTitle = mw.title.getCurrentTitle() local title = currentTitle.text
--========================================================================== -- Local Utility Functions --==========================================================================
local function whichTOC( frame ) local pageCount = mw.site.stats.pagesInCategory(title, 'pages') if pageCount >= 5000 then return frame:expandTemplate{ title = 'CategoryTOC6' } elseif pageCount > 400 then return frame:expandTemplate{ title = 'CategoryTOC5' } end return end
local function redCatCheck( cat ) --cat == 'Blah', not 'Category:Blah', not '' if cat and cat ~= and mw.title.new(cat, 14).exists == false then return '' end return end
local function addCat( cat, id ) if id and id ~= then return ''..redCatCheck(cat) else return ''..redCatCheck(cat) end end
--========================================================================== -- Local Category-Specific Functions --==========================================================================
--For use in , -- i.e. on local function pages( frame, id ) for _, conf in pairs( ac_conf ) do if conf.category == id or string.lower(conf[1]) == string.lower(id) then local linktarget = conf.link or conf[1]..' (識別子)' local wdpl = ':d:Property:P'..conf[2] local txCatMore = frame:expandTemplate{ title = 'Cat more', args = {'Wikipedia:典拠管理', linktarget, wdpl} } local txWPCat = frame:expandTemplate{ title = 'Wikipedia category' } local pagesCat = '典拠管理情報があるページ' local outString = txCatMore..txWPCat..'\n'..addCat(pagesCat, id) return outString end end return end
--For use in , -- i.e. on local function misc( frame, id ) for _, conf in pairs( ac_conf ) do if conf.category == id or string.lower(conf[1]) == string.lower(id) then local linktarget = conf.link or conf[1]..' (識別子)' local link = ''..(conf.displayname or conf[1])..'' local wdpl = ':d:Property:P'..conf[2] local txCatExplain = frame:expandTemplate{ title = 'Category explanation', args = { '{{Normdaten}}を使って'..link..'を指定しているページのうちメインの利用者ページやウィキペディアの記事以外のページを収集しています。' } } local txCatMore = frame:expandTemplate{ title = 'Cat more', args = {'Wikipedia:典拠管理', wdpl} } local txWPCat = frame:expandTemplate{ title = 'Wikipedia category', args = { hidden = 'yes', tracking = 'yes' } } local txTOC = whichTOC( frame ) local idCat = id..'識別子が指定されているページ' local miscCat = '典拠管理情報があるその他のページ' local txNotice = frame:expandTemplate{ title = '告知', args = {'提案','このカテゴリの廃止',page='Template‐ノート:Normdaten',section='モジュールの更新提案 20221022',date='2022年10月'} } local outString = txCatExplain..txCatMore..txWPCat..txNotice..txTOC..'\n'.. 'このカテゴリにあるページはModule:Authority controlによって収集されています。'.. addCat(idCat)..addCat(miscCat, id) return outString end end return end
--For use in , -- i.e. on local function user( frame, id ) for _, conf in pairs( ac_conf ) do if conf.category == id or string.lower(conf[1]) == string.lower(id) then local linktarget = conf.link or conf[1]..' (識別子)' local wdpl = ':d:Property:P'..conf[2] local txCatMore = frame:expandTemplate{ title = 'Cat more', args = {'Wikipedia:典拠管理', linktarget, wdpl} } local txWPCat = frame:expandTemplate{ title = 'Wikipedia category', args = { hidden = 'yes', tracking = 'yes' } } local txTOC = whichTOC( frame ) local idCat = id..'識別子が指定されているページ' local userCat = '典拠管理情報がある利用者ページ' local txNotice = frame:expandTemplate{ title = '告知', args = {'提案','このカテゴリの廃止',page='Template‐ノート:Normdaten',section='モジュールの更新提案 20221022',date='2022年10月'} } local outString = txCatMore..txWPCat..txNotice..txTOC..'\n'.. 'このカテゴリにあるページはModule:Authority controlのみによって収集されています。'.. addCat(idCat)..addCat(userCat, id) return outString end end return end
--For use in , -- i.e. on local function wp( frame, id ) for _, conf in pairs( ac_conf ) do if conf.category == id or string.lower(conf[1]) == string.lower(id) then local linktarget = conf.link or conf[1]..' (識別子)' local link = ''..(conf.displayname or conf[1])..'' local wdpl = ':d:Property:P'..conf[2] local txCatExplain = frame:expandTemplate{ title = 'Category explanation', args = {..link..'識別子がある記事を収集しています。サブカテゴリは追加しないでください。'} } local txCatMore = frame:expandTemplate{ title = 'Cat more', args = {'Wikipedia:典拠管理', linktarget, wdpl} } local txEmptyCat = frame:expandTemplate{ title = 'Empty category' } local txWPCat = frame:expandTemplate{ title = 'Wikipedia category', args = { hidden = 'yes', tracking = 'yes' } } local txTOC = whichTOC( frame ) local idCat = id..'識別子が指定されているページ' local wpCat = '典拠管理情報がある記事' local outString = txCatExplain..txCatMore..txEmptyCat..txWPCat..'\n'..txTOC..'\n'.. 'このカテゴリにあるページはModule:Authority controlのみによって収集されています。'.. addCat(idCat)..addCat(wpCat, id) return outString end end return end
--For use in , -- i.e. on local function wpfaulty( frame, id ) for _, conf in pairs( ac_conf ) do if conf.category == id or string.lower(conf[1]) == string.lower(id) then local linktarget = conf.link or conf[1]..' (識別子)' local wdpl = ':d:Property:P'..conf[2] local txCatMore = frame:expandTemplate{ title = 'Cat more', args = {'Wikipedia:典拠管理', linktarget, wdpl} } local txEmptyCat = frame:expandTemplate{ title = 'Empty category' } local txWPCat = frame:expandTemplate{ title = 'Wikipedia category', args = { hidden = 'yes', tracking = 'yes' } } local txDirtyCat = frame:expandTemplate{ title = 'Polluted category' } local txTOC = whichTOC( frame ) local idCat = id..'識別子が指定されているページ' local wpfCat = '誤った典拠管理情報が指定されている記事' local outString = txCatMore..txEmptyCat..txWPCat..txDirtyCat..'\n'..txTOC..'\n'.. 'このカテゴリにあるページはModule:Authority controlのみによって収集されています。'.. ''..redCatCheck(idCat).. ''..redCatCheck(wpfCat) return outString end end return end
--========================================================================== -- Main/External Call --========================================================================== function p.autoDetect( frame ) if currentTitle.namespace == 14 then --cat space local pagesID = mw.ustring.match(title, '([%w%.%-・ ]+)識別子が指定されているページ') local miscID = mw.ustring.match(title, '([%w%.%-・ ]+)識別子が指定されているその他のページ') local userID = mw.ustring.match(title, '([%w%.%-・ ]+)識別子が指定されている利用者ページ') local wpfaultyID = mw.ustring.match(title, '誤った([%w%.%-・ ]+)識別子が指定されている記事') local wpID = mw.ustring.match(title, '([%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 '' end end return end
return p