Importer, Bürokraten, Moderatoren (CommentStreams), flow-bot, Oberflächenadministratoren, Push-Abonnementverwalter, Oversighter, Administratoren, Kampagnenbearbeiter (Hochladeassistent)
853
Bearbeitungen
(Avoid categorizing {{used in system}} itself) |
K (39 Versionen von wpen:Module:High-use importiert) |
||
(13 dazwischenliegende Versionen von 8 Benutzern werden nicht angezeigt) | |||
Zeile 3: | Zeile 3: | ||
-- _fetch looks at the "demo" argument. | -- _fetch looks at the "demo" argument. | ||
local _fetch = require('Module:Transclusion_count').fetch | local _fetch = require('Module:Transclusion_count').fetch | ||
local yesno = require('Module:Yesno') | |||
function p.num(frame, count) | function p.num(frame, count) | ||
if count == nil then count = _fetch(frame) end | 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 | -- Build output string | ||
Zeile 33: | Zeile 40: | ||
return_value = string.format("approximately %s", mw.getContentLanguage():formatNum(math.floor( (count / 10^(f)) + 0.5) * (10^(f))) ) | return_value = string.format("approximately %s", mw.getContentLanguage():formatNum(math.floor( (count / 10^(f)) + 0.5) * (10^(f))) ) | ||
end | end | ||
-- Insert percentage of pages if that is likely to be >= 1% | -- Insert percentage of pages if that is likely to be >= 1% and when |no-percent= not set to yes | ||
if count and count > 250000 then | 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) | local percent = math.floor( ( (count/frame:callParserFunction('NUMBEROFPAGES', 'R') ) * 100) + 0.5) | ||
if percent >= 1 then | if percent >= 1 then | ||
Zeile 60: | Zeile 67: | ||
-- Only show the information about how this template gets updated if someone | -- Only show the information about how this template gets updated if someone | ||
-- is actually editing the page and maybe trying to update the count. | -- is actually editing the page and maybe trying to update the count. | ||
local bot_text = (frame:preprocess("{{REVISIONID}}") == "") and "\n\n----\n'''Preview message''': Transclusion count updated automatically ([[Template:High-use/doc#Technical details|see documentation]] | 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 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 | |||
local title = mw.title.getCurrentTitle() | local title = mw.title.getCurrentTitle() | ||
if title.subpageText == "doc" or title.subpageText == "sandbox" then | if title.subpageText == "doc" or title.subpageText == "sandbox" then | ||
Zeile 72: | Zeile 85: | ||
systemMessages = nil | systemMessages = nil | ||
end | end | ||
local templateCount = ('on [https:// | -- This retrieves the project URL automatically to simplify localiation. | ||
mw.title.getCurrentTitle(). | local templateCount = ('on [https://linkcount.toolforge.org/index.php?project=%s&page=%s %s pages]'):format( | ||
mw.title.getCurrentTitle():fullUrl():gsub('//(.-)/.*', '%1'), | |||
mw.uri.encode(title.fullText), p.num(frame, count)) | |||
local used_on_text = "'''This " .. (mw.title.getCurrentTitle().namespace == 828 and "Lua module" or "template") .. ' is used '; | local used_on_text = "'''This " .. (mw.title.getCurrentTitle().namespace == 828 and "Lua module" or "template") .. ' is used '; | ||
if systemMessages then | if systemMessages then | ||
used_on_text = used_on_text .. systemMessages .. | used_on_text = used_on_text .. systemMessages .. | ||
((count and count > 2000) and (" | ((count and count > 2000) and ("''', and " .. templateCount) or ("'''")) | ||
else | else | ||
used_on_text = used_on_text .. templateCount .. "'''" | used_on_text = used_on_text .. templateCount .. "'''" | ||
Zeile 90: | Zeile 105: | ||
) | ) | ||
local infoArg = frame.args["info"] ~= "" and frame.args["info"] | |||
if (systemMessages or frame.args[1] == "risk" or (count and count >= 100000) ) 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 '' | local info = systemMessages and '.<br/>Changes to it can cause immediate changes to the Wikipedia user interface.' or '.' | ||
if | if infoArg then | ||
info = info .. "<br />" .. | info = info .. "<br />" .. infoArg | ||
end | end | ||
sandbox_text = info .. '<br /> To avoid major disruption' .. | sandbox_text = info .. '<br /> To avoid major disruption' .. | ||
Zeile 100: | Zeile 116: | ||
'The tested changes can be added to this page in a single edit. ' | 'The tested changes can be added to this page in a single edit. ' | ||
else | else | ||
sandbox_text = ' and | sandbox_text = (infoArg and ('.<br />' .. infoArg .. ' C') or ' and c') .. | ||
'hanges may be widely noticed. Test changes in the ' .. sandbox_text | |||
end | end | ||
Zeile 115: | Zeile 132: | ||
function p.main(frame) | function p.main(frame) | ||
local count = _fetch(frame) | local count = 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 image = "[[File:Ambox warning yellow.svg|40px|alt=Warning|link=]]" | ||
local type_param = "style" | local type_param = "style" | ||
Zeile 123: | Zeile 145: | ||
type_param = "content" | type_param = "content" | ||
local nocat = frame:getParent().args['nocat'] or frame.args['nocat'] | local nocat = frame:getParent().args['nocat'] or frame.args['nocat'] | ||
local categorise = nocat == '' or | local categorise = (nocat == '' or not yesno(nocat)) | ||
if categorise then | 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 | ||
elseif (frame.args[1] == "risk" or (count and count >= 100000)) then | elseif (frame.args[1] == "risk" or (count and count >= 100000)) then |
Bearbeitungen