Content deleted Content added
Dreamy Jazz (talk | contribs) m Protected "Module:Wikipedia stats": High-risk Lua module: Requested at WP:RFPP ([Edit=Require autoconfirmed or confirmed access] (indefinite) [Move=Require autoconfirmed or confirmed access] (indefinite)) |
replace with version that was developed in Module:NUMBEROF by User:Johnuniq; this is to split NUMBEROF from NUMBERSECTIONS per Template talk:NUMBEROF |
||
Line 1:
local p = {}
local function trimArg(arg, i)
error(
return nil
return mw.ustring.lower(mw.text.trim(arg))▼
end
end
local function
-- If wanted site is the local site where module is running,
-- return numberof result for given action, or nil.
-- This is faster than reading the cached table, and gives the current value.
return count▼
local localSite = string.match(mw.site.server, '.*//(.*)%.org$') -- examples: 'en.wikipedia', 'commons.wikimedia'
if site == localSite then
action = 'activeUsers'
▲ if k == 0 then
end
return mw.site.stats[action]
end
end
function p.numberof(frame)
local
local action = trimArg(args[1], 1) --
local site = trimArg(args[2], 2) -- "en" or "en.wikipedia" or "en.wikiquote" etc.
if not site:find('.', 1, true) then
local result = -1▼
▲ local action = trimArg(args[1]) -- "ARTICLES, PAGES, EDITS, USERS, ACTIVEUSERS, ADMINS or FILES"
if not action then▼
▲ error("Parameter 1 is missing. See [[Template:" .. tname .. "]] documentation")
end
local
local result = getIfLocal(site, action)
▲ if not site then
local data = mw.loadData('Module:NUMBEROF/data')
local map = data.map
data = data.data
▲ end
end
result = mw.getContentLanguage():formatNum(result)
▲ site = site .. ".wikipedia"
▲ if action == "activeusers" then
▲ result = v[2]
▲ result = v[3]
▲ result = v[4]
▲ end
end
return result -- number or formatted string
end
end
|