01-30-2013, 06:08 AM
Another set of thoughts, this time on the webadmin and its interaction with the plugins. The current state of affair seems rather fragile and not flexible enough.
Current state:
==============
cWebPlugin implements web-related functions / callbacks
cPlugin_NewLua is also an instance of cWebPlugin
What we want:
=============
We want the following functionality:
Proposed solutions:
=============
cWebAdmin has two lists: Tabs and URL handlers. Callbacks for both can be registered. A tab has a name, title and content callback. An URL handler is simply a callback that may or may not provide content for an URL (?)
cWebAdmin parses each request. If it is for a regular WebAdmin page (URL with a specific prefix), it will create a regular WebAdmin interface page, with tabs, and call the specified tab's content callback to provide the content. If it isn't, it calls the URL handlers to provide the response contents. This way, a plugin can even turn MCServer into a webserver, serving e. g. local files (images in WebAdmin! )
cPluginManager bridges to cWebAdmin, providing means for plugins to register for both categories.
ManualBindings provides the binding between cPluginManager and Lua. cWebPlugin is removed. cPlugin and cPlugin_NewLua are removed from the Lua API.
New API functions:
Thoughts? Other than it's gonna be a hell to implement
Current state:
==============
cWebPlugin implements web-related functions / callbacks
cPlugin_NewLua is also an instance of cWebPlugin
What we want:
=============
We want the following functionality:
- Plugins can add tabs with custom contents to the WebAdmin interface
- Plugins can handle individual request URLs (ChatPlugin requests only chat messages in XML, etc.)
Proposed solutions:
=============
cWebAdmin has two lists: Tabs and URL handlers. Callbacks for both can be registered. A tab has a name, title and content callback. An URL handler is simply a callback that may or may not provide content for an URL (?)
cWebAdmin parses each request. If it is for a regular WebAdmin page (URL with a specific prefix), it will create a regular WebAdmin interface page, with tabs, and call the specified tab's content callback to provide the content. If it isn't, it calls the URL handlers to provide the response contents. This way, a plugin can even turn MCServer into a webserver, serving e. g. local files (images in WebAdmin! )
cPluginManager bridges to cWebAdmin, providing means for plugins to register for both categories.
ManualBindings provides the binding between cPluginManager and Lua. cWebPlugin is removed. cPlugin and cPlugin_NewLua are removed from the Lua API.
New API functions:
- cPluginManager:AddWebTab(TabName, TabTitle, ContentFunction)
- Adds the tab to WebAdmin, ContentFunction will be called each time tab content is requested
- function ContentFunction(TabName, URL[, params?]) - returns the content
- Adds the tab to WebAdmin, ContentFunction will be called each time tab content is requested
- cPluginManager:AddWebURLHandler(ContentFunction)
- Adds the URL handler, ContentFunction will be called each time URL content is requested
- function ContentFunction(URL[, params?]) - returns the content for the specified URL
- Adds the URL handler, ContentFunction will be called each time URL content is requested
Thoughts? Other than it's gonna be a hell to implement