local p = {}
function p.main(frame)
title = mw.title.getCurrentTitle();
mw.log(title.subjectNsText)
mw.log(title.text)
if not getArgs then
getArgs = require('Module:Arguments').getArgs
end
local args = getArgs(frame)
text = args['text']
args['text']=nil
local cats = {}
for k, v in pairs(args) do
if type(k) == 'number' then -- неименованные параметры
table.insert( cats, v )
args[k]=nil
end
end
if args['noself'] == nil and title.subjectNsText == "Категория" then
table.insert(cats,title.text)
end
args['noself'] = nil
args['categories']=table.concat( cats, "\n" )
query = '&' .. (args['query'] or '')
args['query'] = nil
url = 'https://petscan.wmflabs.org/?language=ru&project=wikipedia&interface_language=ru&active_tab=&doit=&depth=-1&sortby=title&'
url = url .. mw.uri.buildQueryString(args) .. query
if text==nil
then return url
else return '[' .. url .. ' ' .. text .. ']'
end
end
return p