-
Notifications
You must be signed in to change notification settings - Fork 0
markdown webserver plugin API
You can develop your own plugin for this application. On this page you find detailed information about this. WARNING! The plugin API (and this page) is still under development. The feature can be used but it is possible that the API will be changed.
The plugin loader can load your own plugin if you define it in a plugin.js
file in markdown-webserver-plugins
directory. You should create your own directory under markdown-webserver-plugins
and define your plugin.js
in it. Directories under your directory with name resources
will be served as static directory, so you should put your css
/ UI js
files here.
You can check an example in code base!
You must declare your own plugin class, and you must export an object of this class with module.exports
command.
Your class can have the following methods:
init(markdownWebserverPluginContext)
This method is called only once when the application is started. You should use the register methods of markdownWebserverPluginContext
here, since later the registered objects are not processed.
reload(markdownWebserverPluginContext)
This method is called if the directory which is served by the server is reloaded. Currently, this is done periodically after 5 minutes. You should use this method for reload your objects which are originated from the server core.
This part is not well documented, for further details you should check the code of the mentioned classes.
Objects you can use:
-
dirLoader
- this object contains the current content which is served by server. -
markdownWebserver
- the object of the server.
Methods you can call:
registerWidget(widget) @param { htmlString, widgetArea } widget
Registers a new widget. A widget is a custom html code which will be rendered in the given widget area.
As widget area a field of markdownWebserverPluginContext.widgetArea must be passed.
Currently there is only one field: LEFT_MAIN_TOP
. Widgets with this attribute will be rendered under site title.
registerUiScript(script) @param {path} script
Registers a new script, which will be rendered in head - part of result html.
registerStyle(style) @param {path} style
Registers a new stylesheet, which will be rendered in head - part of result html.
registerContentGenerator(generator) @param {*} generator
Registers a new content generator which will be executed during routing in application.
The given generator must be an object with a function named "contentGeneratorMethod" with a "path" attribute.