יחידה:NUMBEROF – הבדלי גרסאות

מ. רובין (שיחה | תרומות)
אין תקציר עריכה
התאמה
שורה 1: שורה 1:
--<nochabad>
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://meta.chabadmedia.org/chabad/chabadpedia_article_depth
-- 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, '.*//www.chabadpedia.co.il/$')  -- examples: 'af.chabadpedia', 'commons.chabadmedia'
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 "af.chabadpedia" or "af.chabadquote" etc., including "total"
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 "af" (not "af.chabadpedia")
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" or "chabadquote"
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,
}
}
--</nochabad>