Module:Article history: Difference between revisions

Content deleted Content added
write ArticleHistory:renderBox and add ArticleHistory:message
turn the Header class into a Row class, and add methods to it
Line 13:
 
-- Load required modules.
local checkType = require('libraryUtil').checkType
local yesno = require('Module:Yesno')
 
Line 60 ⟶ 59:
 
-------------------------------------------------------------------------------
-- HeaderRow class
-- HeaderThis objectsis area displayedsuper-class atrepresenting theone toprow ofin the template, above the.
-- collapsed section. They usually have an image and a blurb.
-------------------------------------------------------------------------------
 
local HeaderRow = {}
HeaderRow.__index = HeaderRow
 
function HeaderRow.new(data)
local obj = setmetatable({}, HeaderRow)
obj.cfg = data.cfg
obj.categories = {}
return obj
end
 
function Header:exportHtmlRow.renderImage(image, caption, size)
if caption then
caption = '|' .. caption
else
caption = ''
end
return string.format('[[File:%s|%s%s]]', image, size, caption)
end
 
function HeaderRow:exportCategoriessetIcon(icon, caption, size)
self.icon = icon
self.caption = caption
self.size = size
end
 
function Row:setText(text)
self.text = text
end
 
function Row:exportHtml()
local html = mw.html.create('tr')
html
:tag('td')
:addClass('mbox-image')
:wikitext(self.icon and self.renderImage(
self.icon,
self.caption,
self.size or self.cfg.defaultIconSize or '30px'
))
:done()
:tag('td')
:addClass('mbox-text')
:wikitext(self.text)
return html
end
 
function Row:addCategory(category, sortKey)
local categoryObj = Category.new(category, sortKey)
table.insert(self.categories, categoryObj)
end
 
function Row:exportCategories()
return self.categories
end
 
function Row:setNoticeBarIcon(icon, caption, size)
self.noticeBarIcon = icon
self.noticeBarCaption = caption
self.noticeBarIconSize = size
end
 
function Row:exportNoticeBarIcon()
if not self.noticeBarIcon then
return nil
end
local size = self.noticeBarIconSize or self.cfg.defaultNoticeBarIconSize or '15px'
return self.renderImage(self.noticeBarIcon, size, self.noticeBarCaption)
end
 
Line 84 ⟶ 137:
-------------------------------------------------------------------------------
 
local Status = setmetatable({}, HeaderRow)
Status.__index = Status
 
function Status.new(data)
local obj = HeaderRow.new(data)
setmetatable(obj, Status)
return obj
Line 99 ⟶ 152:
-------------------------------------------------------------------------------
 
local DoubleStatus = setmetatable({}, HeaderRow)
DoubleStatus.__index = DoubleStatus
 
function DoubleStatus.new(data)
local obj = HeaderRow.new(data)
setmetatable(obj, DoubleStatus)
return obj
Line 114 ⟶ 167:
-------------------------------------------------------------------------------
 
local Notice = setmetatable({}, HeaderRow)
Notice.__index = Notice
 
function Notice.new(data)
local obj = HeaderRow.new(data)
setmetatable(obj, Notice)
return obj
Line 133 ⟶ 186:
-------------------------------------------------------------------------------
 
local Action = setmetatable({}, Row)
Action.__index = Action
 
Line 147 ⟶ 200:
-- Valid data table keys:
-- code, result, link, paramNum, cfg, currentTitle
local obj = Row.new(data)
setmetatable({}obj, Action)
 
obj.cfg = data.cfg
Line 184 ⟶ 238:
 
function Action:exportHtml()
local row = mw.html.create('tr')
end
 
Line 195 ⟶ 250:
-------------------------------------------------------------------------------
 
local CollapsibleNotice = setmetatable({}, Row)
CollapsibleNotice.__index = CollapsibleNotice
 
function CollapsibleNotice.new(data)
local obj = Row.new(data)
setmetatable(obj, CollapsibleNotice)
return obj
end
 
-------------------------------------------------------------------------------