Module:Transclusion count: Difference between revisions

m 1 revision imported: Importing CS1
m 1 revision imported: Fix for LUA errors
 
(One intermediate revision by one other user not shown)
Line 52: Line 52:
local data = mw.loadData('Module:Transclusion count/data/' .. ((i == 91) and 'other' or string.char(i)))
local data = mw.loadData('Module:Transclusion count/data/' .. ((i == 91) and 'other' or string.char(i)))
for name, count in pairs(data) do
for name, count in pairs(data) do
table.insert(list, {mw.title.new(name, "Template").fullText, count})
local title = mw.title.new(name, "Template")
table.insert(list, {title, count})
end
end
end
end
Line 60: Line 61:
local lang = mw.getContentLanguage();
local lang = mw.getContentLanguage();
for i = 1, #list do
for i = 1, #list do
list[i] = ('|-\n| %d || [[%s]] || %s\n'):format(i, list[i][1]:gsub('_', ' '), lang:formatNum(list[i][2]))
local protLevel = ""
local title = list[i][1]
if i < 400 then
-- Stop at 400 to avoid breaching the expensive parser function call limit
protLevel = title.protectionLevels.edit[1] or "(unprotected)"
end
list[i] = ('|-\n| %d || [[%s]] || %s || %s \n'):format(i, title.fullText:gsub('_', ' '), lang:formatNum(list[i][2]), protLevel)
end
end
return table.concat(list)
return table.concat(list)