-
Notifications
You must be signed in to change notification settings - Fork 14
Widgets
Widgets are high-level abstractions, pieces using which Pages are built.
From developer's view widget is a directory located in resources
and called WIDGET_NAME
where WIDGET_NAME
is widget's unique name. It should have the following layout:
- widget.json (required, contains the most important descriptional information about widget. Example for summator widget:
{
"description": "Description of widget \"summator\"",
"schema": {
"type": "object",
"title": "Summator settings",
"properties": {
"title": {
"type": "string",
"title": "Widget title"
},
"a": {
"type": "integer",
"title": "Default value for first input"
},
"b": {
"type": "integer",
"title": "Default value for second input"
},
"aDisabled": {
"type": "boolean",
"title": "Should first field be disabled?"
}
}
}
}
- widget.html (optional)
- widget.js (optional)
- icon.png (optional small icon)
- screnshots/ (optional directory with screenshot examples)
When the widget archive is uploaded using PUT-request to address /widgets/WIDGET_NAME
it should be unzipped into /resources/widgets/WIDGET_NAME
. All files should be checked to be safe (there should be a white-list of allowed file extensions: image files, text files, *.js, *.css, *.html, *.txt files and probably a few others. Java code uploading should be strictly prohibited!
When the widget is uploaded widget.json
should be merged into resources/widgets.json
in the following way:
- new properties are added to the
widget.json's
JOSN-object:nohtml: true
if there is nowidget.html
file,widget.js
if there is no main JS file,noicon: true
, if there is no icon.
Example for title widget. Original
{
"description": "Description of widget \"title\"",
"schema": {
"type": "object",
"title": "Title widget",
"properties": {
"title": {
"title": "Set title",
"type": "string"
}
}
}
}
Resulting:
{
"description": "Description of widget \"title\"",
"nojs": true,
"schema": {
"type": "object",
"title": "Title widget",
"properties": {
"title": {
"title": "Set title",
"type": "string"
}
}
}
}
-
widget.json's
JSON object is wrapped into another JSON object like this:{ "WIDGET_NAME": OLD_JSON_OBJECT }
- resulting json is merged with existing JSON-object located in
widgets.json
with the logic identical to (angular.merge
orjQuery.extend
).
All the paths are relative to src/main/webapp
.