Module:User:Zackmann08/unknown links
Appearance
-- Module to display a list of unknown articles
local templates = {
'academic',
'aerial lift line',
'aircraft',
'aircraft occurrence',
'airport',
'alpine ski racer',
'amusement park',
'animanga',
'animal',
'architect',
'artist',
'artwork',
'astronaut',
'aviator',
'badminton player',
'basketball league season',
'Belgium municipality',
'biathlete',
'body of water',
'book',
'boxer',
'boxer (amateur)',
'brewery',
'bridge',
'bridge type',
'Buddhist temple',
'building',
'bus company',
'business park',
'campground',
'canal',
'casino',
'cave',
'cemetery',
'cheese',
'chef',
'Christian leader',
'church',
'civil conflict',
'civilian attack',
'classical composer',
'clergy',
'climbing area',
'climbing route',
'comedian',
'company',
'computing device',
'concentration camp',
'country',
'cricket ground',
'criminal',
'criminal organization',
'cycling championship',
'cycling race report',
'dam',
'dancer',
'desalination plant',
'diplomatic mission',
'distillery',
'dive site',
'dog breed',
'drink',
'earthquake',
'economist',
'economy',
'election',
'engineer',
'European Parliament constituency',
'event',
'F1 driver',
'factory',
'family',
'farm',
'fault',
'FIBA tourney',
'field hockey player',
'figure skater',
'fishery',
'food',
'forest',
'French commune',
'Gaelic games biography',
'game',
'German place',
'glacier',
'golf facility',
'golf tournament',
'government agency',
'government cabinet',
'gridiron football team season',
'gymnast',
'Hindu temple',
'historic site',
'Holocaust event',
'hospital',
'housing project',
'hromada',
'ice hockey biography',
'institute',
'islands',
'Italian comune',
'kommune',
'laboratory',
'landform',
'language',
'LDS Temple',
'legislative election',
'legislature',
'library',
'lighthouse',
'marae',
'martial artist',
'medical person',
'militant organization',
'military conflict',
'military installation',
'military operation',
'military person',
'mill building',
'mining',
'model',
'monastery',
'monument',
'motorcycle',
'motorsport season',
'motorway services',
'mountain',
'mountain pass',
'museum',
'musical artist',
'name',
'newspaper',
'noble',
'NRHP',
'observatory',
'officeholder',
'official post',
'oil refinery',
'organization',
'pageant titleholder',
'park',
'person',
'person/Wikidata',
'philosopher',
'pier',
'pirate',
'play',
'poker player',
'police officer',
'political division',
'port',
'presenter',
'prison',
'property development',
'protected area',
'pyramid',
'racing driver',
'reactor',
'recurring event',
'religious biography',
'religious building',
'residential college',
'restaurant',
'retail market',
'river',
'room',
'royalty',
'school',
'scientist',
'Scottish island',
'seamount',
'sedimentary basin',
'settlement',
'shopping mall',
'ski area',
'ski course',
'skier',
'social media personality',
'solar eclipse',
'space agency',
'sports announcer',
'sports league',
'sports season',
'sports team',
'sportsperson',
'spring',
'spy',
'station',
'street',
'superfund',
'surfer',
'swimmer',
'Switzerland municipality',
'team golf tournament',
'telescope',
'terrestrial impact site',
'theologian',
'Tibetan Buddhist monastery',
'trail',
'transmitter',
'tree',
'tunnel',
'U.S. county',
'university',
'urban development project',
'urban feature',
'valley',
'venue',
'waterfall',
'weather event',
'website',
'wildfire',
'writer',
'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