<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://dharmawiki.org/index.php?action=history&amp;feed=atom&amp;title=Module%3AGallery</id>
	<title>Module:Gallery - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://dharmawiki.org/index.php?action=history&amp;feed=atom&amp;title=Module%3AGallery"/>
	<link rel="alternate" type="text/html" href="https://dharmawiki.org/index.php?title=Module:Gallery&amp;action=history"/>
	<updated>2026-04-06T20:25:48Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.4</generator>
	<entry>
		<id>https://dharmawiki.org/index.php?title=Module:Gallery&amp;diff=1922&amp;oldid=prev</id>
		<title>WikiSysop: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://dharmawiki.org/index.php?title=Module:Gallery&amp;diff=1922&amp;oldid=prev"/>
		<updated>2016-07-30T14:29:53Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- This module implements {{gallery}}&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
local function trim(s)&lt;br /&gt;
	return (mw.ustring.gsub(s, &amp;quot;^%s*(.-)%s*$&amp;quot;, &amp;quot;%1&amp;quot;))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.gallery(frame)&lt;br /&gt;
	local origArgs&lt;br /&gt;
	-- If called via #invoke, use the args passed into the invoking template.&lt;br /&gt;
	-- Otherwise, for testing purposes, assume args are being passed directly in.&lt;br /&gt;
	if type(frame.getParent) == 'function' then&lt;br /&gt;
		origArgs = frame:getParent().args&lt;br /&gt;
	else&lt;br /&gt;
		origArgs = frame&lt;br /&gt;
	end&lt;br /&gt;
    &lt;br /&gt;
    -- ParserFunctions considers the empty string to be false, so to preserve the previous &lt;br /&gt;
    -- behavior of {{gallery}}, change any empty arguments to nil, so Lua will consider&lt;br /&gt;
    -- them false too.&lt;br /&gt;
    local args = {}&lt;br /&gt;
    for k, v in pairs(origArgs) do&lt;br /&gt;
    	if v ~= '' then&lt;br /&gt;
    		args[k] = v&lt;br /&gt;
    	end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local tbl = mw.html.create('table')&lt;br /&gt;
    &lt;br /&gt;
	if args.state then&lt;br /&gt;
		tbl&lt;br /&gt;
			:css('width', '100%')&lt;br /&gt;
			:addClass('collapsible')&lt;br /&gt;
			:addClass(args.state)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if args.style then&lt;br /&gt;
		tbl:cssText(args.style)&lt;br /&gt;
	else&lt;br /&gt;
		tbl&lt;br /&gt;
			:css('background', 'transparent')&lt;br /&gt;
			:css('margin-top', '0.5em')&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if args.align then&lt;br /&gt;
		if args.align == 'center' then&lt;br /&gt;
			tbl&lt;br /&gt;
				:css('margin-left', 'auto')&lt;br /&gt;
				:css('margin-right', 'auto')&lt;br /&gt;
		else&lt;br /&gt;
			tbl:css('float', args.align)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if args.title then&lt;br /&gt;
		tbl&lt;br /&gt;
			:tag('tr')&lt;br /&gt;
				:tag('th')&lt;br /&gt;
					:css('text-align', 'center')&lt;br /&gt;
					:css('font-weight', 'bold')&lt;br /&gt;
					:wikitext(args.title)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local mainCell = tbl:tag('tr'):tag('td')&lt;br /&gt;
	&lt;br /&gt;
	local imageCount = math.ceil(#args / 2)&lt;br /&gt;
	local cellWidth = tonumber(args.cellwidth) or tonumber(args.width) or 180&lt;br /&gt;
	local imgHeight = tonumber(args.height) or 180&lt;br /&gt;
	local lines = tonumber(args.lines) or 2&lt;br /&gt;
	local captionstyle = args.captionstyle&lt;br /&gt;
	&lt;br /&gt;
    for i = 1, imageCount do&lt;br /&gt;
		local img = trim(args[i*2 - 1] or '')&lt;br /&gt;
		local caption = trim(args[i*2] or '')&lt;br /&gt;
		local imgWidth = tonumber(args['width' .. i]) or tonumber(args.width) or 180&lt;br /&gt;
		local alt = args['alt' .. i] or ''&lt;br /&gt;
		&lt;br /&gt;
		local textWidth&lt;br /&gt;
		if cellWidth &amp;lt; 30 then&lt;br /&gt;
			textWidth = imgHeight + 27&lt;br /&gt;
		else&lt;br /&gt;
			textWidth = cellWidth + 7&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if img ~= '' then&lt;br /&gt;
			local imgTbl = mainCell:tag('table')&lt;br /&gt;
            &lt;br /&gt;
			imgTbl&lt;br /&gt;
				:css('width', (cellWidth + 20) .. 'px')&lt;br /&gt;
				:css('float', 'left')&lt;br /&gt;
				:css('border-collapse', 'collapse')&lt;br /&gt;
				:css('margin', '3px')&lt;br /&gt;
				:tag('tr')&lt;br /&gt;
					:tag('td')&lt;br /&gt;
						:css('height', (imgHeight + 20) .. 'px')&lt;br /&gt;
						:css('border', '1px solid #CCCCCC')&lt;br /&gt;
						:css('background-color', '#F8F8F8')&lt;br /&gt;
						:css('padding', '0px')&lt;br /&gt;
						:css('text-align', 'center')&lt;br /&gt;
						:wikitext(string.format('[[%s|center|border|%dx%dpx|alt=%s|%s]]', img, imgWidth, imgHeight, alt, mw.text.unstrip(caption)))&lt;br /&gt;
						:done()&lt;br /&gt;
					:done()&lt;br /&gt;
				:tag('tr')&lt;br /&gt;
					:css('vertical-align', 'top')&lt;br /&gt;
					:tag('td')&lt;br /&gt;
						:css('display', 'block')&lt;br /&gt;
						:css('font-size', '1em')&lt;br /&gt;
						:css('padding', '0px')&lt;br /&gt;
						:tag('div')&lt;br /&gt;
							:addClass('gallerytext')&lt;br /&gt;
							:css('min-height', (0.1 + 1.5*lines) .. 'em')&lt;br /&gt;
							:css('width', textWidth .. 'px')&lt;br /&gt;
							:css('line-height', '1.3em')&lt;br /&gt;
							:css('padding', '2px 6px 1px 6px')&lt;br /&gt;
							:css('margin', '0px')&lt;br /&gt;
							:css('border', 'none')&lt;br /&gt;
							:css('border-width', '0px')&lt;br /&gt;
							:cssText(captionstyle)&lt;br /&gt;
							:wikitext(caption .. '&amp;amp;nbsp;')&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
    &lt;br /&gt;
	if args.footer then&lt;br /&gt;
		tbl&lt;br /&gt;
			:tag('tr')&lt;br /&gt;
				:tag('td')&lt;br /&gt;
					:css('text-align', 'right')&lt;br /&gt;
					:css('font-size', '80%')&lt;br /&gt;
					:css('line-height', '1em')&lt;br /&gt;
					:wikitext(args.footer)&lt;br /&gt;
	end&lt;br /&gt;
	if args.perrow then&lt;br /&gt;
		tbl:css('width', 8 + (cellWidth + 20 + 6)*tonumber(args.perrow) .. 'px')&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return tostring(tbl)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
</feed>