JavaScript Driver (Legacy Driver)

Connect your HTML browser applications to Cloud CMS





Current version: 1.0.323. Released Oct 27, 2022.

The Cloud CMS JavaScript driver can be dropped into any web or mobile application running in the browser, within Node.js or any of a host of web frameworks.

You can load the driver into your web application in one of three ways:

(1) In the Browser (global)


 <script type="text/javascript" src="gitana.min.js"></script>
<script>
    Gitana.connect({...}, function() {
        // ...your code
    });
</script>

(2) Using AMD


define(["gitana"], function(Gitana) {
    Gitana.connect({...}, function() {
        // ...your code
    });
});

(3) Using Common JS


var Gitana = require("gitana");
Gitana.connect({...}, function() {
    // ...your code
});


Installation

You can get the Cloud CMS JavaScript driver using Bower, NPM, via a direct download or you can load it from the Cloud CMS CDN.

(1) Install using Twitter Bower

bower install gitana

(2) Install using NPM (Node Package Manager)

npm install gitana

(3) Download directly

The Cloud CMS driver comes wrapped with a shim to auto-detect the presence of an AMD and CommonJS loaders. This allows it to be loaded into a segmented namespace via tools like RequireJS within the browser or Node.js on the server-side. The driver is entirely standalone and has no external dependencies.


Getting Started

To connect to Cloud CMS, you first need to have a set of API Keys. In Cloud CMS, API Keys consists of a client key/secret and a user key/secret. You pass these keys into the Gitana.connect method as a JSON object.

You can create as many API Keys as you would like. The basic process for getting your own keys is described in the Developers Getting Started Guide. Give that a shot and when you're done, you should have the following:

  • clientKey
  • clientSecret
  • username
  • password

You can then connect to Cloud CMS using a code block like the one shown below. Make sure to plug in the values for clientKey, clientSecret, username and password from the API Keys that you generate.


Gitana.connect({
    "clientKey": "{clientKey}",
    "clientSecret": "{clientSecret}",
    "username": "{username}",
    "password": "{password}",
    "baseURL": "https://api.cloudcms.com"
}, function(err) {

    // here is some sample code of what we might then do

    // create a repository, get master branch
    this.createRepository().readBranch("master").then(function() {

        // create a few nodes
        this.createNode();
        this.createNode({ "title": "My second node" });
        this.createNode({ "title": "My third node", "name": "boo" });

        // query for nodes
        this.queryNodes({ "name": "boo" }).count(function(count) {
            console.log("count = " + count); // 1
        });
    });

    // create then delete a domain
    this.createDomain({
        "title": "Users and Groups"
    }).del();

});


Documentation

The JavaScript driver is a very powerful library that provides access to 100% of the capabilities of Cloud CMS from a programmatic perspective. It is therefore important to first familiarize yourself with the concepts presented in the Cloud CMS Documentation.

We also provide JS-Doc Code Documentation for all of the driver's classes and methods.

And finally, you should familiarize with the Cloud CMS REST API which covers HTTP-level information about all of the methods and operations available within Cloud CMS.

Check out our Cloud CMS JavaScript (Legacy) Cookbook for recipes and examples using this driver.


Fork the Code

The Cloud CMS JavaScript driver is 100% open-source (Apache 2.0) and so you're free to fork it, extend it and dig into it to learn about how it works. We provide hundreds of test files and thousands of unit tests within that demonstrate various code operations. It's really cool.


Bugs / Problems

If you run into a bug, please create an issue so that we can look at it.
For production support, please contact us at support@cloudcms.com or call us directly.


Support and Terms of Use

The JavaScript driver is free to use in your applications and projects. It is fully supported by Cloud CMS.