Module:Sprite: Difference between revisions

m Protected "Module:Sprite": High traffic page ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))
Remove deprecated position handling, now treated as a normal ID. Remove cats on user and talk pages.
Line 125: Line 125:
local categories = {}
local categories = {}
if tonumber( args[1] ) then
local idData = args.iddata
args.pos = args[1]
if not idData then
table.insert( categories, '[[Category:Pages using sprite positions]]' )
local default = {}
else
if args.settings then
local idData = args.iddata
default = mw.loadData( 'Module:' .. args.settings )
if not idData then
local default = {}
if args.settings then
default = mw.loadData( 'Module:' .. args.settings )
end
local name = args.name or default.name
local ids = mw.loadData( 'Module:' .. ( args.ids or default.ids or name .. '/IDs' ) )
ids = ids.ids or ids
local id = mw.text.trim( args[1] or '' )
idData = ids[id] or ids[mw.ustring.lower( id ):gsub( '[%s%+]', '-' )]
end
end
local allowCats = not mw.title.getCurrentTitle().isSubpage
local name = args.name or default.name
if idData then
local ids = mw.loadData( 'Module:' .. ( args.ids or default.ids or name .. '/IDs' ) )
if type( idData ) == 'table' then
ids = ids.ids or ids
if idData.deprecated and allowCats then
local id = mw.text.trim( tostring( args[1] or '' ) )
table.insert( categories, '[[Category:Pages using deprecated sprite names]]' )
idData = ids[id] or ids[mw.ustring.lower( id ):gsub( '[%s%+]', '-' )]
end
end
args.pos = idData.pos
local title = mw.title.getCurrentTitle()
else
-- Remove categories on sub-pages, and User* and *Talk namespaces
args.pos = idData
local allowCats = not title.isSubpage and ( not title.nsText:find( '^User' ) or not title.nsText:find( '[Tt]alk$' ) )
if idData then
if type( idData ) == 'table' then
if idData.deprecated and allowCats then
table.insert( categories, '[[Category:Pages using deprecated sprite names]]' )
end
end
elseif allowCats then
table.insert( categories, '[[Category:Pages with missing sprites]]' )
args.pos = idData.pos
else
args.pos = idData
end
end
elseif allowCats then
table.insert( categories, '[[Category:Pages with missing sprites]]' )
end
end