Documentation for this module may be created at Module:CampaignGallery/doc
-- <nowiki>
--[=[
------------------------------------------------------------------------------
Originally developed by User:WrathOf for use on Rise of Cultures Wiki
https://rise-of-cultures.fandom.com/wiki/Module:CampaignGallery
Please attribute accordingly if copied for use elsewhere.
Refer to https://www.fandom.com/licensing for more information.
--------------------------------------------------------------------------------
Module:CampaignGallery
Returns a specially formatted gallery tag for use on campaign pages
--------------------------------------------------------------------------------
Template:CampaignGallery
{{#invoke:CampaignGallery|main|<1>|<2>|...}}
where <1> is the name of an image file, <2> is the corresponding label
and additional filename/label can be specified
--------------------------------------------------------------------------------
--]=]
--------------------------------------------------------------------------------
-- Module variables
--------------------------------------------------------------------------------
-- Forward declarations
-- (makes functions local to module and allows flexible ordering of definitions)
local m_Main
--------------------------------------------------------------------------------
-- Module functions
--------------------------------------------------------------------------------
-- Externally exported functions
--------------------------------------------------------------------------------
function m_Main(frame)
local result
local args
local lst = {}
local pval
local linkstart
local linkend
local imgref
--args = frame.args or frame:getParent().args
args = frame:getParent().args
-- iterate over args, grouping into new list of filenames and labels
for i,cval in ipairs(args) do
if i % 2 == 1 then --odd
pval = cval
else --even
table.insert(lst,{pval, cval})
end
end
linkstart = ' [[Media:'
linkend = '|<span style="float:right;">«View Full Size»</span>]]'
--result = '<gallery mode="slideshow" type="slideshow" hideaddbutton="true" navigation="false" position="center" widths="300">\n'
result = mw.html.create('gallery')
result
:attr('mode', 'slideshow')
:attr('type', 'slideshow')
:attr('hideaddbutton', 'true')
:attr('navigation', 'false')
:attr('position', 'center')
:attr('widths', '300')
:newline()
--add each specified image and label with link to image
for i,v in ipairs(lst) do
imgref = v[1] .. '| ' .. v[2] .. linkstart .. v[1] .. linkend
result:wikitext(imgref)
result:newline()
end
--return 'Frame: ' .. table.concat(frame.args, ',') .. '\n' .. 'PFrame: ' .. table.concat(frame:getParent().args, ',')
return tostring(result)
end
-- General functions
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Package namespace
--------------------------------------------------------------------------------
--Set external name to corresponding local function(s)
local p = { main = m_Main }
return p
-- </nowiki>