Module:Gallery: Difference between revisions

198 bytes removed ,  19 September 2023
no edit summary
(Created page with "-- This module implements {{gallery}} local p = {} local templatestyles = 'Template:Gallery/styles.css' local yesno = require('Module:Yesno') local function trim(s) return...")
 
No edit summary
 
Line 3: Line 3:
local p = {}
local p = {}


local templatestyles = 'Template:Gallery/styles.css'
local templatestyles = 'Module:Gallery/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 == 'lines' or k == 'whitebg' or
k == 'width' or k == 'height' 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 27: Line 27:
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 79: Line 79:
:addClass('title')
:addClass('title')
:tag('div')
:tag('div')
:wikitext('<dl><dd>' .. args.title .. '</dd></dl>')
:wikitext(args.title)
end
end
Line 117: Line 117:
:addClass('footer')
:addClass('footer')
:tag('div')
:tag('div')
:wikitext('<dl><dd>' .. args.footer .. '</dd></dl>')
:wikitext(args.footer)
end
end


local trackstr = (#tracking > 0) and table.concat(tracking, '') or ''
local trackstr = (#tracking > 0) and table.concat(tracking, '') or ''
if #preview > 0 and frame:preprocess( "{{REVISIONID}}" ) == "" then
if #preview > 0 then
trackstr = tostring(mw.html.create('div')
trackstr = require('Module:If preview')._warning({
:addClass('hatnote')
'Unknown parameters ' .. table.concat(preview, '; ') .. '.'
:css('color','red')
}) .. trackstr
:tag('strong'):wikitext('Warning:'):done()
:wikitext('Unknown parameters: ' .. table.concat(preview, '; ')))
end
end