Module:Random slideshow/sandbox: Difference between revisions

Content deleted Content added
No edit summary
Tag: Reverted
revert to old revision of this page, as edited by Anomalocaris at 20:08, 13 May 2021
Line 38:
local randomiseArgs = { ['t'] = galleryLines }
local sortedLines = nonRandom and galleryLines or randomModule.main('array', randomiseArgs)
for i = 1, #sortedLines do
-- insert a switcher-label span just after the first pipe (which has already been escaped as {{!}} instead the | character)
sortedLines[i] = sortedLines[i]:gsub(
"%{%{%!%}%}",
'{{!}}<span class="switcher-label" style="display:none"><span class="randomSlideshow-sr-only">Image ' .. tostring(i) .. '</span></span>',
1)
end
local galleryContent = table.concat(sortedLines, '\n')
local output = '<div class="' .. containerClassName .. '" style="max-width:' .. normaliseCssMeasurement(maxWidth) .. '; margin:-4em auto;"><div class="nomobile"><!--intentionally empty on desktop, and is not present on mobile website (outside template namesapce)--></div>{{#tag:gallery|' .. galleryContent .. '|mode=slideshow|class=switcher-container}}</div>'
return output
end
Line 114 ⟶ 107:
file = mw.ustring.gsub(file, '{{.-([|%]])', '$1')
-- replace pipes and equals (which would otherwise break the {{#tag:}} syntax)
file = mw.ustring.gsub(file, '|%s*alt%s*=', '{{! }}alt=')
file = mw.ustring.gsub(file, '|', '{{!}}')
file = mw.ustring.gsub(file, '=', '{{=}}')
Line 184 ⟶ 176:
end
 
p._main = function(args, transclude, extraClassNamecontainerClassName)
if not args[1] then
return error(linked and 'No page specified' or 'No page specified', 0)
end
local lines = transclude and makeTranscludedGalleryLinesTables(args) or makeGalleryLinesTable(args)
localreturn classNamesmakeOutput(lines, =args.width or '100%', containerClassName or 'randomSlideshow-container', isDeclined(args.random))
if extraClassName then classNames = classNames .. ' ' .. extraClassName end
return makeOutput(lines, args.width or '100%', classNames, isDeclined(args.random))
end