Module:CategoryAudit: Difference between revisions
Create module to find brands/types missing category pages (via create-page on MediaWiki MCP Server) |
Fix category links (add colon prefix) and use Lua URL builder instead of unprocessed wikitext (via update-page on MediaWiki MCP Server) |
||
| Line 13: | Line 13: | ||
end | end | ||
local function | -- Helper to build a "create category" URL | ||
local function createCategoryUrl(categoryTitle, preloadTemplate, brandOrType) | |||
return tostring(mw.uri.fullUrl(categoryTitle, { | |||
action = 'edit', | |||
preload = preloadTemplate, | |||
['preloadparams[]'] = brandOrType | |||
})) | |||
end | end | ||
| Line 54: | Line 45: | ||
local result = frame:preprocess(queryWikitext) | local result = frame:preprocess(queryWikitext) | ||
if result then | if result then | ||
| Line 118: | Line 107: | ||
for _, brand in ipairs(missing) do | for _, brand in ipairs(missing) do | ||
local count = frame:preprocess('{{#ask:[[Category:CRT models]][[Has brand::' .. brand .. ']]|format=count}}') | local count = frame:preprocess('{{#ask:[[Category:CRT models]][[Has brand::' .. brand .. ']]|format=count}}') | ||
local categoryTitle = 'Category:' .. brand .. ' CRTs' | |||
local createUrl = createCategoryUrl(categoryTitle, 'Template:CRT brand category/preload', brand) | |||
-- Use [[:Category:...]] with colon to make it a LINK not a category assignment | |||
table.insert(output, '* <strong>' .. brand .. '</strong> — ' .. count .. ' CRTs need [[:' .. categoryTitle .. ']] — [' .. createUrl .. ' create it]') | |||
end | end | ||
| Line 207: | Line 199: | ||
for _, crtType in ipairs(missing) do | for _, crtType in ipairs(missing) do | ||
local count = frame:preprocess('{{#ask:[[Category:CRT models]][[Has CRT type::' .. crtType .. ']]|format=count}}') | local count = frame:preprocess('{{#ask:[[Category:CRT models]][[Has CRT type::' .. crtType .. ']]|format=count}}') | ||
table.insert(output, '* | local categoryTitle = 'Category:' .. crtType | ||
local createUrl = createCategoryUrl(categoryTitle, 'Template:CRT type category/preload', crtType) | |||
table.insert(output, '* <strong>' .. crtType .. '</strong> — ' .. count .. ' CRTs need [[:' .. categoryTitle .. ']] — [' .. createUrl .. ' create it]') | |||
end | end | ||
| Line 296: | Line 290: | ||
for _, brand in ipairs(missing) do | for _, brand in ipairs(missing) do | ||
local count = frame:preprocess('{{#ask:[[Category:AV devices]][[Has brand::' .. brand .. ']]|format=count}}') | local count = frame:preprocess('{{#ask:[[Category:AV devices]][[Has brand::' .. brand .. ']]|format=count}}') | ||
table.insert(output, '* | local categoryTitle = 'Category:' .. brand .. ' AV devices' | ||
local createUrl = createCategoryUrl(categoryTitle, 'Template:AV brand category/preload', brand) | |||
table.insert(output, '* <strong>' .. brand .. '</strong> — ' .. count .. ' devices need [[:' .. categoryTitle .. ']] — [' .. createUrl .. ' create it]') | |||
end | end | ||
| Line 385: | Line 381: | ||
for _, deviceType in ipairs(missing) do | for _, deviceType in ipairs(missing) do | ||
local count = frame:preprocess('{{#ask:[[Category:AV devices]][[Has device type::' .. deviceType .. ']]|format=count}}') | local count = frame:preprocess('{{#ask:[[Category:AV devices]][[Has device type::' .. deviceType .. ']]|format=count}}') | ||
table.insert(output, '* | local categoryTitle = 'Category:' .. deviceType .. 's' | ||
local createUrl = createCategoryUrl(categoryTitle, 'Template:AV device type category/preload', deviceType) | |||
table.insert(output, '* <strong>' .. deviceType .. '</strong> — ' .. count .. ' devices need [[:' .. categoryTitle .. ']] — [' .. createUrl .. ' create it]') | |||
end | end | ||