Module:Message box: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
(change the smalltext logic to work with collapsible text fields) |
(remove the presentButBlank function, fix bug with blank date values, and trim whitespace from all arguments) |
||
Line 13: | Line 13: | ||
local tinsert = table.insert |
local tinsert = table.insert |
||
local tconcat = table.concat |
local tconcat = table.concat |
||
local trim = mw.text.trim |
|||
local box = {} |
local box = {} |
||
Line 24: | Line 25: | ||
return title |
return title |
||
end |
end |
||
⚫ | |||
end |
|||
local function presentButBlank(s) |
|||
⚫ | |||
if s and not mw.ustring.find(s, '%S') then |
|||
⚫ | |||
else |
|||
return false |
|||
end |
end |
||
end |
end |
||
Line 219: | Line 211: | ||
self.issue = args.smalltext |
self.issue = args.smalltext |
||
else |
else |
||
local |
local sect |
||
if |
if args.sect == '' then |
||
sect = 'This ' .. (cfg.sectionDefault or 'page') |
sect = 'This ' .. (cfg.sectionDefault or 'page') |
||
elseif type(sect) == 'string' then |
elseif type(args.sect) == 'string' then |
||
sect = 'This ' .. sect |
sect = 'This ' .. sect |
||
⚫ | |||
⚫ | |||
end |
end |
||
local issue = args.issue |
local issue = args.issue |
||
Line 240: | Line 230: | ||
-- Get the self.talk value. |
-- Get the self.talk value. |
||
local talk = args.talk |
local talk = args.talk |
||
if |
if talk == '' and self.isTemplatePage then |
||
talk = '#' |
talk = '#' |
||
end |
end |
||
Line 267: | Line 257: | ||
-- Get other values. |
-- Get other values. |
||
self.fix = args.fix |
self.fix = args.fix |
||
if args.date and args.date ~= '' then |
|||
self.date = |
self.date = format(" <small>''(%s)''</small>", args.date) |
||
elseif args.date == '' and self.isTemplatePage then |
|||
self.date = lang:formatDate('F Y') |
self.date = lang:formatDate('F Y') |
||
end |
end |
||
Line 536: | Line 526: | ||
-- assume args are being passed directly in from the debug console |
-- assume args are being passed directly in from the debug console |
||
-- or from another Lua module. |
-- or from another Lua module. |
||
local |
local origArgs |
||
if frame == mw.getCurrentFrame() then |
if frame == mw.getCurrentFrame() then |
||
origArgs = frame:getParent().args |
|||
for k, v in pairs(frame.args) do |
for k, v in pairs(frame.args) do |
||
origArgs = frame.args |
|||
break |
break |
||
end |
end |
||
else |
else |
||
origArgs = frame |
|||
⚫ | |||
-- Trim whitespace. |
|||
local args = {} |
|||
for k, v in pairs(origArgs) do |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
end |
end |
||
return makeBox(boxType, args) |
return makeBox(boxType, args) |