Permanently protected module
From Wikipedia, the free encyclopedia


local p = {}

local randomModule = require('Module:Random')



p.main = function(frame)

	local parent = frame.getParent(frame)

	local parentArgs = parent.args

	local args = cleanupArgs(parentArgs)

	local output = p._main(args)

	return frame:preprocess(output)

end



function cleanupArgs(argsTable)

	local cleanArgs = {}

	for key, val in pairs(argsTable) do

		if type(val) == 'string' then

			val = val:match('^%s*(.-)%s*$')

			if val ~= '' then

				cleanArgskey = val

			end

		else

			cleanArgskey = val

		end

	end

	return cleanArgs

end



p._main = function(args)

	if not args1 then

		return error('No page specified', 0)

	end

	local lines=makeGalleryLinesTable(args)

	return makeOutput(lines, args.overflow, args.maxheight, args.mode, args.croptop)

end



function makeGalleryLine(file, caption, link)

	local title = mw.title.new(file, "File" )

	local linktext = ( link and '{{!}}link=' .. link  or '' )

	local maxImageWidth = '{{!}}800px'

	return '[[' .. title.prefixedText ..(caption and'{{!}}'..caption or '').. maxImageWidth .. linktext ..']]' .. (caption and '\n<div style="text-align:center;">' .. caption ..'</div>' or '\n') 

end



function makeGalleryLineSlideshow(file, caption)

	local title = mw.title.new(file, "File" )

	local captiontext= '[[File:OOjs_UI_icon_info-progressive.svg|link=:'..title.prefixedText..']]&nbsp;<span style="font-size:110%;">'..(caption or '')..'</span>'

	return title.prefixedText .. '{{!}}' .. captiontext 

end



function makeGalleryLinesTable(args)

	local galleryLinesTable = {}

	local i = 1

	while argsi do

		if not args.mode then 

			table.insert(galleryLinesTable, makeGalleryLine(argsi], argsi+1],args.link))

		elseif args.mode == 'slideshow' then

			table.insert(galleryLinesTable, makeGalleryLineSlideshow(argsi], argsi+1], args.link)) 

		else 

			error('Mode not supported')

		end

		i = i + 2

	end

	

	return galleryLinesTable 

end



function makeOutput(imageLines, overflow, maxHeight, mode, croptop)

	local randomiseArgs = {	't' = imageLines }

	local randomisedLines = randomModule.main('array', randomiseArgs )

	local output, galleryContent

	if not mode then

	    galleryContent = table.concat(randomisedLines, '\n',1,1)

	    seperate=mw.text.split(galleryContent,'\n')

		output = '<div class="portal-banner-image" style="max-height:' .. (maxHeight or 'initial') .. '; overflow:'..(overflow or 'auto')..

		';"><div class="portal-banner-image-crop" style="position:relative; margin-top:-'..(croptop or '0')..'%;">'..seperate1..'</div></div>'..seperate2

	elseif mode == 'slideshow' then

      	galleryContent = table.concat(randomisedLines, '\n')

		output='<div class="portal-banner-image-slideshow nomobile" style="max-height:' .. (maxHeight or 'initial') .. '; overflow:'..(overflow or 'auto')..

		';"><div class="portal-banner-image-crop" style="position:relative; margin-top:-'..(croptop or '0')..'%;">'..'{{#tag:gallery|'..galleryContent..'|mode=slideshow}}'..'</div></div>'

	else

		error('Mode not supported')

	end

	

	return output

end



return p
Permanently protected module
From Wikipedia, the free encyclopedia


local p = {}

local randomModule = require('Module:Random')



p.main = function(frame)

	local parent = frame.getParent(frame)

	local parentArgs = parent.args

	local args = cleanupArgs(parentArgs)

	local output = p._main(args)

	return frame:preprocess(output)

end



function cleanupArgs(argsTable)

	local cleanArgs = {}

	for key, val in pairs(argsTable) do

		if type(val) == 'string' then

			val = val:match('^%s*(.-)%s*$')

			if val ~= '' then

				cleanArgskey = val

			end

		else

			cleanArgskey = val

		end

	end

	return cleanArgs

end



p._main = function(args)

	if not args1 then

		return error('No page specified', 0)

	end

	local lines=makeGalleryLinesTable(args)

	return makeOutput(lines, args.overflow, args.maxheight, args.mode, args.croptop)

end



function makeGalleryLine(file, caption, link)

	local title = mw.title.new(file, "File" )

	local linktext = ( link and '{{!}}link=' .. link  or '' )

	local maxImageWidth = '{{!}}800px'

	return '[[' .. title.prefixedText ..(caption and'{{!}}'..caption or '').. maxImageWidth .. linktext ..']]' .. (caption and '\n<div style="text-align:center;">' .. caption ..'</div>' or '\n') 

end



function makeGalleryLineSlideshow(file, caption)

	local title = mw.title.new(file, "File" )

	local captiontext= '[[File:OOjs_UI_icon_info-progressive.svg|link=:'..title.prefixedText..']]&nbsp;<span style="font-size:110%;">'..(caption or '')..'</span>'

	return title.prefixedText .. '{{!}}' .. captiontext 

end



function makeGalleryLinesTable(args)

	local galleryLinesTable = {}

	local i = 1

	while argsi do

		if not args.mode then 

			table.insert(galleryLinesTable, makeGalleryLine(argsi], argsi+1],args.link))

		elseif args.mode == 'slideshow' then

			table.insert(galleryLinesTable, makeGalleryLineSlideshow(argsi], argsi+1], args.link)) 

		else 

			error('Mode not supported')

		end

		i = i + 2

	end

	

	return galleryLinesTable 

end



function makeOutput(imageLines, overflow, maxHeight, mode, croptop)

	local randomiseArgs = {	't' = imageLines }

	local randomisedLines = randomModule.main('array', randomiseArgs )

	local output, galleryContent

	if not mode then

	    galleryContent = table.concat(randomisedLines, '\n',1,1)

	    seperate=mw.text.split(galleryContent,'\n')

		output = '<div class="portal-banner-image" style="max-height:' .. (maxHeight or 'initial') .. '; overflow:'..(overflow or 'auto')..

		';"><div class="portal-banner-image-crop" style="position:relative; margin-top:-'..(croptop or '0')..'%;">'..seperate1..'</div></div>'..seperate2

	elseif mode == 'slideshow' then

      	galleryContent = table.concat(randomisedLines, '\n')

		output='<div class="portal-banner-image-slideshow nomobile" style="max-height:' .. (maxHeight or 'initial') .. '; overflow:'..(overflow or 'auto')..

		';"><div class="portal-banner-image-crop" style="position:relative; margin-top:-'..(croptop or '0')..'%;">'..'{{#tag:gallery|'..galleryContent..'|mode=slideshow}}'..'</div></div>'

	else

		error('Mode not supported')

	end

	

	return output

end



return p

Videos

Youtube | Vimeo | Bing

Websites

Google | Yahoo | Bing

Encyclopedia

Google | Yahoo | Bing

Facebook