local p =
function p.image(frame) math.randomseed(tonumber(mw.getContentLanguage:formatDate("U"))*10000 + os.clock*10000) local args = frame:getParent.args local popupConfig = local caption = popupConfig.loop = args.loop
nil then -- Register this as a dependency so that this page shows up as using all the images on the list page frame:expandTemplate end -- If we don't want to transclude for performance, maybe we could at least link -- however links need to actually be output on the page to register them. if args.caption then popupConfig.caption = "imagestackpopup-caption-" .. math.random caption = tostring(mw.html.create('div') :attr('id', popupConfig.caption) :attr('style', 'display: none') :wikitext(args.caption) :done) end if args.title then popupConfig.title = args.title end
return tostring(mw.html.create('div') :attr('class', 'ImageStackPopup') :attr('data-imagestackpopup-config', mw.text.jsonEncode) :wikitext(args.file)) .. caption
end
function p.gallery(frame) -- Seems like math.random is always seeded with 0 :(math.randomseed(tonumber(mw.getContentLanguage:formatDate("U"))*10000 + os.clock*10000) local args = frame:getParent.args local reuseImageCaption = args.reuse_image_caption ~= nil local title = args["popup-title"] local captionId = nil local captionText = local galleryContents = local optionsArray = local galleryArgs =
local galleryAttr = for i, j in ipairs(galleryAttr) do galleryArgs[j] = args[j] end
if args['popup-caption'] then captionId = 'imagestackpopup-caption-' .. math.random captionText = tostring(mw.html.create('div') :attr('style', 'display:none') :attr('id', captionId) :wikitext(args['popup-caption']) ) end
for row in mw.text.gsplit(args.gallery, "\n", true) do local galleryRow = local popupOptions = for part in mw.text.gsplit(row, "!", true) do equalSplit = mw.text.split(part, '=', true) if #equalSplit <= 1 then -- be sure this really is a caption. if galleryRow ~= and reuseImageCaption and #part > 8 and string.find(part, " ", 1, true) then local captionId = 'imagestackpopup-caption-' .. math.random local wrappedPart = tostring(mw.html.create('span') :attr('id', captionId) :wikitext(part) ) popupOptions.caption = captionId galleryRow = galleryRow .. wrappedPart .. '|' else galleryRow = galleryRow .. part .. '|' end else if equalSplit[1]
'popup-height' then popupOptions.height = tonumber(equalSplit[2]) elseif equalSplit[1]
'popup-start' then popupOptions.start = tonumber(equalSplit[2]) elseif equalSplit[1]
'popup-title' then popupOptions.title = table.concat(equalSplit, '=', 2) elseif equalSplit[1]
nil then -- Register this as a dependency so that this page shows up as using all the images on the list page frame:expandTemplate end else galleryRow = galleryRow .. part .. '|' end
end end if string.sub(galleryRow, -1)
return p