Module:Index progress
上述文档嵌入自Module:Index progress/doc。 (编辑 | 历史) 编者可以在本模块的沙盒 (创建 | 镜像)和测试样例 (创建)页面进行实验。 本模块的子页面。 |
require('strict')
--copied from enwikisource. Removed the function p.pie
--[=[
This is a module to extract data from the ProofreadPage Lua API and feed it into a progress bar
]=]
local p = {} --p stands for package
local getArgs = require('Module:Arguments').getArgs
local proofreadPage = require('mw.ext.proofreadPage')
local yesno = require('Module:Yesno')
local error_message = require('Module:Error')['error']
local progress_bar = require('Module:Progress bar')._progress_bar
--removed dependency on progress_pie_chart
--local progress_pie_chart = require('Module:Progress pie chart')._progress_pie_chart
--[=[
Map ProofreadPage Lua index progress to progress_bar
]=]
function p.bar(frame)
local args = getArgs(frame)
if not args or not args[1] then
return error_message({'[[Module:Index progress]] error: no index provided'})
end
local idx = args[1]:gsub('^Index:', '')
local index = proofreadPage.newIndex(idx)
if not index then
return error_message({'[[Module:Index progress]] error: index not found'})
end
local barArgs = {
['total'] = index.pageCount,
['notext'] = index:pagesWithLevel(0),
['not_proofread'] = index:pagesWithLevel(1),
['problematic'] = index:pagesWithLevel(2),
['proofread'] = index:pagesWithLevel(3),
['validated'] = index:pagesWithLevel(4),
['height'] = args.height,
['width'] = args.width,
['existing_only'] = args.existing_only
}
return progress_bar(barArgs)
end
return p