Article Size

Define rules for size of article. Including number of characters, range of amount of images or other content objects.

Plugin configuration

{
    "id": "io.infomaker.articlesize",
    "name": "im-articlesize",
    "url": "https://plugins.writer.infomaker.io/v1/infomaker/im-articlesize/{PLUGIN_VERSION}/index.js",
    "style": "https://plugins.writer.infomaker.io/v1/infomaker/im-articlesize/{PLUGIN_VERSION}/style.css",
    "enabled": true,
    "mandatory": false,
    "data": {
        "sizes": [
            {
                "name": "small",
                "rules": {
                    "characters": 500,
                    "elements": [
                        {
                            "type": "x-im/image",
                            "count": 2
                        },
                        {
                            "type": "x-im/teaser",
                            "count": 1
                        },
                        {
                            "type": "headline",
                            "count": 1,
                            "characters": 5,
                        },
                        {
                            "type": "body",
                            "count": 2
                        }
                    ]
                }
            },
            {
                "name": "medium",
                "rules": {
                    "characters": [500, 1000],
                    "elements": [
                        {
                            "type": "x-im/image",
                            "count": [2, 3]
                        },
                        {
                            "type": "x-im/teaser",
                            "count": 1
                        },
                        {
                            "type": "x-im/imagegallery",
                            "count": 1
                        },
                        {
                            "type": "headline",
                            "count": 1
                            "characters": [5, 100],
                        },
                        {
                            "type": "body",
                            "count": 5
                        }
                    ]
                }
            }
        ],
        "typeLabels": [
            {
                "type": "x-im/image",
                "singular": {
                    "en": "Image",
                    "sv": "Bild"
                },
                "plural": {
                    "en": "Images",
                    "sv": "Bilder"
                }
            }
        ]
    }
}
Property Type Required Description
sizes Array true Size definitions array
typeLabels Array false Translated labels for element types as defined in size -> rules -> elements. Requires both singular and plural label

sizes configuration

This is an example of object configuration property description.

{
    "name": "medium",
    "rules": {
        "characters": 1000,
        "elements": [
            {
                "type": "x-im/image",
                "count": [1, 3]
            },
            {
                "type": "headline",
                "count": 1
            },
            {
                "type": "body",
                "count": 5
            }
        ]
    }
}
Property Type Required Description
name String true Name of size. Must conform to value set in metadata link. See below
rules Object true Definition for elements and character count rules

name property

Article size is set using a link-element in itemMeta which has rel="content-size". The property name in size definition
must be the same as the last part of the uri-property in this link.

Link found in xml:

<link rel="content-size" title="XL" type="x-im/contentsize" uri="im://content-size/article/xlarge"/>

Name for rule in this plugin's configuration should be set to "xlarge".

rules object

Rules object include the property characters and elements. Use characters to set a minimum value, or a range, for character length in article.
elements is a list of rules that look for elements in the article using a type-property, and the minimum count, or range, for that element type.

For instance the following rule:

{
    "type": "x-im/image",
    "count": 2
}

Will look for xml elements with type="x-im/image" in the content section of the article, and the rule will be valid if there are two or more images found.

In contrast, this rule:

{
    "type": "x-im/image",
    "count": [1, 3]
}

Will look for xml elements with type="x-im/image" and the rule is valid only if there are exactly 1, 2, or 3 images.

Headline and Paragraph length

Headline and paragraph both support setting a characters property to a number och an array (range) of values. This will be used to compare against to see if matching element is valid or not. If this property is not included min length for both will be 1.

{
    "type": "headline",
    "count": 1,
    "characters": [
        2,
        100
    ]
},
{
    "type": "body",
    "count": 5,
    "characters": 2
}

typeLabels configuration

Example typeLabel configuration:

[
    {
        "type": "x-im/image",
        "singular": {
            "en": "Image",
            "sv": "Bild"
        },
        "plural": {
            "en": "Images",
            "sv": "Bilder"
        }
    }
]

This property can be used to add translations for element types that do not already exist, for instance teasers or contentparts with custom types.
Both singular and plural values must be present or the label is ignored.

Default Types

Article Size Plugin contains Swedish and English translations for most first party element types, see list below.

Content Objects

Text Elements

Output

Plugin has no XML output.