Wowpedia

We have moved to Warcraft Wiki. Click here for information and the new URL.

READ MORE

Wowpedia
m (Ketho moved page Module:API info/type/widgetmethod to Module:API info/type/widget without leaving a redirect)
No edit summary
Line 3: Line 3:
 
local m = {}
 
local m = {}
   
function m.main(f)
+
local function GetGithubLink(search)
 
local item = {
local widget, method = f.args[1]:match("API (%w+) (%w+)")
 
local info = {}
 
local group1 = {}
 
table.insert(group1, {
 
 
icon = "GitHub_Octocat.png",
 
icon = "GitHub_Octocat.png",
 
text = "FrameXML",
 
text = "FrameXML",
url = string.format("https://github.com/Gethe/wow-ui-source/search?q=%s", method),
+
url = string.format("https://github.com/Gethe/wow-ui-source/search?q=%s", search),
})
+
}
  +
return item
  +
end
  +
  +
local function GetWowprogLink(apiType, widget, method)
 
local item = {
 
icon = "Wowprogramming.png",
 
text = "Wowprogramming",
  +
}
 
-- certain Region api are documented as VisibleRegion
 
-- certain Region api are documented as VisibleRegion
 
local wowprog_widget = wowprog_data[widget..":"..method]
 
local wowprog_widget = wowprog_data[widget..":"..method]
Line 18: Line 23:
 
widget = wowprog_widget
 
widget = wowprog_widget
 
end
 
end
table.insert(group1, {
 
icon = "Wowprogramming.png",
 
text = "Wowprogramming",
 
url = string.format("https://wowprogramming.com/docs/widgets/%s/%s.html", widget, method),
 
})
 
 
end
 
end
  +
if apiType == "widget" then
local items = {
 
  +
item.url = string.format("https://wowprogramming.com/docs/widgets/%s.html", widget)
  +
elseif apiType == "widgetmethod" then
 
item.url = string.format("https://wowprogramming.com/docs/widgets/%s/%s.html", widget, method)
  +
end
  +
return item
  +
end
  +
  +
function m.main(f)
  +
local apiType = f.args.t
  +
local pageName = f.args.name
  +
local wowprog_tbl, github_tbl
  +
if apiType == "widget" then
  +
local widget = pageName:match("UIOBJECT (%w+)")
  +
github_tbl = GetGithubLink(widget)
  +
wowprog_tbl = GetWowprogLink(apiType, widget)
  +
elseif apiType == "widgetmethod" then
 
local widget, method = pageName:match("API (%w+) (%w+)")
  +
github_tbl = GetGithubLink(method)
  +
wowprog_tbl = GetWowprogLink(apiType, widget, method)
  +
end
 
local source = {
 
"! Links",
 
"! Links",
  +
{github_tbl, wowprog_tbl},
group1,
 
 
}
 
}
return infobox_module:main(info, items)
+
return infobox_module:main({}, source)
 
end
 
end
   

Revision as of 14:03, 25 May 2022

Documentation for this module may be created at Module:API info/main/widget/doc

local infobox_module = require("Module:API_info/util/infobox")
local wowprog_data = mw.loadData("Module:API_info/wowprog/widgets")
local m = {}

local function GetGithubLink(search)
	local item = {
		icon = "GitHub_Octocat.png",
		text = "FrameXML",
		url = string.format("https://github.com/Gethe/wow-ui-source/search?q=%s", search),
	}
	return item
end

local function GetWowprogLink(apiType, widget, method)
	local item = {
		icon = "Wowprogramming.png",
		text = "Wowprogramming",
	}
	-- certain Region api are documented as VisibleRegion
	local wowprog_widget = wowprog_data[widget..":"..method]
	if wowprog_widget then
		if type(wowprog_widget) == "string" then
			widget = wowprog_widget
		end
	end
	if apiType == "widget" then
		item.url = string.format("https://wowprogramming.com/docs/widgets/%s.html", widget)
	elseif apiType == "widgetmethod" then
		item.url = string.format("https://wowprogramming.com/docs/widgets/%s/%s.html", widget, method)
	end
	return item
end

function m.main(f)
	local apiType = f.args.t
	local pageName = f.args.name
	local wowprog_tbl, github_tbl
	if apiType == "widget" then
		local widget = pageName:match("UIOBJECT (%w+)")
		github_tbl = GetGithubLink(widget)
		wowprog_tbl = GetWowprogLink(apiType, widget)
	elseif apiType == "widgetmethod" then
		local widget, method = pageName:match("API (%w+) (%w+)")
		github_tbl = GetGithubLink(method)
		wowprog_tbl = GetWowprogLink(apiType, widget, method)
	end
	local source = {
		"! Links",
		{github_tbl, wowprog_tbl},
	}
	return infobox_module:main({}, source)
end

return m