Universal content delivery

What is Cobalt?

Cobalt is a framework for building front-ends for digital content distribution. You can use it to feed content to a virtually unlimited range of channels and devices.

Standard technologies

Cobalt’s core components use standard technologies you’re already familiar with – no steep learning curve!

Cobalt is entirely developed in Java.

Data is normalized and exposed in JSON format.

Data persistence is handled by PostgreSQL.

Search is powered by ElasticSearch.

The integrated template engine is Freemarker compatible.

Open source – and more

In common with open-source solutions, Cobalt uses a modular, service-oriented architecture interacting through standard REST protocols.

At the same time Cobalt’s core components and API’s are:

Don’t reinvent the stack!

Cobalt’s core components give you a firm basis on which to create innovative solutions, without having to reinvent basic functionalities.

And you can do it confident that you’re working within a technological framework that is robust and fully documented.

That’s a key consideration when the solution you’re building is critical to your organization’s operations.

A decoupled solution

Cobalt is a decoupled solution, with a clear separation of delivery from the content creation processes, however complex these may be.

Content from any standard CMS or legacy system is normalized into a documented JSON format with HTML5 tagging for maximum versatility in subsequent delivery.

This allows Cobalt to act as highly effective bridge between existent content depositories and an unlimited range of destinations.

What can you do?

Have a look at some coding examples:


PHP

The example shows you how to list all the articles that belong to a specific section (passed as a query parameter) by using the Cobalt APIs in plain PHP code:

$cobaltBaseUrl = "http://my.cobalt-cmf.test/api";
$sectionPath = isset($_GET["section"]) ? $_GET["section"] : "/";
$response = file_get_content($cobaltBaseUrl . "/pages?url=" . $sectionPath);
$sections = json_decode($response);

Once you have the content correctly converted into a PHP object, you can parse its content using the object operator. For example, to list all the articles in the section, you can use a piece of code like this:

foreach ($section->model->nodes as $articleNode) {
?>
    <div class="article">
        <a href="article.php?id=<?= $articleNode->id ?>">
            <h1><?= $articleNode->title ?></h1>
            <h2><?= $articleNode->summary ?></h2>
        </a>
    </div>
<?php
}

NODE.JS

This example shows you how to print a site structure using Cobalt APIs in plain Node.js code.

The first thing to do is retrieve the site structure using the /site API:

request({
    baseUrl: 'http://my.cobalt-cmf.test/api',
    url: '/site',
    json: true
}, (err, resp, body) => {
    if (!err) {
        navigateSitemap(body.root, 0);
    }
});

Once we have the JSON object containing the site structure, we can parse it recursively (because it has a tree structure):

function navigateSitemap(node, level) {
    let out = '';
    for (let i = 0; i < level; i++) { out += '\t'; }
    console.log(out + node.title + ' (' + node.uri + ')');
    if (node.items) {
        node.items.forEach(item => {
            navigateSitemap(item, level + 1);
        });
    }
}

JAVASCRIPT

This example will show you the steps needed to publish content from a third-party source. This example uses Google Docs but the same process can be applied to any other source.

First log in to Cobalt to get a valid session token (called emauth) to be used in the subsequent API call. To log in, call the /sessions/login API using data from an HTML form rendered in the Google Docs web panel:

function login() {
    var data = {
        name: $('#username').val(),
        password: $('#password').val()
    }
    $.ajax({
        type: 'POST',
        url: cobaltEndPoint + '/sessions/login',
        data: JSON.stringify(data),
        dataType: 'json',
        contentType: 'application/json'
    }).done(function (res) {
        setEmauth(res.session.id);
    }).fail(function () {
        console.error(arguments);
    });
}

Once you have logged in to Cobalt, you can start the publication process:

function doPublish() {
    google.script.run.withSuccessHandler(function (doc, el) {
        prepare(doc, function (err, pubId) {
            updates(doc, pubId, function (err, res) {
                publish(pubId, function (err, res) {
                    alert('done');
                });
            });
        });
    }).withFailureHandler(function (msg, el) {
        alert('error');
    }).analyzeDocument();
}

This code launches a Google Script function (analyzeDocument). The function parses the file and returns the HTML5-transformed document and other meta-information (i.e. images, blobs, author info etc.). If the call is successful, you can proceed to the first step in publication which is the preparation phase. This phase requests a slot in the repository and returns a publication ID to be used in all subsequent phases.

Once the preparation has been completed, you can move to the next phase which consists of a series of calls, one for each object involved in the publication (i.e. the story and each of its media objects):

function updates(doc, publicationId, callback) {
    var links = {
        hyperlink: {
            image: []
        },
        system: {
            mainPicture: []
        }
    };
    // images publication
    Object.keys(doc.images).forEach(function(imgRef, i) {
        if (i === 0) {
            links.system.mainPicture.push({ foreignId: imgRef });
        }
        links.hyperlink.image.push({ foreignId: imgRef });
    });
    Object.keys(doc.images).forEach(function(imgRef, i) {
        var img = doc.images[imgRef];
        update(imgRef, doc.title + ' - image #' + i, null, null, 'image', 'image', 'image', img.contentType, siteName, sectionPath, b64toBlob(img.b64, img.contentType), publicationId, null);
    });
    // main content publication
    update(doc.docId, doc.title, doc.summary, doc.authors, 'article', 'article', 'content.xml', 'text/xml', siteName, sectionPath, doc.xml, publicationId, links);

    return callback(null, {done:true});
}

The update call launches the /publication/update API to upload the content to Cobalt.

Once all the update processes have been completed, publication proceeds with a call to the /publication/publish API. This step may be considered a commit and publication will be confirmed.

If, for any reason, one or more update steps failed, you can roll back the entire publication by calling the /publication/abort API.

FREEMARKER

This example shows how to use a template engine to render contents on a webpage. The example uses Freemarker, although other template engines are also supported.

A webpage is logically divided into different zones, which may be seen as 'content buckets'.

If you don't know the name of the zone you want to render, you can iterate through all the defined zone names like this:

<#list zones()?keys as zoneName>
    <div class="zone">
        <div class="zone-label">${zoneName}</div>
        <!-- ... -->
    </div>
</#list>

Once you have the name of the zone, you can iterate through its content, leaving the template engine to render each item, mainly on the basis of its item type. An item could be an article, an image, a video, a widget etc.:

<list zone(zoneName).items as item>
    <div class="item">
        <@include object=item />
    </div>
</#list>

Extending and customizing

You can use Cobalt out of the box, but this is not its real strength. Cobalt’s standard core modules are easily extended to add new functionality and are compatible with a wide range of third-party plug ins or extensions.

SDK

Cobalt’s SDK gives you the tools to make the most of its resources and develop innovative solutions quickly and easily.

Front-end freedom

Cobalt integrates the FreeMarker template engine. Designers can use themes and templates to rapidly develop new page and layout formats without manual coding. Cobalt’s APIs allow use of popular toolkits like Bootstrap or AngularJS.

Scalability and multi-site management

You can use Cobalt to manage extremely large website portfolios (100+) based on a single CMS with advantages like content-sharing, integrated access, single sign-on, etc.

Multi-language handling

Cobalt handles different language versions as multi-lingual stories. They may be processed through different workflows and published to different delivery channels but are updated and archived as a single editorial object.

Built-in analytics and A/B testing

Cobalt incorporates powerful tools to measure site performance - in-page analytics, visitor engagement plots and scroll-depth statistics. Cobalt also allows A/B and multivariate testing runs to be launched with just a few clicks, proving valuable feedback about site performance.

Continuous deployment

Cobalt lets you develop your solutions in incremental mode, with frequent upgrades and deployments to keep pace with changing user requirements.

Cloud deployment

Cobalt’s service-oriented architecture supports scalability and availability features for use in both private cloud environments as well as major cloud providers like Amazon Web Services (AWS).
EidosMedia is a certified AWS Advanced Partner.