Module:Archive URL counts
| This module is rated as ready for general use. It has reached a mature state, is considered relatively stable and bug-free, and may be used wherever appropriate. It can be mentioned on help pages and other Wikipedia resources as an option for new users. To minimise server load and avoid disruptive output, improvements should be developed through sandbox testing rather than repeated trial-and-error editing. |
| This module depends on the following other modules: |
- Module:Archive URL counts implements template {{Archive URL counts}}.
- It includes the sub-module Module:Archive URL counts/data which is executed only once per page [not per template invocation] to ensure fast loading times. This sub-module pulls data from Wikimedia Commons:
- c:Data:Wikipedia statistics/exturls.tab for statistics regarding external archive URLs across all Wikimedia wikis.
- exturls.tab is updated automatically by the Numberofurl bot.
- The module was originally developed on Enwiki.
local lang_obj = mw.language.getContentLanguage(); -- for use with <wantComma> and <last_update>
local aliases = {
commons = 'commons.wikimedia',
donate = 'donate.wikimedia',
foundation = 'foundation.wikimedia',
incubator = 'incubator.wikimedia',
meta = 'meta.wikimedia',
species = 'species.wikimedia',
wikidata = 'www.wikidata',
wikifunctions = 'www.wikifunctions',
wikimania = 'wikimania.wikimedia',
wikitech = 'wikitech.wikimedia',
wikisource = 'www.wikisource',
}
local function trimArg(arg, i)
arg = mw.text.trim(arg or '')
if arg == '' then
if i then
error('Parameter ' .. i .. ' is missing. See template documentation')
end
return nil
end
return mw.ustring.lower(arg)
end
local function main(frame)
local args = frame:getParent().args
local action = trimArg(args[1], 1)
-- Clean up action if someone uses legacy formatting
if action:sub(1, 8) == 'numberof' then
action = trimArg(action:sub(9), 1)
end
local site = trimArg(args[2], 2)
site = aliases[site] or site
-- If no project is specified (e.g. "fr"), default to ".wikipedia"
-- This also handles the "total" aliases gracefully
if not site:find('.', 1, true) then
site = site .. '.wikipedia'
end
local wantComma = trimArg(args[3]) -- "N" or anything non-blank inserts commas
local result
-- Load the cached data table
local dataObj = mw.loadData('Module:Archive URL counts/data')
local map = dataObj.map
local data = dataObj.data
if 'last_update' == action then -- if all we want is the date of the last update
return lang_obj:formatDate ('j F Y', dataObj.last_update); -- make the date all pretty-like (dmy), return it, and done
end
local siteData = data[site]
if siteData and map[action] then
result = siteData[map[action]]
end
if result then
if wantComma then
result = lang_obj:formatNum(result)
end
return result
end
-- Return -1 if the site or statistic doesn't exist in the JSON
return -1
end
return {
main = main,
}
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.