Module:Gallery: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
(preview message)
Line 8:
return (mw.ustring.gsub(s, "^%s*(.-)%s*$", "%1"))
end
 
local tracking, preview = '', ''
 
local function checkarg(k)
local t = ''
if k and type(k) == 'string' then
if k == 'align' or k == 'state' or k == 'style' or k == 'title' or
Line 18 ⟶ 19:
-- valid
elseif k == 'captionstyle' then
ttracking = tracking .. '[[Category:Pages using gallery with the captionstyle parameter]]'
elseif k:match('^width%d+$') then
-- deprecated
k = mw.ustring.gsub(k, '^width(%d+)$', '%1')
ttracking = tracking .. '[[Category:Pages using gallery with custom width parameters|' .. k .. ']]'
else
-- invalid
Line 28 ⟶ 29:
k = mw.ustring.sub(k, 1, (vlen < 25) and vlen or 25)
k = mw.ustring.gsub(k, '[^%w\-_ ]', '?')
ttracking = tracking .. '[[Category:Pages using gallery with unknown parameters|' .. k .. ']]'
preview = preview .. 'Unknown: "' .. k .. '"<br>'
end
end
Line 35 ⟶ 37:
 
function p.gallery(frame)
local tracking = ''
-- If called via #invoke, use the args passed into the invoking template.
-- Otherwise, for testing purposes, assume args are being passed directly in.
Line 48:
if v ~= '' then
args[k] = v
tracking = tracking .. checkarg(k)
end
end
Line 162:
end
 
if preview ~= '' then
if frame:preprocess( "{{REVISIONID}}" ) == "" then
tracking = preview
end
end
return frame:extensionTag{ name = 'templatestyles', args = { src = templatestyles} } .. tostring(tbl) .. tracking
end