Module:Protection banner and Module:Transclusion count/data/H: Difference between pages

From Frontierpedia, the Microsoft Agent encyclopedia
(Difference between pages)
en>Mr. Stradivarius
(use ipairs to make the attempt loop a little more efficient)
 
en>Ahechtbot
m (Bot: Updated page.)
 
Line 1: Line 1:
-- This module implements {{pp-meta}} and its daughter templates such as
return {
-- {{pp-dispute}}, {{pp-vandalism}} and {{pp-sock}}.
["H-phrases"] = 2200,
 
["H-phrases/text"] = 2200,
local categories = {
["HABS"] = 2100,
['edit-semi-user-all-all'] = 'Wikipedia semi-protected user and user talk pages',
["HDS"] = 4100,
['edit-semi-project-all-all'] = 'Semi-protected project pages',
["HD_color"] = 2800,
['edit-semi-file-all-all'] = 'Semi-protected images',
["HKG"] = 2800,
['edit-semi-template-all-all'] = 'Wikipedia semi-protected templates',
["HMAS"] = 6700,
['edit-semi-portal-all-all'] = 'Semi-protected portals',
["HMCS"] = 4400,
['edit-semi-talk-all-all'] = 'Semi-protected talk pages',
["HMM"] = 5000,
['edit-semi-all-vandalism-all'] = 'Wikipedia pages semi-protected against vandalism',
["HMNZS"] = 2100,
['edit-full-user-all-all'] = 'Wikipedia protected user and user talk pages',
["HMS"] = 33000,
['edit-full-file-all-all'] = 'Protected images',
["HOUR"] = 2300,
['edit-full-project-all-all'] = 'Protected project pages',
["HRV"] = 4200,
['edit-full-template-all-all'] = 'Wikipedia protected templates',
["HUN"] = 9700,
['edit-full-talk-all-all'] = 'Protected talk pages',
["Hab"] = 11000,
['edit-full-all-vandalism-all'] = 'Wikipedia pages protected against vandalism',
["Hair_space"] = 8400,
['edit-semi-all-dispute-all'] = 'Wikipedia pages semi-protected due to dispute',
["Hansard-contribs"] = 9300,
['edit-full-all-dispute-all'] = 'Wikipedia pages protected due to dispute',
["Harv"] = 5800,
['move-full-all-dispute-all'] = 'Wikipedia pages move-protected due to dispute',
["Harvard_citation"] = 6300,
['move-full-user-all-all'] = 'Wikipedia move-protected user and user talk pages',
["Harvard_citation_no_brackets"] = 39000,
['move-full-user-all-all'] = 'Wikipedia move-protected project pages',
["Harvard_citation_text"] = 5300,
['move-full-portal-all-all'] = 'Wikipedia move-protected portals',
["Harvid"] = 54000,
['edit-semi-template-all-all'] = 'Wikipedia semi-protected templates',
["Harvnb"] = 38000,
['move-full-template-all-all'] = 'Wikipedia move-protected templates',
["Harvp"] = 3100,
['edit-all-template-all-all'] = 'Wikipedia protected templates',
["Harvtxt"] = 5300,
['move-full-template-all-all'] = 'Wikipedia move-protected portals',
["Has_short_description"] = 195000,
['edit-semi-all-sock-all'] = 'Wikipedia pages semi-protected from banned users',
["Hat"] = 11000,
['edit-full-all-sock-all'] = 'Wikipedia pages protected from banned users',
["Hatnote"] = 421000,
['edit-semi-all-blp-temp'] = 'Wikipedia temporarily semi-protected biographies of living people',
["Hatnote_inline"] = 3200,
['edit-full-all-blp-temp'] = 'Wikipedia temporarily protected biographies of living people',
["Hatnote_inline/invoke"] = 3200,
['edit-semi-all-blp-indef'] = 'Wikipedia indefinitely semi-protected biographies of living people',
["Height"] = 105000,
['edit-full-all-blp-indef'] = 'Wikipedia indefinitely protected biographies of living people',
["Help_me-helped"] = 14000,
['edit-semi-all-all-indef'] = 'Wikipedia indefinitely semi-protected pages',
["Helpbox"] = 2500,
['move-full-talk-all-all'] = 'Wikipedia move-protected talk pages',
["Helpbox/styles.css"] = 2500,
['move-full-all-all-indef'] = 'Wikipedia indefinitely move-protected pages',
["Helpme-helped"] = 2100,
['edit-semi-all-all-all'] = 'Wikipedia semi-protected pages',
["Hidden"] = 348000,
['all-all-all-all-all'] = 'Wikipedia protected pages',
["Hidden/FC"] = 3700,
['edit-semi-category-all-all'] = 'Wikipedia semi-protected categories',
["Hidden_archive_bottom"] = 11000,
['edit-full-category-all-all'] = 'Wikipedia protected categories',
["Hidden_archive_top"] = 11000,
['move-full-all-all-all'] = 'Wikipedia move-protected pages',
["Hidden_begin"] = 383000,
['all-all-all-office-all'] = 'Wikipedia Office-protected pages',
["Hidden_category"] = 6200,
['pc-semi-all-all-all'] = 'Wikipedia pending changes protected pages (level 1)',
["Hidden_end"] = 383000,
['pc-reviewer-all-all-all'] = 'Wikipedia pending changes protected pages (level 2)',
["Hidden_ping"] = 3200,
["Hidden_sort_key"] = 16000,
["Hide_in_print"] = 61000,
["High-Class"] = 15000,
["High-importance"] = 15000,
["High-use"] = 3200,
["Highlight"] = 4800,
["Highlight/core"] = 4900,
["Hilite"] = 2800,
["Historical"] = 25000,
["Historical_populations"] = 35000,
["History_icon"] = 9300,
["History_icon2"] = 9300,
["Hlist"] = 179000,
["Hmbox"] = 22000,
["Hmmm"] = 5900,
["Hndis"] = 62000,
["HockeyDB"] = 3700,
["Hockeydb"] = 3600,
["Hong_Kong_English"] = 2900,
["Horizontal_TOC"] = 4700,
["Horizontal_TOC/styles.css"] = 4700,
["Horse_racing"] = 3300,
["HoursElapsed"] = 41000,
["Hours_elapsed"] = 41000,
["Hover_title"] = 54000,
["How_to_request_photo_in"] = 2200,
["Howtoreqphotoin"] = 2100,
["Hr"] = 4400,
["Hs"] = 16000,
["Hsp"] = 3400,
["Hugman"] = 6700,
["Human_name_disambiguation"] = 65000,
["Humor"] = 2400,
["Hurricane"] = 2600,
["Hurricane_season_bar"] = 2300,
["Hurricane_season_bar/button"] = 2300,
["Hurricane_season_bar/end"] = 2300,
["Hurricane_season_bar/start"] = 2300,
["Hurricane_status_small"] = 2300,
["Module:HTMLDecode"] = 598000,
["Module:Hatnote"] = 1530000,
["Module:Hatnote_inline"] = 3200,
["Module:Hatnote_list"] = 969000,
["Module:Hidden_ping"] = 3200,
["Module:High-use"] = 3600,
["Module:Highest_archive_number"] = 106000,
["Module:Historical_populations"] = 35000,
["Module:Hms"] = 226000,
}
}
local nskeys = {
[2] = 'user',
[3] = 'user',
[4] = 'project',
[6] = 'file',
[10] = 'template',
[12] = 'project',
[14] = 'category',
[100] = 'portal',
}
local error_categories = {
incorrect = 'Wikipedia pages with incorrect protection templates',
no_expiry = 'Wikipedia protected pages without expiry',
create = 'Wikipedia pages tagged as create-protected',
template = 'Wikipedia template-protected pages other than templates and modules'
}
local template_types = {
vandalism = {
namespaces = false, -- defaults to all namespaces
editLevels = false, -- all edit protection levels
moveLevels = false, -- all move protection levels
createLevels = false, -- all create protection levels
header = false,
reason = 'due to [[Wikipedia:Vandalism|vandalism]]',
icon_reason = 'due to vandalism',
}
}
--------------------------------------------------------------------------------
-- Main functions
--------------------------------------------------------------------------------
local getArgs = require('Module:Arguments').getArgs
local yesno = require('Module:Yesno')
local p = {}
function p.main(frame)
-- Get data
local args = getArgs(frame)
local title = p.getTitle(args.page)
local protType, protLevel = p.getProtectionStatus(title)
local namespace = p.getNamespace(title)
local expiry = p.getExpiry(args.expiry)
local reason = p.getReason(args.reason)
-- Sort categories and build a category link with the best match
categories = p.sortCategories(categories, protType, protLevel, namespace, expiry, reason)
local category = categories[1].name
category = string.format('[[Category:%s]]', category)
-- Find whether we are small or not and output a padlock or a banner as appropriate
local isSmall = yesno(args.small, true)
if isSmall then
return p.exportPadlock()
else
return p.exportBanner()
end
end
function p.parseNamespace(ns)
-- The ns variable is the namespace number.
if not ns or type(ns) ~= 'number' then
return 'all'
end
local nskey = nskeys[ns]
if not nskey and ns % 2 == 1 then
nskey = 'talk'
elseif not nskey then
nskey = 'all'
end
return nskey
end
function p.getCategoryName(cats, protType, protLevel, namespace, reason, expiry)
-- Preprocess parameters
cats = cats or categories
protType = protType or 'all'
protLevel = protLevel or 'all'
namespace = p.parseNamespace(namespace)
reason = reason or 'all'
if not expiry then
expiry = 'all'
elseif expiry ~= 'indef' then
expiry = 'temp'
end
-- Define the key table and the order to test it in.
-- This part is a little like playing regex golf - we have to make up a new
-- rule for every idiosyncracy that was in the old template system.
local keyTable = {protType, protLevel, namespace, reason, expiry}
local attemptOrder = {
--  type, level, ns, reason, expiry
{true, true, true, true, true},    -- 1
{true, true, true, true, false},    -- 2
{true, true, true, false, true},    -- 3
{true, true, false, true, true},    -- 4
{true, true, true, false, false},  -- 5
{true, true, false, true, false},  -- 6
{true, true, false, false, true},  -- 7
{true, true, false, false, false},  -- 8
{true, false, false, false, false}, -- 9
{false, false, false, false, false} -- 10
}
if reason ~= 'vandalism' then
attemptOrder[3], attemptOrder[4] = attemptOrder[4], attemptOrder[3]
attemptOrder[5], attemptOrder[6] = attemptOrder[6], attemptOrder[5]
end
-- Try successively generic matches until we run out of key combinations
for i, t in ipairs(attemptOrder) do
local key = {}
for j, useKeyTable in ipairs(t) do
if useKeyTable then
key[j] = keyTable[j]
else
key[j] = 'all'
end
end
key = table.concat(key, '-')
mw.log(key) -- for debugging
local attempt = cats[key]
if attempt then
return attempt
end
end
error('No category match found; please define the category for key "all-all-all-all-all"')
end
return p

Revision as of 05:11, 23 May 2021

Documentation for this module may be created at Module:Transclusion count/data/H/doc

return {
["H-phrases"] = 2200,
["H-phrases/text"] = 2200,
["HABS"] = 2100,
["HDS"] = 4100,
["HD_color"] = 2800,
["HKG"] = 2800,
["HMAS"] = 6700,
["HMCS"] = 4400,
["HMM"] = 5000,
["HMNZS"] = 2100,
["HMS"] = 33000,
["HOUR"] = 2300,
["HRV"] = 4200,
["HUN"] = 9700,
["Hab"] = 11000,
["Hair_space"] = 8400,
["Hansard-contribs"] = 9300,
["Harv"] = 5800,
["Harvard_citation"] = 6300,
["Harvard_citation_no_brackets"] = 39000,
["Harvard_citation_text"] = 5300,
["Harvid"] = 54000,
["Harvnb"] = 38000,
["Harvp"] = 3100,
["Harvtxt"] = 5300,
["Has_short_description"] = 195000,
["Hat"] = 11000,
["Hatnote"] = 421000,
["Hatnote_inline"] = 3200,
["Hatnote_inline/invoke"] = 3200,
["Height"] = 105000,
["Help_me-helped"] = 14000,
["Helpbox"] = 2500,
["Helpbox/styles.css"] = 2500,
["Helpme-helped"] = 2100,
["Hidden"] = 348000,
["Hidden/FC"] = 3700,
["Hidden_archive_bottom"] = 11000,
["Hidden_archive_top"] = 11000,
["Hidden_begin"] = 383000,
["Hidden_category"] = 6200,
["Hidden_end"] = 383000,
["Hidden_ping"] = 3200,
["Hidden_sort_key"] = 16000,
["Hide_in_print"] = 61000,
["High-Class"] = 15000,
["High-importance"] = 15000,
["High-use"] = 3200,
["Highlight"] = 4800,
["Highlight/core"] = 4900,
["Hilite"] = 2800,
["Historical"] = 25000,
["Historical_populations"] = 35000,
["History_icon"] = 9300,
["History_icon2"] = 9300,
["Hlist"] = 179000,
["Hmbox"] = 22000,
["Hmmm"] = 5900,
["Hndis"] = 62000,
["HockeyDB"] = 3700,
["Hockeydb"] = 3600,
["Hong_Kong_English"] = 2900,
["Horizontal_TOC"] = 4700,
["Horizontal_TOC/styles.css"] = 4700,
["Horse_racing"] = 3300,
["HoursElapsed"] = 41000,
["Hours_elapsed"] = 41000,
["Hover_title"] = 54000,
["How_to_request_photo_in"] = 2200,
["Howtoreqphotoin"] = 2100,
["Hr"] = 4400,
["Hs"] = 16000,
["Hsp"] = 3400,
["Hugman"] = 6700,
["Human_name_disambiguation"] = 65000,
["Humor"] = 2400,
["Hurricane"] = 2600,
["Hurricane_season_bar"] = 2300,
["Hurricane_season_bar/button"] = 2300,
["Hurricane_season_bar/end"] = 2300,
["Hurricane_season_bar/start"] = 2300,
["Hurricane_status_small"] = 2300,
["Module:HTMLDecode"] = 598000,
["Module:Hatnote"] = 1530000,
["Module:Hatnote_inline"] = 3200,
["Module:Hatnote_list"] = 969000,
["Module:Hidden_ping"] = 3200,
["Module:High-use"] = 3600,
["Module:Highest_archive_number"] = 106000,
["Module:Historical_populations"] = 35000,
["Module:Hms"] = 226000,
}