יחידה:NUMBEROF – הבדלי גרסאות
אין תקציר עריכה |
חלוקת קונטרסים (שיחה | תרומות) התאמה |
||
| שורה 1: | שורה 1: | ||
local function trimArg(arg, i) | local function trimArg(arg, i) | ||
arg = mw.text.trim(arg or '') | arg = mw.text.trim(arg or '') | ||
| שורה 13: | שורה 12: | ||
local function getValue(stats, action, map) | local function getValue(stats, action, map) | ||
if action == 'depth' then | if action == 'depth' then | ||
-- https:// | -- https://chabadpedia.co.il/index.php/חב%22דפדיה | ||
-- This gives silly results if, for example, the number of articles is small. | -- This gives silly results if, for example, the number of articles is small. | ||
local n = { 'articles', 'edits', 'pages' } | local n = { 'articles', 'edits', 'pages' } | ||
| שורה 40: | שורה 39: | ||
-- return numberof result for given action, or nil. | -- return numberof result for given action, or nil. | ||
-- This is faster than reading the cached table, and gives the current value. | -- This is faster than reading the cached table, and gives the current value. | ||
local localSite = string.match(mw.site.server, '. | local localSite = string.match(mw.site.server, 'https?://(.-)%.com$') | ||
or string.match(mw.site.server, 'https?://(.-)%.co%.il$') -- examples: 'chabadpedia', 'text.chabadpedia' | |||
if site == localSite then | if site == localSite then | ||
if action == 'activeusers' then | if action == 'activeusers' then | ||
| שורה 55: | שורה 55: | ||
action = trimArg(action:sub(9), 1) | action = trimArg(action:sub(9), 1) | ||
end | end | ||
local site = trimArg(args[2], 2) -- "af" or " | local site = trimArg(args[2], 2) -- "af" or "text.chabadpedia" or "zitut.chabadpedia" etc., including "total" | ||
if not site:find('.', 1, true) then | if not site:find('.', 1, true) then | ||
site = site .. '.chabadpedia' | site = site .. '.chabadpedia' | ||
| שורה 82: | שורה 82: | ||
-- Rank sites in a specified sister project by their number of articles. | -- Rank sites in a specified sister project by their number of articles. | ||
local args = frame:getParent().args | local args = frame:getParent().args | ||
local parm = trimArg(args[1], 1) -- a number like 12 or a site name like " | local parm = trimArg(args[1], 1) -- a number like 12 or a site name like "text" (not "text.chabadpedia") | ||
local base = trimArg(args[2]) or 'chabadpedia' -- base of full site name like "chabadpedia | local base = trimArg(args[2]) or 'chabadpedia' -- base of full site name like "chabadpedia" | ||
local wantComma = trimArg(args[3]) | local wantComma = trimArg(args[3]) | ||
local data = mw.loadData('Module:NUMBEROF/' .. (base == 'chabadpedia' and 'rank' or 'other')) | local data = mw.loadData('Module:NUMBEROF/' .. (base == 'chabadpedia' and 'rank' or 'other')) | ||
| שורה 109: | שורה 109: | ||
rank = rank, | rank = rank, | ||
} | } | ||