Module:Sandbox/Aidan9382

This is an old revision of this page, as edited by Aidan9382 (talk | contribs) at 06:07, 4 November 2022 (More tests and some pain). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

require("strict")
local p = {}

function p.main(data)
	return "<div style=text-align:right;font-size:80%>This does nothing as of right now. "..os.time().."</div>"
end

function p.iloveregexold(data)
	local r = "%[?%[?.-:([^{|]+)%]?%]?"
	local args = {mw.ustring.match("[[File:Hey.jpg|thumb|left|250px]]",r)}
	return table.concat(args," -- ")
end
function p.iloveregex(data)
	--This assumes [[ is present, and that therefore ]] is present
	local r = "%[%[%a-:([^{|]+)(.+)%]%]"
	local args = {mw.ustring.match("[[File:Hey.jpg|thumb|left|250px|All for [[Module:Excerpt/portals]]|alt=text]]",r)}
	return table.concat(args," -- ")
end

function p:namecall()
	return self
end

function p.pipeProcessingAbsurdityTest(frame)
	-- To do with [[Module:Random slideshow]]
	-- I need this to somehow expand the tags with the input having pipes
	-- Since if we remove pipes and use {{1}}, advanced wikitext causes linter errors and terrible display failures
	-- {{#tag:gallery|' .. galleryContent  .. '|mode=slideshow|class=switcher-container}}
	local inputUnpiped = [==[File:MH-60S Helicopter dumps water onto Fire.jpg{{!}}<span class="switcher-label" style="display:none"><span class="randomSlideshow-sr-only">Image 1</span></span>Water is used for [[fire fighting{{!}}fighting]] [[wildfire]]s. (from '''[[Water]]''')
File:Water molecule (1).svg{{!}}<span class="switcher-label" style="display:none"><span class="randomSlideshow-sr-only">Image 2</span></span>A water molecule consists of two hydrogen atoms and one oxygen atom (from '''[[Water]]''')
File:Water withdrawals per capita, OWID.svg{{!}}<span class="switcher-label" style="display:none"><span class="randomSlideshow-sr-only">Image 3</span></span>Total water withdrawals for agricultural, industrial and municipal purposes per capita, measured in cubic metres (m³) per year in 2010 (from '''[[Water]]''')
File:Icosahedron-spinoza.jpg{{!}}<span class="switcher-label" style="display:none"><span class="randomSlideshow-sr-only">Image 4</span></span>[[Icosahedron]] as a part of [[Baruch Spinoza{{!}}Spinoza]] monument in [[Amsterdam]]. (from '''[[Water]]'''){{!}}alt{{=}}Icosahedron as a part of Spinoza monument in Amsterdam.
File:Sterilewater.jpg{{!}}<span class="switcher-label" style="display:none"><span class="randomSlideshow-sr-only">Image 5</span></span>Sterile water for injection (from '''[[Water]]''')]==]
	-- just the first five images given out by galleryContent in Random slideshow.makeOutput()
	local inputPiped = string.gsub(inputUnpiped,"{{!}}","|")
	local results = {}
	results[#results+1] = frame:preprocess("{{#tag:gallery|" .. inputUnpiped  .. "|mode=slideshow|class=switcher-container}}")
	results[#results+1] = frame:preprocess("{{#tag:gallery|" .. inputPiped  .. "|mode=slideshow|class=switcher-container}}")
	results[#results+1] = frame:preprocess(string.gsub(inputPiped,"\n","\n\n"))
	results[#results+1] = frame:preprocess("{{#invoke:Text|concatParams|" .. inputPiped  .. "}}")
	results[#results+1] = frame:preprocess("{{#tag:gallery|{{#invoke:Text|concatParams|" .. inputPiped  .. "}}|mode=slideshow|class=switcher-container}}")
	--results[#results+1] = frame:expandTemplate({title="#tag",args={"gallery",inputPiped,mode="slideshow",class="switcher-container"}}) --I wish
	return table.concat(results,"\n\n<hr>\n\n")
end

return p