WebAdmin API thoughts
#1
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:
  • 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! Smile )
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
  • 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

Thoughts? Other than it's gonna be a hell to implement Wink
Reply
Thanks given by:


Messages In This Thread
WebAdmin API thoughts - by xoft - 01-30-2013, 06:08 AM
RE: WebAdmin API thoughts - by Taugeshtu - 01-30-2013, 06:37 AM
RE: WebAdmin API thoughts - by xoft - 01-30-2013, 06:47 AM
RE: WebAdmin API thoughts - by FakeTruth - 01-30-2013, 08:09 AM
RE: WebAdmin API thoughts - by xoft - 02-01-2013, 05:55 AM
RE: WebAdmin API thoughts - by FakeTruth - 02-01-2013, 07:05 AM



Users browsing this thread: 1 Guest(s)