First Steps
Get started with your plugin
Build a webserver
Every plugin in neleto is just a normal Webserver with some JSON REST endpoints. These endpoints can serve a variety of purposes. They can be used to manipulate rendered html before being sent to the client or cached, or they can define functions or helpers for the renderer itself. Here are the types (we're using typescript as an example, but you can build your plugin in any language):
Rewriter-endpoint
This endpoint can be specified under rewriter in your plugin.json.
// The body of the request this endpoint receives looks like this:
type Body = string;
// And the response needs to look like this:
type Response = string;
Helper-endpoint
This endpoint can be used in the array under helpers in your plugin.json.
// The body of the request this endpoint receives looks like this:
type Body = {
// the name of the helper called
name: string;
args: JsonValue[]; // any value that is valid json
// this is only there if this endpoint is specified as `block: true` in your `plugin.json` (this doesn't yet work)
// body?: string;
};
// And the response needs to look like this:
type Response = {
// any value that is valid json, this needs to match the VariableType in the
// `type` section of this helper-endpoint in your `plugin.json`
data: JsonValue;
};
Page-endpoint
This endpoint can be used in the array under pages in your plugin.json.
Page-endpoints are just normal endpoints which get the request directly forwarded from the client. They can also return anything, as they can also function as an api endpoint.
Admins and Developers can select a layout in the cms for every page-endpoint defined by plugins. When a page-endpoint has a layout selected, the request to that endpoint will be transformed into a POST request and the rendered layout will be included in the body of the request, the response will not be changed.
Api-endpoint
This endpoint can be used in the array under api in your plugin.json.
Api endpoints are similar to page-endpoints, except their access can be
controlled to only be accessible by logged in users with a specific role.
Api-endpoints are proxied through the cms backend with the route prefix
/api/rest/plugin/<plugin-name>/api. This means a route which your plugin
defines as /foo will be available under
/api/rest/plugin/<your-plugin-name>/api/foo. The query, body and request
method will not be modified when proxying the request, it will only check for
valid authentication and the correct user role.
Ui-endpoint
The ui-endpoint is similar to api-endpoints in that it is only accessible to
logged in users. The only difference is that the user role will not be checked
for this endpoint, and that it will be used to serve a custom admin ui for your
plugin. You can only define one ui-endpoint in your plugin.json, because this
one endpoint will be used as the entrypoint to the ui of your plugin inside an
iframe.
Your plugin server can listen on more than one endpoint and you can use links
to navigate between them, but these links will need to have the prefix
/api/rest/plugin/<your-plugin-name>/ui.