Module:Gallery: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
(preview message)
Line 8: Line 8:
return (mw.ustring.gsub(s, "^%s*(.-)%s*$", "%1"))
return (mw.ustring.gsub(s, "^%s*(.-)%s*$", "%1"))
end
end

local tracking, preview = '', ''


local function checkarg(k)
local function checkarg(k)
local t = ''
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
Line 18: Line 19:
-- valid
-- valid
elseif k == 'captionstyle' then
elseif k == 'captionstyle' then
t = '[[Category:Pages using gallery with the captionstyle parameter]]'
tracking = tracking .. '[[Category:Pages using gallery with the captionstyle parameter]]'
elseif k:match('^width%d+$') then
elseif k:match('^width%d+$') then
-- deprecated
-- deprecated
k = mw.ustring.gsub(k, '^width(%d+)$', '%1')
k = mw.ustring.gsub(k, '^width(%d+)$', '%1')
t = '[[Category:Pages using gallery with custom width parameters|' .. k .. ']]'
tracking = tracking .. '[[Category:Pages using gallery with custom width parameters|' .. k .. ']]'
else
else
-- invalid
-- invalid
Line 28: Line 29:
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\-_ ]', '?')
t = '[[Category:Pages using gallery with unknown parameters|' .. k .. ']]'
tracking = tracking .. '[[Category:Pages using gallery with unknown parameters|' .. k .. ']]'
preview = preview .. 'Unknown: "' .. k .. '"<br>'
end
end
end
end
Line 35: Line 37:


function p.gallery(frame)
function p.gallery(frame)
local tracking = ''
-- If called via #invoke, use the args passed into the invoking template.
-- If called via #invoke, use the args passed into the invoking template.
-- Otherwise, for testing purposes, assume args are being passed directly in.
-- Otherwise, for testing purposes, assume args are being passed directly in.
Line 48: Line 48:
if v ~= '' then
if v ~= '' then
args[k] = v
args[k] = v
tracking = tracking .. checkarg(k)
checkarg(k)
end
end
end
end
Line 162: Line 162:
end
end


if preview ~= '' then
if frame:preprocess( "{{REVISIONID}}" ) == "" then
tracking = preview
end
end
return frame:extensionTag{ name = 'templatestyles', args = { src = templatestyles} } .. tostring(tbl) .. tracking
return frame:extensionTag{ name = 'templatestyles', args = { src = templatestyles} } .. tostring(tbl) .. tracking
end
end