Module:API info/flavor

local bit = require "bit32" local data = { a = mw.loadData("Module:API_info/flavor/api"), e = mw.loadData("Module:API_info/flavor/event"), } local m = {}

-- cant use dots in github search -- https://docs.github.com/en/github/searching-for-information-on-github/searching-on-github/searching-code#considerations-for-code-search local function GetApiBaseName(v) if v:find("%.") then v = v:match(".-%.(.+)") end return v end

-- github forks are not searchable unless they have more stars, just cloned it instead -- https://stackoverflow.com/questions/33626326/how-to-search-a-github-fork-for-code-using-the-github-search-api local flavors = { {		id = 0x1, label = "retail", icon = "", url = "https://github.com/Gethe/wow-ui-source/search?q=%s", },	{ -- show bcc before classic_era id = 0x4, label = "bcc", icon = "", url = "https://github.com/Ketho/wow-ui-source-bcc/search?q=%s", },	{		id = 0x2, label = "classic_era", icon = "", url = "https://github.com/Ketho/wow-ui-source-classic-era/search?q=%s", }, }

function m:GetFlavors(name, apiType) local flags = data[apiType][name] if flags then local t = {} for _, v in pairs(flavors) do			if bit.band(flags, v.id) > 0 then local baseName = GetApiBaseName(name) local url = v.url:format(baseName) table.insert(t, {					icon = v.icon:format(url),					link = string.format("[%s %s]", url, v.label),				}) end end return t	end end

return m