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?
contentful_bootstrap
let's you set up a new Contentful environment with 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]
You can also generate JSON Templates from existing spaces by doing:
$ contentful_bootstrap generate_json <space_id> <access_token> [--output-file OUTPUT PATH]
Built-in templates
Just getting started with Contentful? We have included the following built-in templates:
blog
gallery
catalogue
You can use these with the --template
option to create some demo data and start developing
against our APIs right away. Once you've gotten comfortable, you can
create your own templates for quickly replicating testing & development spaces.
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::CommandRunner.new.create_space("space_name")
Additionally, you can send an options hash with the following keys:
= {
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::CommandRunner.new.create_space("space_name", )
To Create a new Delivery API Token
Contentful::Bootstrap::CommandRunner.new.generate_token("space_id")
Additionally, you can send an options hash with the following keys:
= {
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::CommandRunner.new.generate_token("space_id", )
To Generate a JSON Template from an exising Space
Contentful::Bootstrap::CommandRunner.new.generate_json("space_id", access_token: "access_token")
Additionally, you can send an options hash with the following keys:
NOTE: The :access_token
key is required in the options hash
options = {
access_token: "access_token" # REQUIRED
filename: "template.json" # Will save the JSON to the specified file
}
Contentful::Bootstrap::CommandRunner.new.generate_json("space_id", options)
Optionally, CommandRunner#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
Using the --json-template
option, you can create spaces with your own predefined content.
This can be useful for creating testing & development spaces or just starting new projects from
a common baseline. 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