Content deleted Content added
rewrite the Row class internals to deal with function values from the config - other classes also need to be updated |
use getter methods and override them for the Status class instead of overriding the exportHtml method |
||
Line 133:
end
function Row:getIcon(
return maybeCallFunc(self.icon,
end
function Row:getIconCaption(
return maybeCallFunc(self.iconCaption,
end
Line 149:
end
function Row:renderIcon(
local icon = self:getIcon(
if not icon then
return nil
end
return renderImage(
icon, self:getIconCaption( self:getIconSize( )
end
Line 163 ⟶ 167:
end
function Row:getNoticeBarIcon(
return maybeCallFunc(self.noticeBarIcon,
end
function Row:getNoticeBarIconCaption(
return maybeCallFunc(self.noticeBarIconCaption,
end
Line 175 ⟶ 179:
end
function Row:exportNoticeBarIcon(
local icon = self:getNoticeBarIcon(
if not icon then
return nil
Line 182 ⟶ 186:
return renderImage(
icon,
self
self:getNoticeBarIconSize()
)
Line 191 ⟶ 195:
end
function Row:getText(
return maybeCallFunc(self.text, articleHistoryObj, self)
end
function Row:exportHtml(
local text = self:getText(
if not text then
return nil
Line 204 ⟶ 208:
:tag('td')
:addClass('mbox-image')
:wikitext(self:renderIcon(
:done()
:tag('td')
Line 218 ⟶ 222:
end
function Row:getCategories(
local ret = {}
if type(self.categories) == 'table' then
Line 225 ⟶ 229:
end
elseif type(self.categories) == 'function' then
for _, categoryObj in ipairs(t) do
ret[#ret + 1] = categoryObj
end
Line 244 ⟶ 249:
setmetatable(obj, Status)
obj.id = data.id
obj.
obj:setIconValues(obj.
obj:setText(obj.statusCfg.text)
obj:setCategories(obj.statusCfg.categories)
return obj
end
function Status:
if self.isSmall then
return self.statusCfg.smallIconSize or self.cfg.defaultSmallStatusIconSize or '30px'
else
return self.statusCfg.iconSize or self.cfg.defaultStatusIconSize or '50px'
end
end
function Status:getText(articleHistoryObj)
local text = Row.getText(self, articleHistoryObj)
return substituteParams(
text,
self.currentTitle.subjectPageTitle.prefixedText,
self.currentTitle.text
end
Line 498 ⟶ 496:
)
end
-- Set the categories
obj:setCategories(obj.actionCfg.categories)
return obj
Line 563 ⟶ 564:
return row
end
Line 598 ⟶ 586:
)
obj:setText(data.text)
obj:setCollapsibleText(data.collapsibleText)
obj:setCategories(data.categories)
return obj
end
function CollapsibleNotice:
self.collapsibleText = s
end
function CollapsibleNotice:getCollapsibleText(articleHistoryObj)
return maybeCallFun(self.collapsibleText, articleHistoryObj, self)
end
function CollapsibleNotice:getIconSize()
if self.isSmall then
return self.iconSmallSize
or self.cfg.defaultSmallCollapsibleNoticeIconSize
or '15px'
else
return self.iconSize
or self.cfg.defaultCollapsibleNoticeIconSize
or '20px'
end
end
function CollapsibleNotice:exportHtml(articleHistoryObj, isInCollapsibleTable)
local text = self:getText(articleHistoryObj)
if
return nil
end
local function maybeMakeCollapsibleTable(cell, text, collapsibleText)
-- If collapsible text is specified, makes a collapsible table inside
Line 659 ⟶ 651:
local html = mw.html.create('tr')
local icon = self:renderIcon(articleHistoryObj)
local collapsibleText = self:getCollapsibleText(articleHistoryObj)
if isInCollapsibleTable then
local textCell = html:tag('td')
:attr('colspan', 3)
:css('width', '100%')
local
if icon then
else
end
maybeMakeCollapsibleTable(textCell,
else
local textCell = html
Line 678 ⟶ 672:
:tag('td')
:addClass('mbox-text')
maybeMakeCollapsibleTable(textCell,
end
Line 808 ⟶ 802:
-- user. We memoise this so that the parameters only have to be processed
-- once.
if self.actions
return self.actions
end
Line 857 ⟶ 851:
function ArticleHistory:getStatusObj()
-- Get the status object for the current status.
if self.statusObj
return nil
elseif self.statusObj ~= nil then
return self.statusObj
end
Line 871 ⟶ 867:
if not statusId then
self.statusObj = false
return
end
Line 883 ⟶ 879:
local isMulti = self.cfg.statuses[statusId].isMulti
local initFunc = isMulti and MultiStatus.new or Status.new
local statusObj = self:try(initFunc, statusObjData)
self.statusObj = statusObj or false
return self.statusObj or nil
end
Line 893 ⟶ 889:
end
function ArticleHistory:
-- This holds the logic for fetching tables of Notice and CollapsibleNotice
-- objects.
if self[memoizeKey] then
return self[memoizeKey]
end
local ret = {}
for i,
for k, v in pairs(t) do
if k ~= 'isActive' then
data[k] = v
end
end
data.cfg = self.cfg
data.currentTitle = self.currentTitle
data.isSmall = self.isSmall
ret[#ret + 1] = class.new(data)
end
end
self
return ret
end
function ArticleHistory:getNoticeObjects()
return self:noticeFactory('notices', 'notices', Notice)
end
function ArticleHistory:getCollapsibleNoticeObjects()
return self:noticeFactory(
CollapsibleNotice
)
end
|