No edit summary |
No edit summary |
||
Line 20: | Line 20: | ||
{ |
{ |
||
id = "tly_globewut", |
id = "tly_globewut", |
||
⚫ | |||
icon = "Townlong-Yak_Globe", |
icon = "Townlong-Yak_Globe", |
||
url = "https://www.townlong-yak.com/globe/wut/#q:%s", |
url = "https://www.townlong-yak.com/globe/wut/#q:%s", |
||
⚫ | |||
}, |
}, |
||
{ |
{ |
||
id = "tly_apidocs", |
id = "tly_apidocs", |
||
⚫ | |||
icon = "Townlong-Yak_BAD", |
icon = "Townlong-Yak_BAD", |
||
url = "https://www.townlong-yak.com/framexml/latest/Blizzard_APIDocumentation#%s", |
url = "https://www.townlong-yak.com/framexml/latest/Blizzard_APIDocumentation#%s", |
||
⚫ | |||
show = function(v, apiType) |
show = function(v, apiType) |
||
if apiType == "a" then |
if apiType == "a" then |
||
Line 42: | Line 42: | ||
{ |
{ |
||
id = "gh_wowapiweb", |
id = "gh_wowapiweb", |
||
⚫ | |||
icon = "ProfIcons_engineering", |
icon = "ProfIcons_engineering", |
||
url = "https://mrbuds.github.io/wow-api-web/?search=%s", |
url = "https://mrbuds.github.io/wow-api-web/?search=%s", |
||
⚫ | |||
show = function(v, apiType) |
show = function(v, apiType) |
||
if apiType == "a" then |
if apiType == "a" then |
||
Line 72: | Line 72: | ||
{ |
{ |
||
id = "wowprog", |
id = "wowprog", |
||
⚫ | |||
icon = "Wowprogramming", |
icon = "Wowprogramming", |
||
url = "https://wowprogramming.com/docs/api/%s.html", |
url = "https://wowprogramming.com/docs/api/%s.html", |
||
⚫ | |||
show = function(v) return wowprog_data[v] end, |
show = function(v) return wowprog_data[v] end, |
||
url_params = function(v) |
url_params = function(v) |
Revision as of 07:32, 10 June 2021
Documentation for this module may be created at Module:API info/elink/doc
local bit = require "bit32"
local data = {
a = mw.loadData("Module:API_info/doc_api"),
--e = mw.loadData("Module:API_info/flavor_event"),
}
local event_doc = mw.loadData("Module:API_info/doc_event")
local wowprog_data = mw.loadData("Module:API_info/wowprog")
local m = {}
local ICON_FORMAT = "[[Image:%s.png|16px|link=%s]]"
local function GetApiBaseName(v)
if v:find("%.") then
v = v:match(".-%.(.+)")
end
return v
end
local links = {
{
id = "tly_globewut",
label = "Globe Wut",
icon = "Townlong-Yak_Globe",
url = "https://www.townlong-yak.com/globe/wut/#q:%s",
},
{
id = "tly_apidocs",
label = "Blizzard Docs",
icon = "Townlong-Yak_BAD",
url = "https://www.townlong-yak.com/framexml/latest/Blizzard_APIDocumentation#%s",
show = function(v, apiType)
if apiType == "a" then
if data.a[v] then
local flags = data.a[v].flags
return bit.band(flags, 0x2) > 0
end
elseif apiType == "e" then
return event_doc[v]
end
end,
},
{
id = "gh_wowapiweb",
label = "Offline /api",
icon = "ProfIcons_engineering",
url = "https://mrbuds.github.io/wow-api-web/?search=%s",
show = function(v, apiType)
if apiType == "a" then
if data.a[v] then
local flags = data.a[v].flags
return bit.band(flags, 0x2) > 0
end
elseif apiType == "e" then
return event_doc[v]
end
end,
url_params = function(v, apiType)
if apiType == "a" then
local apiName = GetApiBaseName(v)
local system = data.a[v].system
local params = string.format("api:%s:%s:%s", "function", apiName, system)
return params
elseif apiType == "e" then
local info = event_doc[v]
if info then
local params = string.format("api:%s:%s:%s", "event", info.Name, info.System)
return params
end
end
end,
},
{
id = "wowprog",
label = "Wowprogramming",
icon = "Wowprogramming",
url = "https://wowprogramming.com/docs/api/%s.html",
show = function(v) return wowprog_data[v] end,
url_params = function(v)
local old_name = wowprog_data[v]
local params = type(old_name) == "string" and old_name or v
return params
end,
},
}
function m:GetElinks(name, apiType)
local t = {}
for _, info in pairs(links) do
if not info.show or info.show(name, apiType) then
local params = info.url_params and info.url_params(name, apiType) or name
local url = info.url:format(params)
table.insert(t, {
icon = ICON_FORMAT:format(info.icon, url),
url = url,
text = info.label,
})
end
end
return t
end
return m