Jump to content

Module:Lorem ipsum: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
No edit summary
Line 1: Line 1:
local yn = require("Module:Yesno")
return {
return {
main = function(frame)
main = function(frame)
Line 8: Line 9:
end
end
local out = ''
local out = ''
local link = require("Module:Yesno")(args["link"]) or require("Module:Yesno")(args[4]) or false
local link = yn(args["link"]) or yn(args[4]) or false
local join = require("Module:Yesno")(args["join"]) or false
local join = yn(args["join"]) or false
local cat = yn(args["cat"]) or true
local count = tonumber(args[1] or 1)
local count = tonumber(args[1] or 1)
local i = 1
local i = 1
Line 30: Line 32:
if join then
if join then
out = out .. (args["suffix"] or args[3] or "")
out = out .. (args["suffix"] or args[3] or "")
end
if cat and mw.title.getCurrentTitle().namespace == 0 then
out = out .. "[[Category:Wikipedia articles containing placeholders]]"
end
end
return frame:preprocess(out)
return frame:preprocess(out)
Line 41: Line 46:
end
end
local i = tonumber(args[1] or 1)
local i = tonumber(args[1] or 1)
local link = require("Module:Yesno")(args["link"])
local link = yn(args["link"])
local out = ""
return frame:preprocess(mw.ustring.format(paragraphs[math.mod(i - 1, #paragraphs) + 1], (link and "link" or "")))
if cat and mw.title.getCurrentTitle().namespace == 0 then
out = out .. "[[Category:Wikipedia articles containing placeholders]]"
end
out = out .. mw.ustring.format(paragraphs[math.mod(i - 1, #paragraphs) + 1], (link and "link" or ""))
return frame:preprocess(out)
end
end
}
}

Revision as of 23:21, 12 May 2024

local yn = require("Module:Yesno")
return {
	main = function(frame)
		local args = require("Module:Arguments").getArgs(frame)
		local data = args["data"] and mw.loadData(args["data"]) or mw.loadData("Module:Lorem_ipsum/data")
		local paragraphs = {}
		for k,v in ipairs(data) do
			table.insert(paragraphs, v)
		end
		local out = ''
		local link = yn(args["link"]) or yn(args[4]) or false
		local join = yn(args["join"]) or false
		local cat = yn(args["cat"]) or true
		local count = tonumber(args[1] or 1)
		local i = 1
		if join then
			out = out .. (args["prefix"] or args[2] or "")
		end
		while i <= count do
			if not join then
				out = out .. (args["prefix"] or args[2] or "\n")
			end
			out = out .. mw.ustring.format(paragraphs[math.mod(i - 1, #paragraphs) + 1], (link and "link" or ""))
			if not join then
				out = out .. (args["suffix"] or args[3] or "") .. "\n"
			else
				out = out .. (i == count and "" or " ")
			end
			link = false
			i = i + 1
		end
		if join then
			out = out .. (args["suffix"] or args[3] or "")
		end
		if cat and mw.title.getCurrentTitle().namespace == 0 then
			out = out .. "[[Category:Wikipedia articles containing placeholders]]"
		end
		return frame:preprocess(out)
	end,
	oneParagraph = function(frame)
		local args = require("Module:Arguments").getArgs(frame)
		local data = args["paragraphs"] and mw.loadData(args["paragraphs"]) or mw.loadData("Module:Lorem_ipsum/data")
		local paragraphs = {}
		for k,v in ipairs(data) do
			table.insert(paragraphs, v)
		end
		local i = tonumber(args[1] or 1)
		local link = yn(args["link"])
		local out = ""
		if cat and mw.title.getCurrentTitle().namespace == 0 then
			out = out .. "[[Category:Wikipedia articles containing placeholders]]"
		end
		out = out .. mw.ustring.format(paragraphs[math.mod(i - 1, #paragraphs) + 1], (link and "link" or ""))
		return frame:preprocess(out)
	end
}