local MessageBox = require('Module:Message box')local Gadgets = require('Module:Gadgets')local Arguments = require('Module:Arguments')local TableTools = require('Module:TableTools')
local p =
p.main = function(frame) local args = Arguments.getArgs(frame) return p.core(args.page or mw.title.getCurrentTitle.fullText)end
p.core = function(page) local len = page:len if len < 5 then -- Too short page name, do nothing return end if page:sub(-4)
'.js' then local basepage = page:sub(0, -4) local sisterpage = basepage..'.css' return p.makeMessage('js', mw.title.new(basepage), mw.title.new(sisterpage), 'css') end if page:sub(-5)
local skins =
p.gadget_text = function(name, repo) local lang = mw.getContentLanguage local options = repo[name].options local dependents = if options.hidden ~= nil then -- Find dependents for n, conf in pairs(repo) do local deps = conf.options.dependencies and TableTools.listToSet(mw.text.split(conf.options.dependencies, ',', false)) or local peers = conf.options.peers and TableTools.listToSet(mw.text.split(conf.options.peers, ',', false)) or if deps['ext.gadget.'..name] ~= nil or peers[name] ~= nil then table.insert(dependents, ''..n..'') end end end return 'This page is loaded as a part of the ' .. ''..name..' gadget' .. (options.hidden ~= nil and ', a hidden gadget'.. (#dependents > 0 and ' used by '..mw.text.listToText(dependents)..'.' or '.') or (options.default ~= nil and ', which is enabled by default.' or (', used by '..lang:formatNum(Gadgets.get_usage(name))..' users. '))) .. '
'end
p.makeMessage = function(pagetype, basepage, sisterpage, sistertype) local text = if basepage.namespace
'js' and 'user script' or 'user stylesheet' if docpageExists and sisterpageExists then text = 'This '..desc..' seems to have a documentation page at '..basepage.fullText..' and an accompanying .'..sistertype..' page at '..sisterpage.fullText..'.' elseif docpageExists and not sisterpageExists then text = 'This '..desc..' seems to have a documentation page at '..basepage.fullText..'.' elseif sisterpageExists then text = 'Documentation for this '..desc..' can be added at '..basepage.fullText..'. This user script seems to have an accompanying .'..sistertype..' page at '..sisterpage.fullText..'. ' else text = 'Documentation for this '..desc..' can be added at '..basepage.fullText..'.' end end elseif basepage.namespace
return p