FANDOM


p = {}
 
local function makeCategoryLink(cat)
	return string.format('[[Category:%s]]', cat)
end
 
function p.main(frame)
	local title = mw.title.getCurrentTitle()
	if title.namespace ~= 6 then
		return ''
	end
	local ret = {''}
	local filename = title.text
	local filename2 = mw.ustring.lower(filename)
	if mw.ustring.match(filename2, '%.png%.png$') or mw.ustring.match(filename2, '%.jpg%.jpg$') then
		ret[#ret + 1] = makeCategoryLink('Images with double extensions in filename')
	end
	if mw.ustring.match(filename2, '%.jpeg$') then
		ret[#ret + 1] = makeCategoryLink('Images with extended extensions in filename')
	end
	if mw.ustring.match(filename, '%.JPG$') or mw.ustring.match(filename, '%.PNG$') then
		ret[#ret + 1] = makeCategoryLink('Images with capitalized extensions in filename')
	end
	if mw.ustring.match(filename2, 'image') or mw.ustring.match(filename2, 'screenshot') then
		ret[#ret + 1] = makeCategoryLink('Images with generic strings in filename')
	elseif mw.ustring.match(filename2, 'file') and not (
		mw.ustring.match(filename2, 'profile') or
		mw.ustring.match(filename2, 'fact ?file')
	) then
		ret[#ret + 1] = makeCategoryLink('Images with generic strings in filename')
	end
	if mw.ustring.match(filename, "[%/%?%&%,%+%!%(%)’”]") then
		ret[#ret + 1] = makeCategoryLink('Images with annoying characters in filename')
	elseif mw.ustring.match(filename, "[%']") then
		ret[#ret + 1] = makeCategoryLink('Images with apostrophes in filename')
	else
		for code in mw.ustring.gcodepoint(filename) do
			if code < 32 or code > 122 then
				ret[#ret + 1] = makeCategoryLink('Images with annoying characters in filename')
				break
			end
		end
	end
	return table.concat(ret)
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.