The options plugin provides a list of options of a configurable type.
Options are specified, in the writer client configuration file, as a specific type. Each type has a configurable number
of options to choose from.
{
"id": "io.infomaker.options",
"name": "im-options",
"url": "https://plugins.writer.infomaker.io/v1/infomaker/im-options/{PLUGIN_VERSION}/index.js",
"enabled": true,
"mandatory": false,
"data": {"options": {
"type": "toggle",
"label": "Article options",
"link": {
"rel": "articleoptions",
"type": "x-im/articleoptions"
},
"multivalue": true,
"values": [
{
"uri": "im://articleoptions/premium",
"title": "Premium"
},
{
"uri": "im://articleoptions/facebok",
"title": "Facebook"
},
{
"uri": "im://articleoptions/instagram",
"title": "Instagram"
},
{
"title": "Article placement",
"uri": "im://articleoptions/tone",
"list": {
"type": "dropdown",
"label": "Article placement options",
"link": {
"rel": "articleoptions/placement",
"type": "x-im/articleoptions/placement"
},
"multivalue": false,
"values": [
{
"title": "- Please select placement -"
},
{
"uri": "im://articleoptions/placement/top",
"title": "Positive tone"
},
{
"uri": "im://articleoptions/tone/middle",
"title": "Neutral tone"
},
{
"uri": "im://articleoptions/tone/bottom",
"title": "Negative tone"
}
]
}
}
]
}}
}
The example above states a list of 4 toggable options. The multivalue
setting is set to true, which means that any of them may be selected.
The fourth option 'Article placement' has a sub-list defined with three options.
It's a dropdown style with setting multivalue
set to false, so only one of the items may be selected.
The first item does not have a uri
key, which means that it's a header and does not result in a link in the document.
The option plugin supports being defined multiple times in the configuration file so that
completely different options may be handled by this plugin. The id must be set to different values in order for this to function.
The name must be set to im-options in order for the plugin to register*.
{
"id": "io.infomaker.socialoptions",
"name": "im-options",
"url": "https://plugins.writer.infomaker.io/v1/infomaker/im-options/{PLUGIN_VERSION}/index.js",
"enabled": true,
"mandatory": true,
...
},
{
"id": "io.infomaker.articleoptions",
"name": "im-options",
"url": "https://plugins.writer.infomaker.io/v1/infomaker/im-options/{PLUGIN_VERSION}/index.js",
"enabled": true,
"mandatory": true,
...
},
The plugin supports three types of components for selecting values: dropdown-, toggle- and button components.
The dropdown component, configured with dropdown supports selecting a single value:
------------------------
| Choose something | V |
------------------------
...
"options": {
"type": "dropdown",
"label": "Article options",
"link": {
"rel": "articleoptions",
"type": "x-im/articleoptions"
},
"multivalue": false,
"values": [
{
"uri": "im://articleoptions/premium",
"title": "Premium"
},
...
The button component, configured with button stacks horizontally and supports selecting multiple values:
[Value 1] [Value 2] [Value 3]
[Value 4]
Buttons also have support for icons prepending the name. It is configured in the 'values' section, using the field 'icon'. The value
is any of the Font Awesome icons from http://fontawesome.io/icons/.
It is also possible to have an image icon, which is specified using the 'image' field in the value section.
...
"options": {
"type": "button",
"label": "Article options",
"link": {
"rel": "articleoptions",
"type": "x-im/articleoptions"
},
"multivalue": true,
"values": [
{
"uri": "im://articleoptions/premium",
"title": "Premium",
"icon" : "fa-star-o"
},
{
"uri": "im://articleoptions/priority",
"title": "Priority",
"image" : "data:image/svg+xml;base64,..."
},
...
The toggle component, configured with toggle stacks vertically and supports selecting multiple values:
[ O] Value 1
[O ] Value 2
[O ] Value 3
Toggle buttons also have support for icons prepending the title. It is configured in the 'values' section, using the field 'icon'. The value
is any of the Font Awesome icons from http://fontawesome.io/icons/.
It is also possible to have an image icon, which is specified using the 'image' field in the value section.
...
"options": {
"type": "toggle",
"label": "Article options",
"link": {
"rel": "articleoptions",
"type": "x-im/articleoptions"
},
"multivalue": true,
"values": [
{
"uri": "im://articleoptions/premium",
"title": "Premium",
"icon" : "fa-star-o"
},
{
"uri": "im://articleoptions/priority",
"title": "Priority",
"image" : "data:image/svg+xml;base64,..."
},
...
The plugin will add link
under newsItem > contentMeta > links
. Here's an example where a user marked the article as being 'premium' according to the example configuration above.
<newsItem>
<contentMeta>
<links xmlns="http://www.infomaker.se/newsml/1.0">
<link rel="articleoptions" title="Premium" type="x-im/articleoptions" uri="im://articleoptions/premium"/>
</links>
</contentMeta>
</newsItem>