Renditionable

QName: f:renditionable

Marks that an instance or type is to have one or more renditions.

Renditions are other nodes in the branch whose content is automatically generated and kept in sync as the source node is created, updated and deleted (or has its relevant attachment modified).

Configuration

Property Type Default Read-Only Description
schedule text Determines when renditions will be generated.
Either synchronous or asynchronous.
renditions object Defines the renditions that you would like to have generated. Each rendition is keyed with a name and provides a configuration that is passed to a rendition engine for execution.

Renditionable Example

Here is a node that has the f:renditionable feature enabled. The general form looks something like this:

{
    "title": "My Article",
    "longHeadline": "Cubs win the World Series in game 6 by a score of 201 to 3 in Wrigley Field, Chicago!",
    "mediumHeadline": "Cubs win World Series by score of 201 to 3!";
    "shortHeadline": "Cubs win World Series!";
    "_features": {
        "f:renditionable": {
            "renditions": {
                "{renditionKey}": {
                    "engineId": "{id of the renditioning engine to use}",
                    "targetNodeId": "{targetNodeId}",
                    "targetAttachmentId": "{targetAttachmentId}",
                    "targetAttachmentMimeType": "{targetAttachmentMimeType}",
                }
            }
        }
    }
}

The exact properties that should be specified depend on the requirements of the renditioning engine. Here is a more concrete example that executes a script to create the new node:

{
    "title": "My Article",
    "longHeadline": "Cubs win the World Series in game 6 by a score of 201 to 3 in Wrigley Field, Chicago!",
    "mediumHeadline": "Cubs win World Series by score of 201 to 3!";
    "shortHeadline": "Cubs win World Series!";
    "_features": {
        "f:renditionable": {
            "renditions": {
                "mobile": {
                    "engineId": "script",
                    "scriptNodeId": "custom:script1"
                }
            }
        }
    }
}

The script engine will run the JavaScript contained as the default attachment on the script node. The script node is identified by custom:script1. Note that this the QName for the script node but it may also be identified by it's node _doc property.

For the script engine, a simple rendition method must be provided that takes in a node and returns the JSON for the resulting object.

function rendition(node) {
    return {
        "title": node.data.title,
        "headline": node.data.shortHeadline,
        "format": "mobile"
    };
}

As a result, a new node will be generated with the JSON:

{
    "title": "My Article",
    "headline": ""Cubs win World Series!",
    "format": "mobile"
}

The new node is marked with the f:rendition feature. It has an association of type a:has_rendition that connects it from the source node to the rendition. This association has a property on it called renditionKey with the value mobile.

The source node will be marked with the f:renditioned feature to indicate that a rendition was generated. That way, in the future, if you ever update the source node, all of the target renditions will likewise be regenerated.

For example, you might modify the source node's shortHeadline to be "Cubs lose World Series!". Upon saving the source node, the target rendition (above) will update to:

{
    "title": "My Article",
    "headline": ""Cubs lose World Series!",
    "format": "mobile"
}

Which would be a sad thing indeed. But here in Chicago, we're quite used to the Cubs losing. We'll get over it. And we'll be back next season!