Skip to content

flackend/dotcms-rest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

DotcmsRest

A wrapper around the dotCMS REST API. Requires jQuery (ajax).

Usage

You'll first want to create a new instance:

var REST = new DotcmsRest();

Pass a config object with debug set to true to see debugging information in the console:

var REST = new DotcmsRest({debug: true});

Create a new contentlet

Publishing a new contentlet:

REST.publishContentlet('Blog', {
    'title': 'How to Build a Boat',
    'body': '...'
}, <callback>);

Or simply save (without publishing):

REST.saveContentlet('Blog', {
    'title': 'How to Build a Boat',
    'body': '...'
}, <callback>);

Both methods take an optional callback as the third paramater.

Get a contentlet

Grab a contentlet:

REST.getContentlet('9b4bda68-31b5-4997-1f78-b5a2e933dff9', function(contentlet) {
  if (contentlet) {
    ...
  }
});

Query contentlets

Use a Lucene query to fetch contentlets:

REST.query('+structureName:Blog +Blog.title:How to *', {limit: 10}, <callback>)

Available options are limit, offset, orderBy, and render.

Update a contentlet

You can update a single contentlet:

REST.updateContentlet('9b4bda68-31b5-4997-1f78-b5a2e933dff9', 'Blog', {
  title: 'How to Build a Row Boat'
}, <callback>);

DotcmsRest will put a lock on the identifier and won't try to update the contentlet if an update is still in progress.

REST.updateContentlet() will return false if the update is aborted.

You can also update multiple contentlets:

REST.updateContentlets(['9b4bda68-31b5-4997-1f78-b5a2e933dff9', ...], 'Blog', {
  title: 'How to Build a Row Boat'
}, <callback>);

Each will be updated one at a time.

To Do

  • Make query function easier to work with (e.g.REST.query('Blog', {author: 'John Smith'}, <callback>)).
  • Update library to use promises in addition to callbacks.
  • Set up library so that you don't have to instantiate it (no more var REST = new DotcmsRest();)
  • Move dotcms-rest.es6 to src/dotcms-rest.js.
  • May need to make it configurable to a specific DotCMS version if structureName support is removed for contentType (etc).
  • Maybe publish to Bower and NPM?

About

Wraps around the dotCMS REST API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published