Contentful Bootstrap

A small CLI tool for getting started with Contentful

Contentful

Contentful is a content management platform for web applications, mobile apps and connected devices. It allows you to create, edit & manage content in the cloud and publish it anywhere via powerful API. Contentful offers tools for managing editorial teams and enabling cooperation between organizations.

What does contentful_bootstrap do?

The aim of contentful_bootstrap is to have developers setting up their Contentful environment in a single command

How to Use

Installation

$ gem install contentful_bootstrap

Usage

You can create spaces by doing

$ contentful_bootstrap create_space <space_name> [--template template_name] [--json-template template_path] [--config CONFIG_PATH]

You can also generate new Delivery API Tokens by doing:

$ contentful_bootstrap generate_token <space_id> [--name token_name] [--config CONFIG_PATH]

Available templates

The available templates for your spaces are:

blog
gallery
catalogue

This will get you started with Contentful by setting up a Space with some Demo Data to get you started as soon as possible with development using our API.

Using from within other applications

Include contentful_bootstrap to your project's Gemfile

gem "contentful_bootstrap"

Require contentful_bootstrap

require 'contentful/bootstrap'

To Create a new Space

Contentful::Bootstrap::Commands.new.create_space("space_name")

Additionally, you can send an options hash with the following keys:

options = {
  template: "blog", # Will use one of the predefined templates and create Content Types, Assets and Entries
  json_template: "/path/to/template.json", # Will use the JSON file specified as a Template
  trigger_oauth: true # if true will trigger OAuth process
}
Contentful::Bootstrap::Commands.new.create_space("space_name", options)

To Create a new Delivery API Token

Contentful::Bootstrap::Commands.new.generate_token("space_id")

Additionally, you can send an options hash with the following keys:

options = {
  name: "Some Nice Token Name", # Will Create the Delivery API Token with the specified name
  trigger_oauth: true # if true will trigger OAuth process
}
Contentful::Bootstrap::Commands.new.create_space("space_name", options)

Optionally, Commands#new will take a parameter for specifying a configuration path

Configuration

Contentful Bootstrap will read by default from ~/.contentfulrc, but you can provide your own file by using the --config CONFIG_PATH parameter

If you don't have ~/.contentfulrc created, you will be prompted if you want to create it

Configuration Format

The configuration file will be in ini format and looks like the following

[global]
CONTENTFUL_MANAGEMENT_ACCESS_TOKEN = a_management_access_token

[space_name]
SPACE_ID = some_space_id ; Space configurations are not required by this tool, but can be generated by it
CONTENTFUL_DELIVERY_ACCESS_TOKEN = a_delivery_acces_token      ; Delivery Access Token is not required for this tool, but can be generated by it

JSON Templates

You can find a complete example here

Contributing

Feel free to improve this tool by submitting a Pull Request. For more information, please check CONTRIBUTING.md