en>Mr. Stradivarius |
en>Ahechtbot |
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, |
| -- The key strings follow this format:
| | ["HDS"] = 4100, |
| -- type, level, ns, reason, expiry
| | ["HD_color"] = 2800, |
| ['edit-autoconfirmed-user-all-all'] = 'Wikipedia semi-protected user and user talk pages',
| | ["HKG"] = 2800, |
| ['edit-autoconfirmed-project-all-all'] = 'Semi-protected project pages',
| | ["HMAS"] = 6700, |
| ['edit-autoconfirmed-file-all-all'] = 'Semi-protected images',
| | ["HMCS"] = 4400, |
| ['edit-autoconfirmed-template-all-all'] = 'Wikipedia semi-protected templates',
| | ["HMM"] = 5000, |
| ['edit-autoconfirmed-portal-all-all'] = 'Semi-protected portals',
| | ["HMNZS"] = 2100, |
| ['edit-autoconfirmed-talk-all-all'] = 'Semi-protected talk pages',
| | ["HMS"] = 33000, |
| ['edit-autoconfirmed-all-vandalism-all'] = 'Wikipedia pages semi-protected against vandalism',
| | ["HOUR"] = 2300, |
| ['edit-sysop-user-all-all'] = 'Wikipedia protected user and user talk pages',
| | ["HRV"] = 4200, |
| ['edit-sysop-file-all-all'] = 'Protected images',
| | ["HUN"] = 9700, |
| ['edit-sysop-project-all-all'] = 'Protected project pages',
| | ["Hab"] = 11000, |
| ['edit-sysop-template-all-all'] = 'Wikipedia protected templates',
| | ["Hair_space"] = 8400, |
| ['edit-sysop-talk-all-all'] = 'Protected talk pages',
| | ["Hansard-contribs"] = 9300, |
| ['edit-sysop-all-vandalism-all'] = 'Wikipedia pages protected against vandalism',
| | ["Harv"] = 5800, |
| ['edit-autoconfirmed-all-dispute-all'] = 'Wikipedia pages semi-protected due to dispute',
| | ["Harvard_citation"] = 6300, |
| ['edit-sysop-all-dispute-all'] = 'Wikipedia pages protected due to dispute',
| | ["Harvard_citation_no_brackets"] = 39000, |
| ['move-sysop-all-dispute-all'] = 'Wikipedia pages move-protected due to dispute',
| | ["Harvard_citation_text"] = 5300, |
| ['move-sysop-user-all-all'] = 'Wikipedia move-protected user and user talk pages',
| | ["Harvid"] = 54000, |
| ['move-sysop-project-all-all'] = 'Wikipedia move-protected project pages',
| | ["Harvnb"] = 38000, |
| ['move-sysop-portal-all-all'] = 'Wikipedia move-protected portals',
| | ["Harvp"] = 3100, |
| ['move-sysop-all-vandalism-all'] = 'Wikipedia pages move-protected due to vandalism',
| | ["Harvtxt"] = 5300, |
| ['edit-autoconfirmed-template-all-all'] = 'Wikipedia semi-protected templates',
| | ["Has_short_description"] = 195000, |
| ['move-sysop-template-all-all'] = 'Wikipedia move-protected templates',
| | ["Hat"] = 11000, |
| ['edit-all-template-all-all'] = 'Wikipedia protected templates',
| | ["Hatnote"] = 421000, |
| ['move-sysop-portal-all-all'] = 'Wikipedia move-protected portals',
| | ["Hatnote_inline"] = 3200, |
| ['edit-autoconfirmed-all-sock-all'] = 'Wikipedia pages semi-protected from banned users',
| | ["Hatnote_inline/invoke"] = 3200, |
| ['edit-sysop-all-sock-all'] = 'Wikipedia pages protected from banned users',
| | ["Height"] = 105000, |
| ['edit-autoconfirmed-all-blp-temp'] = 'Wikipedia temporarily semi-protected biographies of living people',
| | ["Help_me-helped"] = 14000, |
| ['edit-sysop-all-blp-temp'] = 'Wikipedia temporarily protected biographies of living people',
| | ["Helpbox"] = 2500, |
| ['edit-autoconfirmed-all-blp-all'] = 'Wikipedia indefinitely semi-protected biographies of living people',
| | ["Helpbox/styles.css"] = 2500, |
| ['edit-sysop-all-blp-all'] = 'Wikipedia indefinitely protected biographies of living people',
| | ["Helpme-helped"] = 2100, |
| ['edit-autoconfirmed-all-all-indef'] = 'Wikipedia indefinitely semi-protected pages',
| | ["Hidden"] = 348000, |
| ['edit-autoconfirmed-category-all-all'] = 'Wikipedia semi-protected categories',
| | ["Hidden/FC"] = 3700, |
| ['edit-sysop-category-all-all'] = 'Wikipedia protected categories',
| | ["Hidden_archive_bottom"] = 11000, |
| ['move-sysop-talk-all-all'] = 'Wikipedia move-protected talk pages',
| | ["Hidden_archive_top"] = 11000, |
| ['move-sysop-all-all-indef'] = 'Wikipedia indefinitely move-protected pages',
| | ["Hidden_begin"] = 383000, |
| ['edit-autoconfirmed-all-all-all'] = 'Wikipedia semi-protected pages',
| | ["Hidden_category"] = 6200, |
| ['move-sysop-all-all-all'] = 'Wikipedia move-protected pages',
| | ["Hidden_end"] = 383000, |
| ['pc-autoconfirmed-all-all-all'] = 'Wikipedia pending changes protected pages (level 1)',
| | ["Hidden_ping"] = 3200, |
| ['pc-reviewer-all-all-all'] = 'Wikipedia pending changes protected pages (level 2)',
| | ["Hidden_sort_key"] = 16000, |
| ['all-all-all-office-all'] = 'Wikipedia Office-protected pages',
| | ["Hide_in_print"] = 61000, |
| ['all-all-all-all-all'] = 'Wikipedia protected pages',
| | ["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 behaviors = {
| |
| vandalism = 'namespaceFirst',
| |
| dispute = 'reasonFirst',
| |
| blp = 'reasonFirst',
| |
| sock = 'reasonFirst',
| |
| office = 'reasonFirst',
| |
| }
| |
|
| |
| --[[
| |
| -- Not currently used
| |
| 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'
| |
| }
| |
| --]]
| |
|
| |
| --------------------------------------------------------------------------------
| |
| -- Main functions
| |
| --------------------------------------------------------------------------------
| |
|
| |
| -- Define often-used functions as local variables.
| |
| local tconcat = table.concat
| |
| local tinsert = table.insert
| |
| local floor = math.floor
| |
|
| |
| local p = {}
| |
|
| |
| function p.matchNamespace(ns)
| |
| -- Matches a namespace number to a string that can be passed to the
| |
| -- namespace parameter of p.getCategoryName.
| |
| if not ns or type(ns) ~= 'number' then
| |
| return 'all'
| |
| end
| |
| local nskey = nskeys[ns]
| |
| if not nskey then
| |
| if ns % 2 == 1 then
| |
| nskey = 'talk'
| |
| else
| |
| nskey = 'all'
| |
| end
| |
| end
| |
| return nskey
| |
| end
| |
|
| |
| function p.getCategoryName(cats, protType, protLevel, namespace, reason, expiry)
| |
| -- Gets a category name from the category table, given a combination of
| |
| -- the protection type, the protection level, the namespace number, the
| |
| -- reason for protection, and the expiry date.
| |
|
| |
| -- Preprocess parameters
| |
| cats = cats or categories
| |
| local properties = {}
| |
| properties.protType = protType or 'all'
| |
| properties.protLevel = protLevel or 'all'
| |
| properties.namespace = p.matchNamespace(namespace)
| |
| properties.reason = reason or 'all'
| |
| if not expiry then
| |
| properties.expiry = 'all'
| |
| elseif expiry ~= 'indef' then
| |
| properties.expiry = 'temp'
| |
| end
| |
|
| |
| local order = {'expiry', 'namespace', 'protLevel', 'protType', 'reason'}
| |
| local behavior = behaviors[reason]
| |
| if behavior == 'namespaceFirst' then
| |
| tinsert(order, table.remove(order, 2)) -- move namespace to the end
| |
| elseif behavior ~= 'reasonFirst' and reason ~= 'all' then
| |
| error(reason .. ' is not a valid reason')
| |
| end
| |
|
| |
| local activePropertyKeys = {}
| |
| for i, propertyKey in ipairs(order) do
| |
| if properties[propertyKey] ~= 'all' then
| |
| activePropertyKeys[#activePropertyKeys + 1] = propertyKey
| |
| end
| |
| end
| |
| local noActiveProperties = #activePropertyKeys
| |
|
| |
| -- Try successively generic matches until we run out of key combinations
| |
| for i = 1, 2^noActiveProperties do
| |
| local categoryKey = {}
| |
| for pos = 1, 5 do
| |
| if pos > noActiveProperties then
| |
| categoryKey[pos] = 'all'
| |
| else
| |
| local quotient = i / 2 ^ (pos - 1)
| |
| quotient = floor(quotient)
| |
| if quotient % 2 == 1 then
| |
| categoryKey[pos] = properties[activePropertyKeys[pos]]
| |
| else -- quotient % 2 == 0
| |
| categoryKey[pos] = 'all'
| |
| end
| |
| end
| |
| end
| |
| categoryKey = tconcat(categoryKey, '-')
| |
| mw.log(categoryKey) -- for debugging
| |
| local attempt = cats[categoryKey]
| |
| 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
| |
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,
}