Module:API namespaces

From Warcraft Watch Secrets
Revision as of 14:23, 13 November 2022 by imported>Ketho (Blizzard_APIDocumentationGenerated)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:API namespaces/doc

-- used for https://wowpedia.fandom.com/wiki/Category:API_namespaces
-- see also https://wowpedia.fandom.com/wiki/Template:API_namespaces_subcategory
local m = {}

local HTML_LIST_START = '<ul class="plainlinks elinks">\n'
local HTML_LIST_ITEM = [=[<li style="padding-left: 0px"><span style="display:inline-block; width:20px; text-align:center">[[Image:%s.png|16px|link=]]</span> %s</li>
]=]
local HTML_LIST_END = '</ul>'

local links = {
	{
		icon = "Townlong-Yak_BAD",
		url = "https://www.townlong-yak.com/framexml/live/Blizzard_APIDocumentationGenerated/%s",
		text = "Blizzard API Docs",
	},
	{
		icon = "ProfIcons_engineering",
		url = "https://mrbuds.github.io/wow-api-web/?search=api:system:%s",
		text = "Offline /api addon",
	},
}

local function FormatLink(info, urlParam)
	local url = info.url:format(urlParam)
	local link = string.format("[%s %s]", url, info.text)
	return HTML_LIST_ITEM:format(info.icon, link)
end

local function GetElinkText(args)
	local s = HTML_LIST_START
	if args.filename then
		s = s..FormatLink(links[1], args.filename)
	end
	if args.system then
		s = s..FormatLink(links[2], args.system)
	end
	s = s..HTML_LIST_END
	return s
end

function m.main(f)
	return GetElinkText(f.args)
end

return m