Cuberite Forum
WebAdmin doesn't display correct content - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Plugins (https://forum.cuberite.org/forum-1.html)
+--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html)
+--- Thread: WebAdmin doesn't display correct content (/thread-2940.html)



WebAdmin doesn't display correct content - Mcpg - 04-15-2017

Hi,

I'm actually creating a plugin for Cuberite. I wanted to create web admin pages for it, so, like Cuberite's LUA API says, I wrote this code:

Code:
   cWebAdmin.AddWebTab("Example", "example1", function(a_Request, a_UrlPath)
       return "asd", "text/html; charset=utf-8"
   end)


But it wasn't working (3rd argument should be string, not function (incorrect docs?Big Grin)). So, I've tried something like this:
Code:
   cWebAdmin.AddWebTab("Example", "example1", "example2", function(a_Request, a_UrlPath)
       return "asd", "text/html; charset=utf-8"
   end)

And, now "example1" appeared in the webadmin.
But, instead of "asd", webpage displays exactly the same content, as for Home. Maybe it's a bug, or I'm an idiot? ^^

Thank you for your help. Smile


RE: WebAdmin doesn't display correct content - xoft - 04-16-2017

Hello, welcome to the forum.

You're calling the function wrong, it should be
cWebAdmin:AddWebTab(...)  -- Note the colon instead of dot!
Then the parameters will match what the API docs say (the cWebAdmin itself is the first hidden parameter, like "this" in C++).


RE: WebAdmin doesn't display correct content - Mcpg - 04-16-2017

Oh, I forgot about it. Too much Java... :D

But still instead of "asd", Home page is displaying. Even I added LOG("dadadda") into handler and it's not displaying in console. I'm just doing something really wrong... Even this obsolete method with Plugin:AddWebTab() is not working...


RE: WebAdmin doesn't display correct content - xoft - 04-16-2017

That's strange, I tried your exact code in the Debuggers plugin and it works for me.
function Initialize(a_Plugin)
	-- Other unrelated code
	cWebAdmin:AddWebTab("Example", "example1", function(a_Request, a_UrlPath)
		return "asd", "text/html; charset=utf-8"
	end)
	-- Other unrelated code
end

Are you sure you reloaded the plugin (or restarted the server) so that the code changes were applied? Could you post your entire plugin source so that we can have a look?


RE: WebAdmin doesn't display correct content - Mcpg - 04-16-2017

Ekhm, it seems that Cuberite doesn't like spaces in plugin names... Alright, I fixed it by removing space from name of the plugin...

Anyway, thank you for help!Big Grin