Модуль:Песочница/Pok

Версия от 21:00, 8 апреля 2025; Pok (обсуждение | вклад) (Содержимое страницы заменено на «local p = {} local frame = mw.getCurrentFrame() function p.listUncategorizedGIFs() local uncategorized = {} local allFiles = mw.site.allPages('', 'File') for title in allFiles do local filename = title.text if filename:match("%.gif$") then local file = mw.title.new('File:' .. filename) if file then local content = file:getContent() if content and not content:match('%[%[Category:') then table.insert(...»)

Для документации этого модуля может быть создана страница Модуль:Песочница/Pok/doc

local p = {}
local frame = mw.getCurrentFrame()

function p.listUncategorizedGIFs()
	local uncategorized = {}
	local allFiles = mw.site.allPages('', 'File') 

	for title in allFiles do
		local filename = title.text
		if filename:match("%.gif$") then
			local file = mw.title.new('File:' .. filename)
			if file then
				local content = file:getContent()
				if content and not content:match('%[%[Category:') then
					table.insert(uncategorized, '* [[:File:' .. filename .. ']]')
				end
			end
		end
	end

	if #uncategorized == 0 then
		return 'Все gif-файлы категоризированы.'
	end

	return table.concat(uncategorized, '\n')
end

return p