Module:User:Zackmann08/unknown links
Appearance
-- Module to display a list of unknown articles
local templates = {
-- Pushpin maps
'LDS Temple',
'New York City Subway station',
'frazione',
'government agency',
-- 'language',
-- 'heat event',
'oil field',
'space agency',
'railway depot',
-- 'station',
'sports rivalry',
-- 'political division',
-- 'tram network',
'public transit accident',
-- 'United States presidential transition',
'retail market',
'river',
'UK place',
'Turkey place',
'street',
'Greece place',
'power station',
'mine',
'Site of Special Scientific Interest',
'golf tournament',
'earthquake',
'waterfall',
'mountain pass',
'individual golf tournament',
'diplomatic mission',
'amusement park',
'Israel village',
'WorldScouting',
'port',
'valley',
'wildfire',
'golf facility',
'cave',
'ski area',
'military operation',
'canal',
'cycling championship',
'observatory',
'urban feature',
'Scottish island',
'residential college',
'First Nation',
'spring',
'Tibetan Buddhist monastery',
'castrum',
'Egyptian tomb',
'UK postcode area',
'seamount',
'concentration camp',
'European Parliament constituency',
'team golf tournament',
'tree',
'terrestrial impact site',
'pier',
'oil refinery',
'fault',
'mill building',
'aerial lift line',
'campground',
'property development',
'Holocaust event',
'farm',
'motorway services',
'superfund',
'business park',
'pyramid',
'climbing route',
'Spanish missions in the Americas',
'sedimentary basin',
'ski course',
'climbing area',
'reactor',
'dive site',
'mining',
'marae',
-- Others
'academic',
'aircraft occurrence',
'aircraft',
'airport',
'alpine ski racer',
'animanga',
'architect',
'art historian',
'artist',
'artwork',
'astronaut',
'aviator',
'badminton player',
'basketball league season',
'Belgium municipality',
'biathlete',
'body of water',
'book',
'boxer',
'boxer (amateur)',
'brewery',
'bridge type',
'bridge',
'Buddhist temple',
'building',
'bus company',
'casino',
'cemetery',
'cheese',
'chef',
'Christian leader',
'church',
'civilian attack',
'classical composer',
'clergy',
'comedian',
'company',
'computing device',
'country',
'cricket ground',
'criminal organization',
'criminal',
'cycling race report',
'dam',
'dancer',
'desalination plant',
'distillery',
'dog breed',
'drink',
'economist',
'economy',
'election',
'engineer',
'event',
'F1 driver',
'factory',
'family',
'FIBA tourney',
'field hockey player',
'figure skater',
'fishery',
'food',
'forest',
'French commune',
'Gaelic games biography',
'game',
'glacier',
'government cabinet',
'gridiron football team season',
'gymnast',
'Hindu temple',
'historic site',
'hospital',
'housing project',
'hromada',
'ice hockey biography',
'institute',
'islands',
'Italian comune',
'laboratory',
'landform',
'legislative election',
'legislature',
'library',
'lighthouse',
'medical person',
'military conflict',
'military installation',
'military person',
'militant organization',
'model',
'monastery',
'monument',
'motorcycle',
'mountain',
'museum',
'musical artist',
'name',
'newspaper',
'NRHP',
'noble',
'officeholder',
'official post',
'organization',
'pageant titleholder',
'park',
'person',
'philosopher',
'pirate',
'play',
'poker player',
'police officer',
'presenter',
'prison',
'protected area',
'racing driver',
'recurring event',
'religious biography',
'religious building',
'restaurant',
'room',
'royalty',
'school',
'scientist',
'settlement',
'shopping mall',
'skier',
'social media personality',
'solar eclipse',
'sports announcer',
'sports league',
'sports season',
'sports team',
'sportsperson',
'spy',
'surfer',
'swimmer',
'Switzerland municipality',
'telescope',
'theologian',
'transmitter',
'tunnel',
'university',
'urban development project',
'venue',
'weather event',
'zoo'
}
require('strict')
local p = {}
function p.getText(text)
text = text:gsub("^%l", string.upper)
text = text:gsub("^(%w+%s+%w*).*", "%1")
return text
end
function p.getList(frame, templates)
local text = {}
for index = 1, #templates do
local title = 'Pages using infobox '..templates[index]..' with unknown parameters'
if not mw.title.new('Category:'..title).exists then
table.insert(text, frame:expandTemplate{
title='Error',
args = {'[[:Category:'..title .. ']] is not a valid category'}
})
end
if p.getSoloCount(frame, templates[index])>0 then
table.insert(text, frame:expandTemplate{
title='User:Zackmann08/cc',
args = {'Pages using infobox '..templates[index]..' with unknown parameters', p.getText(templates[index])}
})
end
end
return text
end
function p.getSoloCount(frame, template)
return tonumber(frame:expandTemplate{
title='cconly',
args = {'Pages using infobox '..template..' with unknown parameters'}
})
end
function p.getCount(frame, templates)
local count = 0
for index = 1, #templates do
count = count + p.getSoloCount(frame, templates[index])
end
return count
end
-- Main function
function p.conflicting(frame)
local offset = frame.args[1] or 0
local title = 'User:Zackmann08/conflicting.json'
local data = mw.text.jsonDecode(mw.title.new(title):getContent())
local array = data["*"][1]["a"]["*"]
local text = ''
local list = {}
for i = 1+offset, math.min(1000+offset, #array) do
local title = mw.ustring.gsub(array[i]["title"], '_', ' ')
local count = mw.site.stats.pagesInCategory(title, 'pages')
if count > 100 then
table.insert(list, '[[:Category:'..title..']] ('..count..')')
end
end
text = 'Using [https://petscan.wmcloud.org/?psid=44764551 this query] on [[User:Zackmann08/conflicting.json]]<br>'
text = text..'There are currently a total of '..table.getn(array)..' conflicting categories!<br>'
text = text..'This page is displaying '..table.getn(list)..' of them.<br>'
text = text..'Modify this template at [[Module:User:Zackmann08/unknown links]]<br>'
return text..frame:expandTemplate{
title='blist',
args = list
}
end
function p.unknowns(frame)
local offset = frame.args[1] or 0
local title = 'User:Zackmann08/unknowns.json'
local data = mw.text.jsonDecode(mw.title.new(title):getContent())
local array = data["*"][1]["a"]["*"]
local text = ''
local list = {}
for i = 1+offset, math.min(500+offset, #array) do
local title = mw.ustring.gsub(array[i]["title"], '_', ' ')
local count = mw.site.stats.pagesInCategory(title, 'pages')
if count > 50 then
table.insert(list, '[[:Category:'..title..']] ('..count..')')
end
end
text = 'Using [https://petscan.wmcloud.org/?psid=39322871 this query] on [[User:Zackmann08/unknowns.json]]<br>'
text = text..'There are currently a total of '..table.getn(array)..' unknown categories!<br>'
text = text..'This page is displaying '..table.getn(list)..' of them.<br>'
text = text..'Modify this template at [[Module:User:Zackmann08/unknown links]]<br>'
return text..frame:expandTemplate{
title='blist',
args = list
}
end
function p.main(frame)
table.sort(templates)
local text = ''
local count = p.getCount(frame, templates)
local list = p.getList(frame, templates)
text = text .. frame:expandTemplate{
title='blist',
args = list
}
return text
end
return p