Модуль:Случайная картинка: различия между версиями
Pok (обсуждение | вклад) Новая страница: «local p = {} local getArgs = require('Module:Arguments').getArgs function p.main(frame) local args = getArgs(frame, { removeBlanks = false }) local name = args[1] or "" local attributes = args[2] or "" if name == "" then return "<span class=\"error\">Ошибка: не указано имя файла.</span>" end local ext = (args["ext"] or "png"):gsub("^%.", "") local max = tonumber(args["max"]) or 50 local include_...» |
Pok (обсуждение | вклад) Нет описания правки |
||
| Строка 9: | Строка 9: | ||
return "<span class=\"error\">Ошибка: не указано имя файла.</span>" | return "<span class=\"error\">Ошибка: не указано имя файла.</span>" | ||
end | end | ||
local max = tonumber(args["max"]) or 50 | local max = tonumber(args["max"]) or 50 | ||
local include_base = (args["base"] ~= "no") | local include_base = (args["base"] ~= "no") | ||
| Строка 16: | Строка 15: | ||
if include_base then | if include_base then | ||
local t = mw.title.new("Файл:" .. name | local t = mw.title.new("Файл:" .. name) | ||
if t and t.exists then | if t and t.exists then | ||
table.insert(found, "") | table.insert(found, "") | ||
| Строка 23: | Строка 22: | ||
for i = 1, max do | for i = 1, max do | ||
local t = mw.title.new("Файл:" .. name .. "-" .. i | local t = mw.title.new("Файл:" .. name .. "-" .. i) | ||
if t and t.exists then | if t and t.exists then | ||
table.insert(found, "-" .. i) | table.insert(found, "-" .. i) | ||
| Строка 34: | Строка 33: | ||
local before = "[[Файл:" .. name | local before = "[[Файл:" .. name | ||
local after = | local after = "|" .. attributes .. "]]" | ||
local parts = {} | local parts = {} | ||