Module:Random slideshow/sandbox: Difference between revisions

Content deleted Content added
add class to output, per live module
sync
Line 29:
end
 
function makeOutput(galleryLines, maxWidth, containerClassName)
local randomiseArgs = { ['t'] = galleryLines }
local randomisedLines = randomModule.main('array', randomiseArgs)
local galleryContent = table.concat(randomisedLines, '\n')
local output = '<div class="randomSlideshow-container' .. containerClassName .. '" style="max-width:' .. normaliseCssMeasurement(maxWidth) .. '; margin:-4em auto;">{{#tag:gallery|' .. galleryContent .. '|mode=slideshow}}</div>'
return output
end
Line 39:
function makeGalleryLine(file, caption, credit)
local title = mw.title.new(file, "File" )
local creditLine = ( credit and '<p><span style="font-size:88%">' .. credit .. '</span></p>' or '' )
return title.prefixedText .. '{{!}}' .. ( caption or '' ) .. creditLine
end
Line 116:
end
 
p._main = function(args, transclude, containerClassName)
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)
return makeOutput(lines, args.width or '100%', containerClassName or 'randomSlideshow-container')
end
 
Line 137:
local args = cleanupArgs(parentArgs)
local output = p._main(args, true)
return frame:preprocess(output)
end
 
p.excerpts = function(frame)
local parent = frame.getParent(frame)
local parentArgs = parent.args
local args = cleanupArgs(parentArgs)
-- preserve blank value in more parameter
if parentArgs.more and not args.more then
args.more = parentArgs.more
end
local galleryArgs = {}
local options = args -- pick up miscellaneous options: more, errors, fileargs
options.paraflags = excerptModule.numberflags(args["paragraphs"] or "") -- parse paragraphs, e.g. "1,3-5" → {"1","3-5"}
options.fileflags = excerptModule.numberflags(args["files"] or "") -- parse file numbers
if options.more and options.more == "" then options.more = "Read more..." end -- more= is short for this default text
local i = 1
while args[i] do
local excerpt = excerptModule.main({args[i]}, options)
local text = '<div style{{=}}text-align:left;>' .. mw.ustring.gsub(excerpt, '%c', '<br>') .. '</div>'
table.insert(galleryArgs, 'File:Blank.png')
table.insert(galleryArgs, text)
i = i + 1
end
local output = p._main(galleryArgs, false)
return frame:preprocess(output)
end