Module:Comment

local p = {}

local Cite = require("Module:Cite") local Color = require("Module:Color") local File = require("Module:File") local utilsArg = require("Module:UtilsArg") local utilsError = require('Module:UtilsError') local utilsMarkup = require("Module:UtilsMarkup")

local Constants = mw.loadData("Module:Constants/Data")

local COMMENTER_IMAGE_SIZE = "80px"

function p.Main(frame) return p.main(frame.args) end

-- Work in progress function p.MultiComment(frame) local args, err = utilsArg.parse(frame:getParent.args, p.Templates.MultiComment) local errorCategories = err and utilsMarkup.categories(err.categories) or "" local result = p.multiComment(frame.args[1], frame.args[2], args.quotes, args.singleQuote) return result..errorCategories end

function p.main(args) local cType = args[1] -- "Comment Type," The template that is being called (Fi, Midna, Navi, etc.) This is typically set by default on every template to decrease user error, but some templates (like Template:Manual) allow for this to be changed to relate to different games. local cSubject = args[2] -- "Comment Subject," The header for the comment (Stalfos, Green Rupee, Zelda, etc.) Pulls from parameter 1 (or 2 if Template:Manual is used). local cContent = args[3] -- "Comment Content," The quote that is displayed in the comment. Pulls from parameter 2 (or 3 if Template:Manual is used) and automatically surrounds it with qutotation marks.

--The following comment types all regard Character comments in-game. These usually regard Link's partner or other character that gives general information on certain subjects, like a "tutorial" guide. Each of these characters have their own template, and the cType parameter is automatically set for every usage of the template. if (cType == "Fi") then --for Template:Fi (Skyward Sword) local targetLock = Color.color("SSHD White", "Target lock:") local subject = Color.color("SSHD Blue", cSubject) local content = Color.color("SSHD White", cContent) returnTable = string.format("Fi's Comment: \n{|\n|\n|%s %s \"%s\"\n|}  ", targetLock, subject, content)

elseif (cType == "Fishman") then --for Template:Fishman (The Wind Waker) returnTable = string.format("Fishman's Comment: \n{|\n|\n|%s \"%s\"\n|}  ", cSubject, cContent)

elseif (cType == "Happy Mask Salesman") then --for Template:Happy Mask Salesman (Majora's Mask) returnTable = string.format("The Happy Mask Salesman's Comment: \n{|\n|\n|%s \"%s\"\n|}  ", cSubject, cContent) elseif (cType == "Madame Couture") then --for Template:Madame Couture (Tri Force Heroes) returnTable = string.format("Madame Couture's Comment: \n{|\n|\n|<span style=\"font-size: 130%%; font-weight: bold;\">%s \"%s\"\n|}  ", cSubject, cContent) elseif (cType == "Midna") then --for Template:Midna (Twilight Princess) local content = Color.color("TPHD Midna Blue", cContent) returnTable = string.format("<div class=\"toccolours mw-collapsible\" data-expandtext=\"show comment ▼\" data-collapsetext=\"hide comment ▲\"><div style=\"font-size: 105%%\">Midna's Comment: <div class=\"mw-collapsible-content\" style=\"border-radius: 25px; border: 6px solid ; background-color: ; display: flex\">\n{|\n|\n|<span style=\"font-size: 130%%; font-weight: bold;\">%s \"%s\"\n|}  ", cSubject, content)

elseif (cType == "Monita") then --for Template:Monita (Nintendo Land) returnTable = string.format("<div class=\"toccolours mw-collapsible\" data-expandtext=\"show comment ▼\" data-collapsetext=\"hide comment ▲\"><div style=\"font-size: 105%%\">Monita's Comment: <div class=\"mw-collapsible-content\" style=\"border-radius: 25px; border: 6px solid ; background-color: ; display: flex\">\n{|\n|\n|<span style=\"font-size: 130%%; font-weight: bold;\">%s \"%s\"\n|}  ", cSubject, cContent)

elseif (cType == "Navi") then --for Template:Navi (Ocarina of Time) returnTable = string.format("<div class=\"toccolours mw-collapsible\" data-expandtext=\"show comment ▼\" data-collapsetext=\"hide comment ▲\"><div style=\"font-size: 105%%\">Navi's Comment: <div class=\"mw-collapsible-content\" style=\"border-radius: 25px; border: 6px solid ; background-color: ; display: flex\">\n{|\n|\n|<span style=\"font-size: 130%%; font-weight: bold;\">%s \"%s\"\n|}  ", cSubject, cContent)

elseif (cType == "Tatl") then --for Template:Tatl (Majora's Mask) returnTable = string.format("<div class=\"toccolours mw-collapsible\" data-expandtext=\"show comment ▼\" data-collapsetext=\"hide comment ▲\"><div style=\"font-size: 105%%\">Tatl's Comment: <div class=\"mw-collapsible-content\" style=\"border-radius: 25px; border: 6px solid ; background-color: ; display: flex\">\n{|\n|\n|<span style=\"font-size: 130%%; font-weight: bold;\">%s \"%s\"\n|}  ", cSubject, cContent)

elseif (cType == "Tingle") then --for Template:Tingle (the Wind Waker [not HD]) returnTable = string.format("<div class=\"toccolours mw-collapsible\" data-expandtext=\"show comment ▼\" data-collapsetext=\"hide comment ▲\"><div style=\"font-size: 105%%\">Tingle's Comment: <div class=\"mw-collapsible-content\" style=\"border-radius: 25px; border: 6px solid ; background-color: ; display: flex\">\n{|\n|\n|<span style=\"font-size: 130%%; font-weight: bold;\">%s \"%s\"\n|}  ", cSubject, cContent) --The following is for Template:Manual. On each page, the editor enters and the Game abbreviation replaces the "cType" variable, which was automatically set on the previous templates.

elseif (cType == "TLoZ") then --for The Legend of Zelda manual returnTable = string.format("<div class=\"toccolours mw-collapsible\" data-expandtext=\"show comment ▼\" data-collapsetext=\"hide comment ▲\"><div style=\"font-size: 105%%\">The Legend of Zelda Manual Comment: <div class=\"mw-collapsible-content\" style=\"border-radius: 25px; border: 6px solid ; background-color: ; display: flex\">\n{|\n|\n|<span style=\"font-size: 130%%; font-weight: bold;\">%s \"%s\"\n|}  ", cSubject, cContent)

elseif (cType == "TAoL") then --for The Adventure of Link manual returnTable = string.format("<div class=\"toccolours mw-collapsible\" data-expandtext=\"show comment ▼\" data-collapsetext=\"hide comment ▲\"><div style=\"font-size: 105%%\">The Adventure of Link Manual Comment: <div class=\"mw-collapsible-content\" style=\"border-radius: 25px; border: 6px solid ; background-color: ; display: flex\">\n{|\n|\n|<span style=\"font-size: 130%%; font-weight: bold;\">%s \"%s\"\n|}  ", cSubject, cContent) elseif (cType == "ZG&W") then --for the Zelda (Game & Watch) manual returnTable = string.format("<div class=\"toccolours mw-collapsible\" data-expandtext=\"show comment ▼\" data-collapsetext=\"hide comment ▲\"><div style=\"font-size: 105%%\">Zelda (Game & Watch) Manual Comment: <div class=\"mw-collapsible-content\" style=\"border-radius: 25px; border: 6px solid ; background-color: ; display: flex\">\n{|\n|\n|<span style=\"font-size: 130%%; font-weight: bold;\">%s \"%s\"\n|}  ", cSubject, cContent)

elseif (cType == "ALttP") then --for the A Link to the Past manual returnTable = string.format("<div class=\"toccolours mw-collapsible\" data-expandtext=\"show comment ▼\" data-collapsetext=\"hide comment ▲\"><div style=\"font-size: 105%%\">A Link to the Past Manual Comment: <div class=\"mw-collapsible-content\" style=\"border-radius: 25px; border: 6px solid ; background-color: ; display: flex\">\n{|\n|\n|<span style=\"font-size: 130%%; font-weight: bold;\">%s \"%s\"\n|}  ", cSubject, cContent) elseif (cType == "ALttPGBA") then --for the A Link to the Past portion of the A Link to the Past & Four Swords manual returnTable = string.format("<div class=\"toccolours mw-collapsible\" data-expandtext=\"show comment ▼\" data-collapsetext=\"hide comment ▲\"><div style=\"font-size: 105%%\">A Link to the Past (Game Boy Advance) Manual Comment: <div class=\"mw-collapsible-content\" style=\"border-radius: 25px; border: 6px solid ; background-color: ; display: flex\">\n{|\n|\n|<span style=\"font-size: 130%%; font-weight: bold;\">%s \"%s\"\n|}  ", cSubject, cContent)

elseif (cType == "LA") then --for the Link's Awakening manual returnTable = string.format("<div class=\"toccolours mw-collapsible\" data-expandtext=\"show comment ▼\" data-collapsetext=\"hide comment ▲\"><div style=\"font-size: 105%%\">Link's Awakening Manual Comment: <div class=\"mw-collapsible-content\" style=\"border-radius: 25px; border: 6px solid ; background-color: ; display: flex\">\n{|\n|\n|<span style=\"font-size: 130%%; font-weight: bold;\">%s \"%s\"\n|}  ", cSubject, cContent)

elseif (cType == "OoT") then --for the Ocarina of Time manual returnTable = string.format("<div class=\"toccolours mw-collapsible\" data-expandtext=\"show comment ▼\" data-collapsetext=\"hide comment ▲\"><div style=\"font-size: 105%%\">Ocarina of Time Manual Comment: <div class=\"mw-collapsible-content\" style=\"border-radius: 25px; border: 6px solid ; background-color: ; display: flex\">\n{|\n|\n|<span style=\"font-size: 130%%; font-weight: bold;\">%s \"%s\"\n|}  ", cSubject, cContent)

elseif (cType == "MM") then --for the Majora's Mask manual returnTable = string.format("<div class=\"toccolours mw-collapsible\" data-expandtext=\"show comment ▼\" data-collapsetext=\"hide comment ▲\"><div style=\"font-size: 105%%\">Majora's Mask Manual Comment: <div class=\"mw-collapsible-content\" style=\"border-radius: 25px; border: 6px solid ; background-color: ; display: flex\">\n{|\n|\n|<span style=\"font-size: 130%%; font-weight: bold;\">%s \"%s\"\n|}  ", cSubject, cContent) elseif (cType == "OoS") then --for the Oracle of Seasons manual returnTable = string.format("<div class=\"toccolours mw-collapsible\" data-expandtext=\"show comment ▼\" data-collapsetext=\"hide comment ▲\"><div style=\"font-size: 105%%\">Oracle of Seasons Manual Comment: <div class=\"mw-collapsible-content\" style=\"border-radius: 25px; border: 6px solid ; background-color: ; display: flex\">\n{|\n|\n|<span style=\"font-size: 130%%; font-weight: bold;\">%s \"%s\"\n|}  ", cSubject, cContent) elseif (cType == "OoA") then --for the Oracle of Ages manual returnTable = string.format("<div class=\"toccolours mw-collapsible\" data-expandtext=\"show comment ▼\" data-collapsetext=\"hide comment ▲\"><div style=\"font-size: 105%%\">Oracle of Ages Manual Comment: <div class=\"mw-collapsible-content\" style=\"border-radius: 25px; border: 6px solid ; background-color: ; display: flex\">\n{|\n|\n|<span style=\"font-size: 130%%; font-weight: bold;\">%s \"%s\"\n|}  ", cSubject, cContent) elseif (cType == "FS") then --for the Four Swords portion of the A Link to the Past & Four Swords manual returnTable = string.format("<div class=\"toccolours mw-collapsible\" data-expandtext=\"show comment ▼\" data-collapsetext=\"hide comment ▲\"><div style=\"font-size: 105%%\">Four Swords Manual Comment: <div class=\"mw-collapsible-content\" style=\"border-radius: 25px; border: 6px solid ; background-color: ; display: flex\">\n{|\n|\n|<span style=\"font-size: 130%%; font-weight: bold;\">%s \"%s\"\n|}  ", cSubject, cContent) elseif (cType == "FSA") then --for the Four Swords Adventures manual returnTable = string.format("<div class=\"toccolours mw-collapsible\" data-expandtext=\"show comment ▼\" data-collapsetext=\"hide comment ▲\"><div style=\"font-size: 105%%\">Four Swords Adventures Manual Comment: <div class=\"mw-collapsible-content\" style=\"border-radius: 25px; border: 6px solid ; background-color: ; display: flex\">\n{|\n|\n|<span style=\"font-size: 130%%; font-weight: bold;\">%s \"%s\"\n|}  ", cSubject, cContent) elseif (cType == "TMC") then --for the The Minish Cap manual returnTable = string.format("<div class=\"toccolours mw-collapsible\" data-expandtext=\"show comment ▼\" data-collapsetext=\"hide comment ▲\"><div style=\"font-size: 105%%\">The Minish Cap Manual Comment: <div class=\"mw-collapsible-content\" style=\"border-radius: 25px; border: 6px solid ; background-color: ; display: flex\">\n{|\n|\n|<span style=\"font-size: 130%%; font-weight: bold;\">%s \"%s\"\n|}  ", cSubject, cContent) elseif (cType == "ST") then --for the Spirit Tracks manual returnTable = string.format("<div class=\"toccolours mw-collapsible\" data-expandtext=\"show comment ▼\" data-collapsetext=\"hide comment ▲\"><div style=\"font-size: 105%%\">Spirit Tracks Manual Comment: <div class=\"mw-collapsible-content\" style=\"border-radius: 25px; border: 6px solid ; background-color: ; display: flex\">\n{|\n|\n|<span style=\"font-size: 130%%; font-weight: bold;\">%s \"%s\"\n|}  ", cSubject, cContent)

elseif (cType == "LCT") then --for the Link's Crossbow Training manual returnTable = string.format("<div class=\"toccolours mw-collapsible\" data-expandtext=\"show comment ▼\" data-collapsetext=\"hide comment ▲\"><div style=\"font-size: 105%%\">Link's Crossbow Training Manual Comment: <div class=\"mw-collapsible-content\" style=\"border-radius: 24px; border: 6px solid ; background-color: ; display: flex\">\n{|\n|\n|<span style=\"font-size: 130%%; font-weight: bold;\">%s \"%s\"\n|}  ", cSubject, cContent)

else --Activates when someone enters an invalid value for "cType" utilsError.warn(string.format("%s is not a valid game, see here for all usable games. If this is a mistake, please contact a staff member on the Discord server.", cType)) end return returnTable end

function p.multiComment(game, commenter, quotes, singleQuote) local categories = "" if singleQuote then quotes = { { quote = singleQuote } }		utilsError.warn(" parameter is deprecated. Please use   instead.") categories = categories.."" end if #quotes == 0 then utilsError.warn("Please provide at least one quote.") categories = categories.."" return categories end local comments = #quotes == 1 and "comment" or "comments" local showComments = string.format("show %s's %s ▼", commenter, comments) local hideComments = string.format("hide %s's %s ▲", commenter, comments) local img = File.gameImage(game, commenter, "Icon", {		checkExists = false,		size = COMMENTER_IMAGE_SIZE,		link = commenter,	})

-- Class name use BEM syntax https://getbem.com/ local container = mw.html.create("div") :addClass("mw-collapsible comments") :attr("data-expandtext", showComments) :attr("data-collapsetext", hideComments) -- if #quotes > 3 then -- 	container:addClass("mw-collapsed") -- end local content = container:tag("div") :addClass("mw-collapsible-content comments__content") for i, quote in ipairs(quotes) do		if quote.context then content:tag("span") :addClass("comments__quote-context") :wikitext(quote.context) end if i == 1 then content:tag("div") :addClass("comments__commenter") :wikitext(img) end local coloredQuote = Cite.color(quote.quote, commenter, game) content:tag("div") :addClass("comments__quote-bubble comments__quote-bubble--"..string.lower(commenter)) :wikitext(coloredQuote) if i ~= #quotes then content:tag("div") :addClass("comments__spacer") :attr("aria-hidden", "true") end end local result = tostring(container) return result..categories end

p.Templates = { MultiComment = { wip = true, format = "block", repeatedGroup = { name = "quotes", params = {"quote", "context"}, counts = {1, 2, 3, 4, 5, 6, 7, 8}, },		params = { [1] = {				name = "subject", type = "string", deprecated = true, -- Displaying the subject name is redundant - the subject is obvious from context inline = true, },			[2] = {				name = "singleQuote", type = "string", desc = "Use  instead.", deprecated = true, inline = true, },			quote = { required = true, type = "content", desc = string.format("The complete description given by %s on the subject, quoted verbatim. Use Template:Color, Template:Player Name, and Template:Typo as needed.", mw.title.getCurrentTitle.baseText), trim = true, nilIfEmpty = true, },			context = { type = "string", desc = "A description of where or when the quote appears. Only needed when there are multiple quotes in different contexts. Generally not needed for the first quote.", type = "string", trim = true, nilIfEmpty = true, },		},	} }

return p