Module:High-use: Difference between revisions
Appearance
Created page with "local p = {} -- _fetch looks at the "demo" argument. local _fetch = require('Module:Transclusion_count').fetch local yesno = require('Module:Yesno') function p.num(frame, count) if count == nil then if yesno(frame.args['fetch']) == false then if (frame.args[1] or '') ~= '' then count = tonumber(frame.args[1]) end else count = _fetch(frame) end end -- Build output string local return_value = "" if count == nil then if frame.args[1] == "risk" then..." |
m 1 revision imported: some changes are needed ; like removing link to UTRS |
||
Line 18: | Line 18: | ||
if count == nil then | if count == nil then | ||
if frame.args[1] == "risk" then | if frame.args[1] == "risk" then | ||
return_value = "a very large number of" | |||
else | else | ||
return_value = "many" | |||
end | end | ||
else | else | ||
Line 52: | Line 52: | ||
return return_value | return return_value | ||
end | end | ||
-- Actions if there is a large (greater than or equal to 100,000) transclusion count | -- Actions if there is a large (greater than or equal to 100,000) transclusion count | ||
function p.risk(frame) | function p.risk(frame) | ||
local return_value = "" | |||
if frame.args[1] == "risk" then | if frame.args[1] == "risk" then | ||
return_value = "risk" | |||
else | else | ||
local count = _fetch(frame) | local count = _fetch(frame) | ||
if count and count >= 100000 then | if count and count >= 100000 then return_value = "risk" end | ||
end | end | ||
return | return return_value | ||
end | end | ||
Line 88: | Line 86: | ||
end | end | ||
-- This retrieves the project URL automatically to simplify | -- This retrieves the project URL automatically to simplify localiation. | ||
local templateCount = ('on [https://linkcount.toolforge.org/?project=%s&page=%s | local templateCount = ('on [https://linkcount.toolforge.org/index.php?project=%s&page=%s %s pages]'):format( | ||
mw.title.getCurrentTitle():fullUrl():gsub('//(.-)/.*', '%1'), | mw.title.getCurrentTitle():fullUrl():gsub('//(.-)/.*', '%1'), | ||
mw.uri.encode(title.fullText), p.num(frame, count)) | mw.uri.encode(title.fullText), p.num(frame, count)) | ||
Line 148: | Line 146: | ||
local nocat = frame:getParent().args['nocat'] or frame.args['nocat'] | local nocat = frame:getParent().args['nocat'] or frame.args['nocat'] | ||
local categorise = (nocat == '' or not yesno(nocat)) | local categorise = (nocat == '' or not yesno(nocat)) | ||
if categorise | if categorise then | ||
epilogue = frame:preprocess('{{Sandbox other||{{#switch:{{#invoke:Effective protection level|{{#switch:{{NAMESPACE}}|File=upload|#default=edit}}|{{FULLPAGENAME}}}}|sysop|templateeditor|interfaceadmin=|#default=[[Category:Pages used in system messages needing protection]]}}}}') | epilogue = frame:preprocess('{{Sandbox other||{{#switch:{{#invoke:Effective protection level|{{#switch:{{NAMESPACE}}|File=upload|#default=edit}}|{{FULLPAGENAME}}}}|sysop|templateeditor|interfaceadmin=|#default=[[Category:Pages used in system messages needing protection]]}}}}') | ||
end | end |