Module:Gallery and Module:Gallery/sandbox: Difference between pages
Appearance
(Difference between pages)
Content deleted Content added
Add support for "centre" in align. |
No edit summary Tags: Mobile edit Mobile web edit Advanced mobile edit |
||
Line 3: | Line 3: | ||
local p = {} |
local p = {} |
||
local templatestyles = 'Module:Gallery/styles.css' |
local templatestyles = 'Module:Gallery/sandbox/styles.css' |
||
local yesno = require('Module:Yesno') |
local yesno = require('Module:Yesno') |
||
Line 15: | Line 15: | ||
if k and type(k) == 'string' then |
if k and type(k) == 'string' then |
||
if k == 'align' or k == 'state' or k == 'style' or k == 'title' or |
if k == 'align' or k == 'state' or k == 'style' or k == 'title' or |
||
k == 'width' or k == 'height' or k == 'whitebg' or |
k == 'width' or k == 'height' or k == 'lines' or k == 'whitebg' or |
||
k == 'mode' or k == 'footer' or k == 'perrow' or k == 'noborder' or |
k == 'mode' or k == 'footer' or k == 'perrow' or k == 'noborder' or |
||
k:match('^alt%d+$') or k:match('^%d+$') then |
k:match('^alt%d+$') or k:match('^%d+$') then |
||
Line 26: | Line 26: | ||
-- invalid |
-- invalid |
||
local vlen = mw.ustring.len(k) |
local vlen = mw.ustring.len(k) |
||
k = mw.ustring.sub(k, 1, (vlen < 25) and vlen or 25) |
k = mw.ustring.sub(k, 1, (vlen < 25) and vlen or 25) |
||
k = mw.ustring.gsub(k, '[^%w |
k = mw.ustring.gsub(k, '[^%w\-_ ]', '?') |
||
table.insert(tracking, '[[Category:Pages using gallery with unknown parameters|' .. k .. ']]') |
table.insert(tracking, '[[Category:Pages using gallery with unknown parameters|' .. k .. ']]') |
||
table.insert(preview, '"' .. k .. '"') |
table.insert(preview, '"' .. k .. '"') |
||
Line 38: | Line 38: | ||
-- Otherwise, for testing purposes, assume args are being passed directly in. |
-- Otherwise, for testing purposes, assume args are being passed directly in. |
||
local origArgs = (type(frame.getParent) == 'function') and frame:getParent().args or frame |
local origArgs = (type(frame.getParent) == 'function') and frame:getParent().args or frame |
||
-- ParserFunctions considers the empty string to be false, so to preserve the previous |
-- ParserFunctions considers the empty string to be false, so to preserve the previous |
||
-- behavior of {{gallery}}, change any empty arguments to nil, so Lua will consider |
-- behavior of {{gallery}}, change any empty arguments to nil, so Lua will consider |
||
-- them false too. |
-- them false too. |
||
Line 52: | Line 52: | ||
if (args.mode or '') == 'packed' and (args.align or '') == '' then |
if (args.mode or '') == 'packed' and (args.align or '') == '' then |
||
args.align = 'center' |
|||
end |
|||
if (args.align or '') == 'centre' then |
|||
args.align = 'center' |
args.align = 'center' |
||
end |
end |
||
local tbl = mw.html.create('div') |
local tbl = mw.html.create('div') |
||
tbl:addClass('mod-gallery') |
tbl:addClass('mod-gallery-sb') |
||
if args.state then |
if args.state then |
||
tbl |
tbl |
||
Line 116: | Line 112: | ||
frame:extensionTag{ name = 'gallery', content = '\n' .. table.concat(gallery,'\n'), args = gargs} |
frame:extensionTag{ name = 'gallery', content = '\n' .. table.concat(gallery,'\n'), args = gargs} |
||
) |
) |
||
if args.footer then |
if args.footer then |
||
tbl:tag('div') |
tbl:tag('div') |