Zelda Wiki

OoT Navi.png

Hey! Listen!

This wiki contains spoilers! Read at your own risk!

READ MORE

Zelda Wiki
Advertisement
Zelda Wiki
10,305
pages

Documentation for this module may be created at Module:Cite/Documentation

local Color = require("Module:Color")
local Franchise = require("Module:Franchise")
local Term = require("Module:Term")
local utilsArg = require("Module:UtilsArg")
local utilsError = require("Module:UtilsError")
local utilsMarkup = require("Module:UtilsMarkup")
local utilsString = require("Module:UtilsString")

local p = {}

function p.Main(frame)
	local args, err = utilsArg.parse(frame:getParent().args, p.Templates.Cite)
	local result = p.printGameCitation(args.quote, args.source, args.plural, args.game, args.version)
	if err then
		result = result .. utilsMarkup.categories(err.categories)
	end
	return result
end

function p.printGameCitation(quote, source, plural, game, version)
	local gameLink = game and Franchise.link(game)
	local sourceDisplay = source or ""
	if gameLink and source ~= "N/A" then -- if gameLink is not null here, it means `game` should be a valid term context
		sourceDisplay = Term.printTerm({
			page = source,
			game = game,
			link = "link",
		}, plural, true)
	end
	local categories = ""
	if not gameLink and not utilsMarkup.containsLink(game or "") and mw.title.getCurrentTitle().nsText ~= "MediaWiki" then --MediaWiki is excluded or else this matches MediaWiki:Gadget-EditToolbarButtons.js for some reason
		utilsError.warn(utilsMarkup.code(mw.dumpObject(game)) .." is neither a valid [[Data:Franchise|code]] nor an interwiki link.")
		categories = "[[Category:Pages with Invalid Arguments]]"
	end
	if game and Franchise.hasRemakes(game) then
		categories = categories .. "[[Category:Pages Citing Games with Remakes]]"
	end
	
	local sourceWithContext
	if version then
		sourceWithContext = string.format("%s (%s, %s)", sourceDisplay, gameLink or utilsMarkup.italic(game), version)
	else
		sourceWithContext = string.format("%s (%s)", sourceDisplay, gameLink or utilsMarkup.italic(game))
	end
	if mw.title.getCurrentTitle().nsText ~= "User" then
		sourceWithContext = sourceWithContext .. categories
	end
	
	if utilsString.isEmpty(quote) then
		return sourceWithContext
	end
	
	local quoteDisplay
	if game and source then
		quoteDisplay = utilsMarkup.italic(Color.dialogue(game, source, quote))
	else
		quoteDisplay = utilsMarkup.italic(quote)
	end
	
	local result = string.format('"%s" — %s', quoteDisplay, sourceWithContext)
	return result
end

p.Templates = {
	Cite = {
		purpose = "Citing in-game text. For more information, see [[Guidelines:References]].",
		format = "inline",
		paramOrder = {1, 2, "plural", 3, 4},
		params = {
			[1] = {
				name = "quote",
				required = true,
				type = "content",
				desc = "The text to cite. Generally speaking, one should quote the [[Guidelines:Canon#Version Differences|latest remake]] of a game."
			},
			[2] = {
				name = "source",
				required = true,
				type = "string",
				desc = "The source of the in-game text. Usually this is a speaking character. For written text, cite the source as being text itself if it has a name, otherwise cite its author. A [[:Category:Menus|menu screen]] can also be a source. If the text corresponds to in-game narration, use <code>N/A</code>. If <code>game</code> is a valid game code, then <code>source</code> is treated as a [[Template:Term|term]] subject (unless it's <code>N/A</code>).",
			},
			plural = {
				type = "boolean",
				desc = "Typing <code>yes</code> in this field causes <code>speaker</code> to be [[Template:Plural|pluralized]], if it is a valid term.",
				canOmit = true,
				trim = true,
				nilIfEmpty = true,
			},
			[3] = {
				name = "game",
				required = true,
				type = "string",
				desc = "A [[Data:Franchise|game code]]. If no such game exists at [[Data:Franchise]] (i.e. any third-party game outside the ''Zelda'' franchise), this field will instead be treated as plain wikitext. In this case, an interwiki link must be used."
			},
			[4] = {
				name = "version",
				type = "content",
				desc = "Can be used to specify a port, game mode, or localization of the game.",
				canOmit = true,
			},
		},
		examples = {
			{
				desc = "A regular citation. Note that <code>version</code> is not to be used when citing American English text, nor when citing a remake.",
				args = {"Leave these {{Color|TPHD Red|woods}} and go to the {{Color|TPHD Red|east}}, where you will find the land protected by {{Color|TPHD Red|the spirit Eldin}}.", "Faron (Spirit)", "TPHD"},
			},
			{
				desc = "For some games and sources, the default text color changes to match the in-game color",
				args = {"Its skin and clothing differ due to its hailing from a different environment, but it still has the same fixation with exotic undergarments.", "Fi", "SS"},
			},
			{
				desc = "Citing a plural term.",
				args = {"'''Cryonis<br>Create a pillar of ice from a water surface.'''<br>Builds ice pillars that are very stable. These pillars can be used as {{Color|BotW Red|stepping stones}} or as {{Color|BotW Red|obstacles}}. Use Cryonis on an ice pillar to {{Color|BotW Red|break}} it.", "Rune", plural = "yes", "BotW"},
			},
			{
				desc = "Invalid terms are marked accordingly.",
				args = {"Lorem ipsum", "Not a Real Term", "BotW"},
			},
			{
				desc = "<code>N/A</code> is not counted as a term.",
				args = {"This is but one of the legends of which the people speak...", "N/A", "TWWHD"},
			},
			{
				desc = "Citing menu screens is sometimes necessary.",
				args = {"'''{{Big|Akkala Highlands}}'''", "Map", "BotW"},
			},
			{
				desc = "When citing written text which has a valid term, use that term instead of the author's name.",
				args = {"Today, I told everything to Mikau, the one person whom I didn't want to know about it. At first, I was too embarrassed and too sad to do anything. And with the words that Mikau said at that moment, I felt that all hope had been lost. But please, Mikau, I'm begging you, don't do anything rash.", "Lulu's Diary", "MM3D"},
			},
			{
				desc = "Citing an alternate version/game mode. Citations of outdated game versions are marked with a maintenance category, as they are generally to be avoided.",
				args = {"Leave these {{Color|TPHD Red|woods}} and go to the {{Color|TPHD Red|west}}, where you will find the land protected by {{Color|TPHD Red|the spirit Eldin}}.", "Faron (Spirit)", "TP", "Wii version"},
			},
			{
				desc = "Citing the Japanese version of a game.",
				args = {"{{Romanize|その剣は、魔を撃退する{{Color|#ff6b00|退魔の剣}} であると同時に、 我が魔族を封じていた、いまいましい{{Color|TWW Vermilion|封印}} そのものなのだよ!|Sono Ken wa, Ma o Gekitai suru Taima no Kendearu to Dōjini, Waga Mazoku o Fūjite ita, imaimashī Fūin sonomonona noda yo!|That sword is the Anti-Demon Sword that repels demons. However, it is also the annoying seal that was sealing my demon tribe.|3}}", "Ganondorf", "TWW", "Japanese version"} 
			},
			{
				desc = "Citing a non-Zelda game with Zelda references",
				args = {"Tired of pixies asking you to listen?", "N/A", "{{Ip|Kid Icarus: Uprising}}"}
			},
			{
				desc = "Citing a game that is neither a valid code nor a link is considered an error.",
				args = {"Bla bla bla", "N/A", "notARealGame"},
			},
		}
	}
}

return p
Advertisement