Content deleted Content added
Undid revision 642591985 by Mr. Stradivarius (talk) let's keep things the same as the current template until we roll this out |
per edit request on talk page - remove line as unnecessary |
||
(16 intermediate revisions by 6 users not shown) | |||
Line 13:
-- Load required modules.
require('
local Category = require('Module:Article history/Category')
local yesno = require('Module:Yesno')
Line 127:
obj.cfg = data.cfg
obj.currentTitle = data.currentTitle
obj.makeData = data.makeData -- used by Row:getData
return obj
Line 182 ⟶ 181:
end
function Row:setIconValues(icon, caption, size
self.icon = icon
self.iconCaption = caption
self.iconSize = size
end
Line 198 ⟶ 196:
function Row:getIconSize()
return self.iconSize or self.cfg.defaultIconSize or '30px'
end
Line 347 ⟶ 341:
function Status:getIconSize()
end
function Status:getText(articleHistoryObj)
local text = Row.getText(self, articleHistoryObj)
if text then
return substituteParams(
text,
self.currentTitle.
self.currentTitle.text
)
end
end
Line 396 ⟶ 386:
end
obj.statuses = {}
local defaultIconSize = obj.cfg.
for
table.insert(obj.statuses, Status.new(getChildStatusData(
data,
Line 410 ⟶ 400:
function MultiStatus:exportHtml(articleHistoryObj)
local ret = mw.html.create()
for
ret:node(obj:exportHtml(articleHistoryObj))
end
Line 418 ⟶ 408:
function MultiStatus:getCategories(articleHistoryObj)
local ret = {}
for
for
ret[#ret + 1] = categoryObj
end
Line 428 ⟶ 418:
function MultiStatus:exportNoticeBarIcon()
local ret = {}
for
ret[#ret + 1] = obj:exportNoticeBarIcon()
end
Line 436 ⟶ 426:
function MultiStatus:getWarnings()
local ret = {}
for
for
ret[#ret + 1] = msg
end
Line 460 ⟶ 450:
data.icon,
data.iconCaption,
data.iconSize
)
obj:setNoticeBarIconValues(
Line 668 ⟶ 657:
self:getName(articleHistoryObj)
))
-- Result cell
row
Line 694 ⟶ 683:
data.icon,
data.iconCaption,
data.iconSize
)
obj:setNoticeBarIconValues(
Line 718 ⟶ 706:
function CollapsibleNotice:getIconSize()
or self.cfg.defaultCollapsibleNoticeIconSize
or '20px'
end
Line 747 ⟶ 729:
if collapsibleText then
cell
:tag('
:addClass('mw-collapsible mw-collapsed')
:
:
:done()
:tag('
:
else
cell:wikitext(text)
Line 815 ⟶ 787:
obj.args = args or {}
obj.currentTitle = currentTitle or mw.title.getCurrentTitle()
-- Define object structure.
obj._errors = {}
obj._allObjectsCache = {}
-- Format the config
local function substituteAliases(t, ret)
Line 939 ⟶ 908:
local actions = {}
local suffixes = self.cfg.actionParamSuffixes
for
local objArgs = {}
for k, v in pairs(t) do
Line 1,010 ⟶ 979:
id = statusId,
currentTitle = self.currentTitle,
cfg = self.cfg
}
local isMulti = self.cfg.statuses[statusId].isMulti
Line 1,032 ⟶ 1,000:
end
local ret = {}
for
if t.isActive(self) then
local data = {}
Line 1,042 ⟶ 1,010:
data.cfg = self.cfg
data.currentTitle = self.currentTitle
ret[#ret + 1] = class.new(data)
end
Line 1,076 ⟶ 1,043:
self:getCollapsibleNoticeObjects()
}
for
for
ret[#ret + 1] = obj
end
Line 1,116 ⟶ 1,083:
ret[#ret + 1] = msg
end
for
for
ret[#ret + 1] = msg
end
end
return ret
end
function ArticleHistory:categoriesAreActive()
-- Returns a boolean indicating whether categories should be output or not.
local title = self.currentTitle
local ns = title.namespace
return title.isTalkPage
and ns ~= 3 -- not user talk
and ns ~= 119 -- not draft talk
end
Line 1,127 ⟶ 1,103:
local ret = {}
if self:categoriesAreActive() then
-- Child object categories
for _, obj in ipairs(self:getAllObjects()) do
local categories = self:try(obj.getCategories, obj, self)
for _, categoryObj in ipairs(categories or {}) do
ret[#ret + 1] = tostring(categoryObj)
end
end
local cats = func(self) or {}
for
ret[#ret + 1] = tostring(categoryObj)
end
end
end
Line 1,151 ⟶ 1,129:
-- Table root
local tableRoot = root:tag('table')
tableRoot:addClass('article-history tmbox tmbox-notice')
-- Status
local statusObj = self:getStatusObj()
Line 1,189 ⟶ 1,162:
)
end
local
local nCollapsibleRows = nActionRows + #collapsibleNoticeHtmlObjects
-- Find out if we are collapsed or not.
local isCollapsed = yesno(self.args.collapse)
if
if self.cfg.uncollapsedRows == 'all' then
isCollapsed = false
elseif nCollapsibleRows == 1 then
isCollapsed = false
else
isCollapsed = nCollapsibleRows > (tonumber(self.cfg.uncollapsedRows) or 3)
end
end
Line 1,216 ⟶ 1,192:
-- notices are only included in the table if it is collapsed. Action rows
-- are always included.
local collapsibleTable
if isCollapsed or nActionRows > 0 then
-- Collapsible table base
:tag('tr')
:tag('td')
Line 1,224 ⟶ 1,201:
:css('width', '100%')
:tag('table')
:addClass('
:addClass(isCollapsed and 'mw-collapsible mw-collapsed' or nil)
:css('width', '100%')
:css('font-size', '90%')
-- Header row
local ctHeader = collapsibleTable
:tag('tr')
:tag('
:
end
ctHeader:wikitext(' ')
end
end
end
Line 1,280 ⟶ 1,254:
collapsibleTable:node(htmlObj)
end
end
-- Collapsible notices and current status
-- Otherwise, they are added afterwards, so that they align with the
-- notices.
do
local tableNode, statusColspan
if isCollapsed then
tableNode = collapsibleTable
statusColspan = 3
tableNode = tableRoot
statusColspan = 2
end
--
for _, obj in ipairs(collapsibleNotices) do
tableNode:node(self:try(obj.exportHtml, obj, self, isCollapsed))
end
-- Current status
if statusObj and nActionRows > 1 then
tableNode
:tag('tr')
:tag('td')
:attr('colspan',
:wikitext(self:message('status-blurb',
end
end
-- Get the categories. We have to do this before the error row, so that
Line 1,332 ⟶ 1,304:
errorList:tag('li'):wikitext(msg)
end
if self:categoriesAreActive() then
errorCategory = tostring(Category.new(self:message( 'error-category' ))) end
-- If there are no errors and no active objects, then exit. We can't make
Line 1,344 ⟶ 1,320:
root:wikitext(categories)
root:wikitext(errorCategory)
local frame = mw.getCurrentFrame()
return frame:extensionTag{
name = 'templatestyles', args = { src = 'Module:Message box/tmbox.css' }
} .. frame:extensionTag{
name = 'templatestyles', args = { src = 'Module:Article history/styles.css' }
} .. tostring(root)
end
Line 1,364 ⟶ 1,345:
wrappers = WRAPPER_TEMPLATE
})
if frame:getTitle():find('sandbox', 1, true) then
CONFIG_PAGE = CONFIG_PAGE .. '/sandbox'
end
return p._main(args)
end
|