Module:Article history: Difference between revisions

Content deleted Content added
only output categories if we are in the Talk namespace
per edit request on talk page - remove line as unnecessary
 
(10 intermediate revisions by 6 users not shown)
Line 13:
 
-- Load required modules.
require('Module:No globalsstrict')
local Category = require('Module:Article history/Category')
local yesno = require('Module:Yesno')
Line 127:
obj.cfg = data.cfg
obj.currentTitle = data.currentTitle
obj.isSmall = data.isSmall
obj.makeData = data.makeData -- used by Row:getData
return obj
Line 182 ⟶ 181:
end
 
function Row:setIconValues(icon, caption, size, smallSize)
self.icon = icon
self.iconCaption = caption
self.iconSize = size
self.iconSmallSize = smallSize
end
 
Line 198 ⟶ 196:
 
function Row:getIconSize()
return self.iconSize or self.cfg.defaultIconSize or '30px'
if self.isSmall then
return self.iconSmallSize or self.cfg.defaultSmallIconSize or '15px'
else
return self.iconSize or self.cfg.defaultIconSize or '30px'
end
end
 
Line 347 ⟶ 341:
 
function Status:getIconSize()
ifreturn self.isSmall theniconSize
returnor self.statusCfg.smallIconSizeiconSize
or self.cfg.defaultSmallStatusIconSizedefaultStatusIconSize
or '30px50px'
else
return self.iconSize
or self.statusCfg.iconSize
or self.cfg.defaultStatusIconSize
or '50px'
end
end
 
Line 398 ⟶ 386:
end
obj.statuses = {}
local defaultIconSize = obj.cfg.defaultSmallStatusIconSizedefaultMultiStatusIconSize or '30px'
for i_, id in ipairs(obj.statusCfg.statuses) do
table.insert(obj.statuses, Status.new(getChildStatusData(
data,
Line 412 ⟶ 400:
function MultiStatus:exportHtml(articleHistoryObj)
local ret = mw.html.create()
for i_, obj in ipairs(self.statuses) do
ret:node(obj:exportHtml(articleHistoryObj))
end
Line 420 ⟶ 408:
function MultiStatus:getCategories(articleHistoryObj)
local ret = {}
for i_, obj in ipairs(self.statuses) do
for j_, categoryObj in ipairs(obj:getCategories(articleHistoryObj)) do
ret[#ret + 1] = categoryObj
end
Line 430 ⟶ 418:
function MultiStatus:exportNoticeBarIcon()
local ret = {}
for i_, obj in ipairs(self.statuses) do
ret[#ret + 1] = obj:exportNoticeBarIcon()
end
Line 438 ⟶ 426:
function MultiStatus:getWarnings()
local ret = {}
for i_, obj in ipairs(self.statuses) do
for j_, msg in ipairs(obj:getWarnings()) do
ret[#ret + 1] = msg
end
Line 462 ⟶ 450:
data.icon,
data.iconCaption,
data.iconSize,
data.iconSmallSize
)
obj:setNoticeBarIconValues(
Line 670 ⟶ 657:
self:getName(articleHistoryObj)
))
 
-- Result cell
row
Line 696 ⟶ 683:
data.icon,
data.iconCaption,
data.iconSize,
data.iconSmallSize
)
obj:setNoticeBarIconValues(
Line 720 ⟶ 706:
 
function CollapsibleNotice:getIconSize()
ifreturn self.isSmall theniconSize
or self.cfg.defaultCollapsibleNoticeIconSize
return self.iconSmallSize
or '20px'
or self.cfg.defaultSmallCollapsibleNoticeIconSize
or '15px'
else
return self.iconSize
or self.cfg.defaultCollapsibleNoticeIconSize
or '20px'
end
end
 
Line 749 ⟶ 729:
if collapsibleText then
cell
:tag('tablediv')
:addClass('mw-collapsible mw-collapsed')
:csstag('margindiv', 0)
:csswikitext('padding', 0text)
:css('border-collapse', 'collapse')
:css('width', '100%')
:css('background', 'transparent')
:tag('tr')
:tag('th')
:css('font-weight', 'normal')
:css('text-align', 'left')
:css('width', '100%')
:wikitext(text)
:done()
:done()
:tag('trdiv')
:tagaddClass('tdmw-collapsible-content')
:css('border', '1px silver solid')
:wikitext(collapsibleText)
else
cell:wikitext(text)
Line 817 ⟶ 787:
obj.args = args or {}
obj.currentTitle = currentTitle or mw.title.getCurrentTitle()
 
-- Set isSmall
obj.isSmall = yesno(obj.args.small) or false
 
-- Define object structure.
obj._errors = {}
obj._allObjectsCache = {}
 
-- Format the config
local function substituteAliases(t, ret)
Line 941 ⟶ 908:
local actions = {}
local suffixes = self.cfg.actionParamSuffixes
for i_, t in ipairs(actionArgs) do
local objArgs = {}
for k, v in pairs(t) do
Line 1,012 ⟶ 979:
id = statusId,
currentTitle = self.currentTitle,
cfg = self.cfg,
isSmall = self.isSmall
}
local isMulti = self.cfg.statuses[statusId].isMulti
Line 1,034 ⟶ 1,000:
end
local ret = {}
for i_, t in ipairs(self.cfg[configKey] or {}) do
if t.isActive(self) then
local data = {}
Line 1,044 ⟶ 1,010:
data.cfg = self.cfg
data.currentTitle = self.currentTitle
data.isSmall = self.isSmall
ret[#ret + 1] = class.new(data)
end
Line 1,078 ⟶ 1,043:
self:getCollapsibleNoticeObjects()
}
for i_, t in ipairs(objTables) do
for j_, obj in ipairs(t) do
ret[#ret + 1] = obj
end
Line 1,118 ⟶ 1,083:
ret[#ret + 1] = msg
end
for i_, obj in ipairs(self:getAllObjects(true)) do
for j_, msg in ipairs(obj:getWarnings()) do
ret[#ret + 1] = msg
end
Line 1,128 ⟶ 1,093:
function ArticleHistory:categoriesAreActive()
-- Returns a boolean indicating whether categories should be output or not.
returnlocal title = self.currentTitle.namespace == 1 -- We are in the Talk namespace
local ns = title.namespace
return title.isTalkPage
and ns ~= 3 -- not user talk
and ns ~= 119 -- not draft talk
end
 
Line 1,136 ⟶ 1,105:
if self:categoriesAreActive() then
-- Child object categories
for i_, obj in ipairs(self:getAllObjects()) do
local categories = self:try(obj.getCategories, obj, self)
for j_, categoryObj in ipairs(categories or {}) do
ret[#ret + 1] = tostring(categoryObj)
end
end
 
-- Extra categories
for i_, func in ipairs(self.cfg.extraCategories or {}) do
local cats = func(self) or {}
for i_, categoryObj in ipairs(cats) do
ret[#ret + 1] = tostring(categoryObj)
end
Line 1,160 ⟶ 1,129:
-- Table root
local tableRoot = root:tag('table')
tableRoot:addClass('article-history tmbox tmbox-notice')
 
if self.isSmall then
tableRoot:addClass('mbox-small')
else
tableRoot:css('width', '80%')
end
-- Status
local statusObj = self:getStatusObj()
Line 1,200 ⟶ 1,164:
local nActionRows = #actionHtmlObjects
local nCollapsibleRows = nActionRows + #collapsibleNoticeHtmlObjects
 
-- Find out if we are collapsed or not.
local isCollapsed = yesno(self.args.collapse)
if self.cfg.uncollapsedRowsisCollapsed == 'all'nil then
if self.cfg.uncollapsedRows == 'all' then
isCollapsed = false
isCollapsed = false
elseif nCollapsibleRows == 1 then
elseif nCollapsibleRows == 1 then
isCollapsed = false
isCollapsed = false
else
else
isCollapsed = nCollapsibleRows > (tonumber(self.cfg.uncollapsedRows) or 3)
isCollapsed = nCollapsibleRows > (tonumber(self.cfg.uncollapsedRows) or 3)
end
end
 
Line 1,235 ⟶ 1,201:
:css('width', '100%')
:tag('table')
:addClass('AHarticle-history-milestones')
:addClass(isCollapsed and 'mw-collapsible mw-collapsed' or nil)
:css('width', '100%')
:css('background', 'transparent')
:css('font-size', '90%')
 
-- Header row
if nCollapsibleRows > 1 then
local ctHeader = collapsibleTable
-- Header row
:tag('tr')
local ctHeader = collapsibleTable
:tag('trth')
:tagattr('thcolspan', 3)
:attrcss('colspanfont-size', 3'110%')
:css('font-size', '110%')
 
-- Notice bar
if isCollapsed then
local noticeBarIcons = self:getNoticeBarIcons()
if #noticeBarIcons > 0 then
local noticeBar = ctHeader:tag('span'):css('float', 'left')
for _, icon in ipairs(noticeBarIcons) do
noticeBar:wikitext(icon)
end
ctHeader:wikitext(' ')
end
ctHeader:wikitext(' ')
end
end
 
-- Header text
if mw.site.namespaces[self.currentTitle.namespace].subject.id == 0 then
ctHeader:wikitext(self:message('milestones-header'))
else
ctHeader:wikitext(self:message(
'milestones-header-other-ns',
self.currentTitle.subjectNsText
))
end
 
-- Subheadings
if nActionRows > 0 then
collapsibleTable
:tag('tr')
:css('text-align', 'left')
:tag('th')
:wikitext(self:message('milestones-date-header'))
:done()
:tag('th')
:wikitext(self:message('milestones-process-header'))
:done()
:tag('th')
:wikitext(self:message('milestones-result-header'))
end
end
 
Line 1,292 ⟶ 1,255:
end
end
 
-- Collapsible notices and current status
-- These are only included in the collapsible table if it is collapsed.
Line 1,306 ⟶ 1,269:
statusColspan = 2
end
 
-- Collapsible notices
for _, obj in ipairs(collapsibleNotices) do
tableNode:node(self:try(obj.exportHtml, obj, self, isCollapsed))
end
 
-- Current status
if statusObj and nActionRows > 1 then
Line 1,357 ⟶ 1,320:
root:wikitext(categories)
root:wikitext(errorCategory)
 
local frame = mw.getCurrentFrame()
return tostring(root)
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,377 ⟶ 1,345:
wrappers = WRAPPER_TEMPLATE
})
if frame:getTitle():find('sandbox', 1, true) then
CONFIG_PAGE = CONFIG_PAGE .. '/sandbox'
end
return p._main(args)
end