Module:High-use: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
m
1 revision imported from wikipedia:Module:High-use
(Fix Linter errors)
m (1 revision imported from wikipedia:Module:High-use)
 
(10 intermediate revisions by 6 users not shown)
Line 3:
-- _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 count = _fetch(frame) end
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
Line 33 ⟶ 40:
return_value = string.format("approximately %s", mw.getContentLanguage():formatNum(math.floor( (count / 10^(f)) + 0.5) * (10^(f))) )
end
 
-- Insert percentage of pages if that is likely to be >= 1% and when |no-percent= not set to yes
if count and count > 250000 and not yesno (frame:getParent().args['no-percent']) then
local percent = math.floor( ( (count/frame:callParserFunction('NUMBEROFPAGES', 'R') ) * 100) + 0.5)
if percent >= 1 then
Line 45 ⟶ 52:
return return_value
end
 
-- Actions if there is a large (greater than or equal to 100,000) transclusion count
function p.risk(frame)
Line 62 ⟶ 70:
local bot_text = (frame:preprocess("{{REVISIONID}}") == "") and "\n\n----\n'''Preview message''': Transclusion count updated automatically ([[Template:High-use/doc#Technical details|see documentation]])." or ''
if count == nil then count = _fetch(frame) end
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
local title = mw.title.getCurrentTitle()
if title.subpageText == "doc" or title.subpageText == "sandbox" then
Line 72 ⟶ 86:
systemMessages = nil
end
-- This retrieves the project URL automatically to simplify localiation.
local templateCount = ('on [https://templatecountlinkcount.toolforge.org/index.php?lang=en&namespaceproject=%s&namepage=%s %s pages]'):format(
mw.title.getCurrentTitle().namespace, mw.uri.encode(title.text), p.num(frame, count))
mw.title.getCurrentTitle():fullUrl():gsub('//(.-)/.*', '%1'),
mw.title.getCurrentTitle().namespace, mw.uri.encode(title.textfullText), p.num(frame, count))
local used_on_text = "'''This " .. (mw.title.getCurrentTitle().namespace == 828 and "Lua module" or "template") .. ' is used ';
if systemMessages then
used_on_text = used_on_text .. systemMessages ..
((count and count > 2000) and (",''', and " .. templateCount) or (".'''"))
else
used_on_text = used_on_text .. templateCount .. "'''"
Line 90 ⟶ 106:
)
if local infoArg = frame.args["info"] ~= "" and frame.args["info"] ~= "" then
if (systemMessages or frame.args[1] == "risk" or (count and count >= 100000) ) then
local info = systemMessages and '.<br/>Changes to it can cause immediate changes to the Wikipedia user interface.' or '.'
if infoArg then
if frame.args["info"] and frame.args["info"] ~= "" then
info = info .. "<br />" .. frame.args["info"]infoArg
end
sandbox_text = info .. '<br /> To avoid major disruption' ..
Line 100 ⟶ 117:
'The tested changes can be added to this page in a single edit. '
else
sandbox_text = '(infoArg and changes('.<br may/>' be.. widelyinfoArg noticed.. Test' changesC') inor the' and c') .. sandbox_text
'hanges may be widely noticed. Test changes in the ' .. sandbox_text
end
 
Line 115 ⟶ 133:
 
function p.main(frame)
local count = _fetch(frame)nil
if yesno(frame.args['fetch']) == false then
if (frame.args[1] or '') ~= '' then count = tonumber(frame.args[1]) end
else
count = _fetch(frame)
end
local image = "[[File:Ambox warning yellow.svg|40px|alt=Warning|link=]]"
local type_param = "style"
Line 123 ⟶ 146:
type_param = "content"
local nocat = frame:getParent().args['nocat'] or frame.args['nocat']
local categorise = (nocat == '' or not require('Module:Yesno')yesno(nocat))
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]]}}}}')
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu