contentful_bootstrap 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +37 -0
- data/CONTRIBUTING.md +43 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +59 -0
- data/LICENSE +22 -0
- data/README.md +37 -0
- data/Rakefile +2 -0
- data/bin/contentful_bootstrap +56 -0
- data/contentful_bootstrap.gemspec +26 -0
- data/lib/contentful_bootstrap.rb +2 -0
- data/lib/contentful_bootstrap/commands.rb +75 -0
- data/lib/contentful_bootstrap/constants.rb +6 -0
- data/lib/contentful_bootstrap/server.rb +63 -0
- data/lib/contentful_bootstrap/support.rb +12 -0
- data/lib/contentful_bootstrap/templates.rb +3 -0
- data/lib/contentful_bootstrap/templates/base.rb +56 -0
- data/lib/contentful_bootstrap/templates/blog.rb +75 -0
- data/lib/contentful_bootstrap/templates/catalogue.rb +8 -0
- data/lib/contentful_bootstrap/templates/entry_link.rb +10 -0
- data/lib/contentful_bootstrap/templates/gallery.rb +9 -0
- data/lib/contentful_bootstrap/token.rb +23 -0
- data/lib/contentful_bootstrap/version.rb +3 -0
- metadata +152 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f9506edbc16f70f64a055a68070cc45ab223f659
|
4
|
+
data.tar.gz: c6264e50faf9279fd7ab8f6b711ef28078429db8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1f6699a6d573ef6861d375532da40236d2fcc64476108482a27b53a3621788fee0c0b1af917255f8801fb2d133d7c90e550f05caa52b1b5ed1651d6927ee5aec
|
7
|
+
data.tar.gz: b28410bf29c7bf06b8b593f236736431e40d50c2d772dc374ac205affd780aac60326b0a5326c9f31b5b4f1a0290e272c46f35f4e492d6bf02ecce379c199697
|
data/.gitignore
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/vendor/bundle
|
26
|
+
/lib/bundler/man/
|
27
|
+
|
28
|
+
# for a library or gem, you might want to ignore these files since the code is
|
29
|
+
# intended to run in multiple environments; otherwise, check them in:
|
30
|
+
# Gemfile.lock
|
31
|
+
# .ruby-version
|
32
|
+
# .ruby-gemset
|
33
|
+
|
34
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
35
|
+
.rvmrc
|
36
|
+
|
37
|
+
.contentful_bootstrap
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Contributing
|
2
|
+
In the spirit of [free software][free-sw], **everyone** is encouraged to help
|
3
|
+
improve this project.
|
4
|
+
|
5
|
+
[free-sw]: http://www.fsf.org/licensing/essays/free-sw.html
|
6
|
+
|
7
|
+
Here are some ways *you* can contribute:
|
8
|
+
|
9
|
+
* by using alpha, beta, and prerelease versions
|
10
|
+
* by reporting bugs
|
11
|
+
* by suggesting new features
|
12
|
+
* by writing or editing documentation
|
13
|
+
* by writing specifications
|
14
|
+
* by writing code ( **no patch is too small** : fix typos, add comments, clean up inconsistent whitespace )
|
15
|
+
* by refactoring code
|
16
|
+
* by closing [issues][]
|
17
|
+
* by reviewing patches
|
18
|
+
|
19
|
+
[issues]: https://github.com/contentful-labs/contentful_bootstrap.rb/issues
|
20
|
+
|
21
|
+
## Submitting an Issue
|
22
|
+
We use the [GitHub issue tracker][issues] to track bugs and features. Before
|
23
|
+
submitting a bug report or feature request, check to make sure it hasn't
|
24
|
+
already been submitted. When submitting a bug report, please include a [Gist][]
|
25
|
+
that includes a stack trace and any details that may be necessary to reproduce
|
26
|
+
the bug, including your gem version, Ruby version, and operating system.
|
27
|
+
Ideally, a bug report should include a pull request with failing specs.
|
28
|
+
|
29
|
+
[gist]: https://gist.github.com/
|
30
|
+
|
31
|
+
## Submitting a Pull Request
|
32
|
+
1. [Fork the repository.][fork]
|
33
|
+
2. [Create a topic branch.][branch]
|
34
|
+
3. Add specs for your unimplemented feature or bug fix.
|
35
|
+
4. Run `bundle exec rake test`. If your specs pass, return to step 3.
|
36
|
+
5. Implement your feature or bug fix.
|
37
|
+
6. Run `bundle exec rake test`. If your specs fail, return to step 5.
|
38
|
+
7. Add, commit, and push your changes.
|
39
|
+
8. [Submit a pull request.][pr]
|
40
|
+
|
41
|
+
[fork]: http://help.github.com/fork-a-repo/
|
42
|
+
[branch]: http://learn.github.com/p/branching.html
|
43
|
+
[pr]: http://help.github.com/send-pull-requests/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
addressable (2.3.8)
|
5
|
+
coderay (1.1.0)
|
6
|
+
contentful-management (0.7.2)
|
7
|
+
http (~> 0.8)
|
8
|
+
multi_json (~> 1)
|
9
|
+
daemons (1.2.3)
|
10
|
+
deklarativna (0.0.10)
|
11
|
+
launchy
|
12
|
+
sinatra
|
13
|
+
thin
|
14
|
+
domain_name (0.5.25)
|
15
|
+
unf (>= 0.0.5, < 1.0.0)
|
16
|
+
eventmachine (1.0.8)
|
17
|
+
http (0.9.8)
|
18
|
+
addressable (~> 2.3)
|
19
|
+
http-cookie (~> 1.0)
|
20
|
+
http-form_data (~> 1.0.1)
|
21
|
+
http_parser.rb (~> 0.6.0)
|
22
|
+
http-cookie (1.0.2)
|
23
|
+
domain_name (~> 0.5)
|
24
|
+
http-form_data (1.0.1)
|
25
|
+
http_parser.rb (0.6.0)
|
26
|
+
launchy (2.4.3)
|
27
|
+
addressable (~> 2.3)
|
28
|
+
method_source (0.8.2)
|
29
|
+
multi_json (1.11.2)
|
30
|
+
pry (0.10.3)
|
31
|
+
coderay (~> 1.1.0)
|
32
|
+
method_source (~> 0.8.1)
|
33
|
+
slop (~> 3.4)
|
34
|
+
rack (1.6.4)
|
35
|
+
rack-protection (1.5.3)
|
36
|
+
rack
|
37
|
+
sinatra (1.4.6)
|
38
|
+
rack (~> 1.4)
|
39
|
+
rack-protection (~> 1.4)
|
40
|
+
tilt (>= 1.3, < 3)
|
41
|
+
slop (3.6.0)
|
42
|
+
thin (1.6.4)
|
43
|
+
daemons (~> 1.0, >= 1.0.9)
|
44
|
+
eventmachine (~> 1.0, >= 1.0.4)
|
45
|
+
rack (~> 1.0)
|
46
|
+
tilt (2.0.1)
|
47
|
+
unf (0.1.4)
|
48
|
+
unf_ext
|
49
|
+
unf_ext (0.0.7.1)
|
50
|
+
|
51
|
+
PLATFORMS
|
52
|
+
ruby
|
53
|
+
|
54
|
+
DEPENDENCIES
|
55
|
+
contentful-management
|
56
|
+
deklarativna
|
57
|
+
launchy
|
58
|
+
pry
|
59
|
+
sinatra
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Contentful Bootstrap
|
2
|
+
|
3
|
+
A small CLI tool for getting started with Contentful
|
4
|
+
|
5
|
+
## Contentful
|
6
|
+
[Contentful](http://www.contentful.com) is a content management platform for web applications,
|
7
|
+
mobile apps and connected devices. It allows you to create, edit manage content in the cloud
|
8
|
+
and publish it anywhere via powerful API. Contentful offers tools for managing editorial
|
9
|
+
teams and enabling cooperation between organizations.
|
10
|
+
|
11
|
+
## How to Use
|
12
|
+
|
13
|
+
### Installation
|
14
|
+
|
15
|
+
```bash
|
16
|
+
$ gem install contentful_bootstrap
|
17
|
+
```
|
18
|
+
|
19
|
+
### First Usage
|
20
|
+
|
21
|
+
```bash
|
22
|
+
$ contentful_bootstrap init <space_name> [--template template_name]
|
23
|
+
```
|
24
|
+
|
25
|
+
Then you can create other spaces by doing:
|
26
|
+
|
27
|
+
```bash
|
28
|
+
$ contentful_bootstrap create_space <space_name> [--template template_name]
|
29
|
+
```
|
30
|
+
|
31
|
+
This will get you started with Contentful by setting up a Space with some Demo Data to get you
|
32
|
+
started as soon as possible with development using our API.
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
Feel free to improve this tool by submitting a Pull Request. For more information,
|
37
|
+
please check [CONTRIBUTING.md](./CONTRIBUTING.md)
|
data/Rakefile
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'contentful_bootstrap/commands'
|
5
|
+
|
6
|
+
options = {}
|
7
|
+
global = OptionParser.new do |opts|
|
8
|
+
opts.banner = "Usage: contentful_bootstrap <command> <space_name> [--template TEMPLATE_NAME]"
|
9
|
+
opts.separator ""
|
10
|
+
opts.separator <<-HELP
|
11
|
+
Available commands are:
|
12
|
+
init
|
13
|
+
create_space
|
14
|
+
HELP
|
15
|
+
end
|
16
|
+
|
17
|
+
subcommands = {
|
18
|
+
'init' => OptionParser.new do |opts|
|
19
|
+
opts.banner = "Usage: init <space_name> [--template TEMPLATE_NAME]"
|
20
|
+
opts.on("-t", "--template TEMPLATE", "Specify Template", "blog, catalogue, gallery") do |t|
|
21
|
+
options[:template] = t
|
22
|
+
end
|
23
|
+
end,
|
24
|
+
'create_space' => OptionParser.new do |opts|
|
25
|
+
opts.banner = "Usage: init <space_name> [--template TEMPLATE_NAME]"
|
26
|
+
opts.on("-t", "--template TEMPLATE", "Specify Template", "blog, catalogue, gallery") do |t|
|
27
|
+
options[:template] = t
|
28
|
+
end
|
29
|
+
end
|
30
|
+
}
|
31
|
+
|
32
|
+
global.order!
|
33
|
+
command = ARGV.shift
|
34
|
+
space_name = ARGV.shift
|
35
|
+
|
36
|
+
if subcommands.has_key? command
|
37
|
+
subcommands[command].order!
|
38
|
+
|
39
|
+
if space_name.nil? || space_name.empty?
|
40
|
+
puts "Usage: contentful_bootstrap <command> <space_name> [--template TEMPLATE_NAME]"
|
41
|
+
puts
|
42
|
+
puts "You must provide a valid space name. Exiting!"
|
43
|
+
exit
|
44
|
+
end
|
45
|
+
|
46
|
+
ContentfulBootstrap::Commands.new.send(command, space_name, options.fetch(:template, nil))
|
47
|
+
else
|
48
|
+
puts "Usage: contentful_bootstrap <command> <space_name> [--template TEMPLATE_NAME]"
|
49
|
+
puts
|
50
|
+
puts <<-HELP
|
51
|
+
Subcommand not available or missing
|
52
|
+
Available commands are:
|
53
|
+
init
|
54
|
+
create_space
|
55
|
+
HELP
|
56
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'contentful_bootstrap/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "contentful_bootstrap"
|
8
|
+
spec.version = ContentfulBootstrap::VERSION
|
9
|
+
spec.authors = ["David Litvak Bruno"]
|
10
|
+
spec.email = ["david.litvakb@gmail.com"]
|
11
|
+
spec.summary = %q{Contentful CLI tool for getting started with Contentful}
|
12
|
+
spec.homepage = "https://www.contentful.com"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
spec.add_runtime_dependency "sinatra"
|
23
|
+
spec.add_runtime_dependency "launchy"
|
24
|
+
spec.add_runtime_dependency "contentful-management"
|
25
|
+
spec.add_runtime_dependency "deklarativna"
|
26
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require "thread"
|
2
|
+
require "net/http"
|
3
|
+
require "contentful/management"
|
4
|
+
require "contentful_bootstrap/token"
|
5
|
+
require "contentful_bootstrap/server"
|
6
|
+
require "contentful_bootstrap/support"
|
7
|
+
require "contentful_bootstrap/templates"
|
8
|
+
|
9
|
+
module ContentfulBootstrap
|
10
|
+
class Commands
|
11
|
+
include Support
|
12
|
+
|
13
|
+
def init(space_name, template_name = nil)
|
14
|
+
if !Token.present?
|
15
|
+
puts "A new tab on your browser will open for requesting OAuth permissions"
|
16
|
+
get_token
|
17
|
+
puts "OAuth permissions successfully saved, your OAuth token is present in '.contentful_token'"
|
18
|
+
else
|
19
|
+
puts "OAuth token found, moving on!"
|
20
|
+
end
|
21
|
+
|
22
|
+
create_space(space_name, template_name)
|
23
|
+
end
|
24
|
+
|
25
|
+
def create_space(space_name, template_name = nil)
|
26
|
+
management_client_init
|
27
|
+
|
28
|
+
puts "Creating Space '#{space_name}'"
|
29
|
+
space = Contentful::Management::Space.create(name: space_name)
|
30
|
+
puts "Space '#{space_name}' created!"
|
31
|
+
|
32
|
+
return if template_name.nil?
|
33
|
+
|
34
|
+
if templates.has_key? template_name.to_sym
|
35
|
+
puts "Creating Template '#{template_name}'"
|
36
|
+
|
37
|
+
templates[template_name.to_sym].new(space).run
|
38
|
+
puts "Template '#{template_name}' created!"
|
39
|
+
else
|
40
|
+
puts "Template '#{template_name}' not found. Valid templates are '#{templates.keys.map(&:to_s).join('\', \'')}'"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
def management_client_init
|
46
|
+
Contentful::Management::Client.new(Token.read, raise_errors: true)
|
47
|
+
end
|
48
|
+
|
49
|
+
def get_token
|
50
|
+
silence_stderr do # Don't show any Sinatra related stuff
|
51
|
+
t = Thread.new { Server.run! }
|
52
|
+
|
53
|
+
while !Server.running? # Wait for Server Init
|
54
|
+
sleep(1)
|
55
|
+
end
|
56
|
+
|
57
|
+
Net::HTTP.get(URI('http://localhost:5123'))
|
58
|
+
|
59
|
+
while !Token.present? # Wait for User to do OAuth cycle
|
60
|
+
sleep(1)
|
61
|
+
end
|
62
|
+
|
63
|
+
Server.quit!
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def templates
|
68
|
+
{
|
69
|
+
blog: Templates::Blog,
|
70
|
+
gallery: Templates::Gallery,
|
71
|
+
catalogue: Templates::Catalogue
|
72
|
+
}
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require "sinatra"
|
2
|
+
require "launchy"
|
3
|
+
require "deklarativna"
|
4
|
+
require "thin"
|
5
|
+
require "contentful_bootstrap/constants"
|
6
|
+
require "contentful_bootstrap/token"
|
7
|
+
|
8
|
+
module ContentfulBootstrap
|
9
|
+
class OAuthEchoView < BaseTemplate
|
10
|
+
def _body
|
11
|
+
script(type: "text/javascript") {
|
12
|
+
<<-JS
|
13
|
+
(function() {
|
14
|
+
var access_token = window.location.hash.split('&')[0].split('=')[1];
|
15
|
+
window.location.replace('http://localhost:5123/save_token/' + access_token);
|
16
|
+
})();
|
17
|
+
JS
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class ThanksView < BaseTemplate
|
23
|
+
def _head
|
24
|
+
link(rel: "stylesheet", href: "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css")
|
25
|
+
end
|
26
|
+
|
27
|
+
def _body
|
28
|
+
div(class: "container") {
|
29
|
+
div(class: "jumbotron") {[
|
30
|
+
h1 { "Contentful Bootstrap" },
|
31
|
+
h4 { "Thanks! The OAuth Token has been generated" },
|
32
|
+
p { "The Space you specified will now start to create. You can close this window freely" }
|
33
|
+
]}
|
34
|
+
}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class Server < Sinatra::Base
|
39
|
+
configure do
|
40
|
+
set :port, 5123
|
41
|
+
set :logging, nil
|
42
|
+
set :quiet, true
|
43
|
+
Thin::Logging.silent = true # Silence Thin startup message
|
44
|
+
end
|
45
|
+
|
46
|
+
get '/' do
|
47
|
+
client_id = ContentfulBootstrap::Constants::OAUTH_APP_ID
|
48
|
+
redirect_uri = ContentfulBootstrap::Constants::OAUTH_CALLBACK_URL
|
49
|
+
scope = "content_management_manage"
|
50
|
+
Launchy.open("https://be.contentful.com/oauth/authorize?response_type=token&client_id=#{client_id}&redirect_uri=#{redirect_uri}&scope=#{scope}")
|
51
|
+
""
|
52
|
+
end
|
53
|
+
|
54
|
+
get '/oauth_callback' do
|
55
|
+
OAuthEchoView.new.render
|
56
|
+
end
|
57
|
+
|
58
|
+
get '/save_token/:token' do
|
59
|
+
Token.write(params[:token])
|
60
|
+
ThanksView.new.render
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require "contentful/management"
|
2
|
+
|
3
|
+
module ContentfulBootstrap
|
4
|
+
module Templates
|
5
|
+
class Base
|
6
|
+
attr_reader :space
|
7
|
+
|
8
|
+
def initialize(space)
|
9
|
+
@space = space
|
10
|
+
end
|
11
|
+
|
12
|
+
def run
|
13
|
+
content_types.each do |ct|
|
14
|
+
puts "Creating Content Type '#{ct[:name]}'"
|
15
|
+
|
16
|
+
fields = []
|
17
|
+
content_type = space.content_types.new
|
18
|
+
content_type.id = ct[:id]
|
19
|
+
content_type.name = ct[:name]
|
20
|
+
content_type.display_field = ct[:display_field]
|
21
|
+
|
22
|
+
ct[:fields].each do |f|
|
23
|
+
field = Contentful::Management::Field.new
|
24
|
+
field.id = f[:id]
|
25
|
+
field.name = f[:name]
|
26
|
+
field.type = f[:type]
|
27
|
+
field.link_type = f[:link_type] if f.has_key?(:link_type)
|
28
|
+
fields << field
|
29
|
+
end
|
30
|
+
|
31
|
+
content_type.fields = fields
|
32
|
+
content_type.save
|
33
|
+
content_type.activate
|
34
|
+
end
|
35
|
+
|
36
|
+
entries.each do |content_type_id, entry_list|
|
37
|
+
content_type = space.content_types.find(content_type_id)
|
38
|
+
entry_list.each_with_index do |e, index|
|
39
|
+
puts "Creating Entry #{index} for #{content_type_id.capitalize}"
|
40
|
+
entry = content_type.entries.create(e)
|
41
|
+
entry.save
|
42
|
+
entry.publish
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def content_types
|
48
|
+
raise "must implement"
|
49
|
+
end
|
50
|
+
|
51
|
+
def entries
|
52
|
+
raise "must implement"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require "contentful_bootstrap/templates/base"
|
2
|
+
require "contentful_bootstrap/templates/entry_link"
|
3
|
+
|
4
|
+
module ContentfulBootstrap
|
5
|
+
module Templates
|
6
|
+
class Blog < Base
|
7
|
+
def content_types
|
8
|
+
[
|
9
|
+
{
|
10
|
+
id: 'author',
|
11
|
+
name: 'Author',
|
12
|
+
display_field: 'name',
|
13
|
+
fields: [
|
14
|
+
{
|
15
|
+
id: 'name',
|
16
|
+
name: "Author Name",
|
17
|
+
type: "Symbol"
|
18
|
+
}
|
19
|
+
]
|
20
|
+
},
|
21
|
+
{
|
22
|
+
id: 'post',
|
23
|
+
name: 'Post',
|
24
|
+
display_field: 'title',
|
25
|
+
fields: [
|
26
|
+
{
|
27
|
+
id: 'title',
|
28
|
+
name: "Post Title",
|
29
|
+
type: "Symbol"
|
30
|
+
},
|
31
|
+
{
|
32
|
+
id: 'content',
|
33
|
+
name: "Content",
|
34
|
+
type: "Text"
|
35
|
+
},
|
36
|
+
{
|
37
|
+
id: 'author',
|
38
|
+
name: "Author",
|
39
|
+
type: "Link",
|
40
|
+
link_type: "Entry"
|
41
|
+
}
|
42
|
+
]
|
43
|
+
}
|
44
|
+
]
|
45
|
+
end
|
46
|
+
|
47
|
+
def entries
|
48
|
+
{
|
49
|
+
'author' => [
|
50
|
+
{
|
51
|
+
id: "dan_brown",
|
52
|
+
name: "Dan Brown"
|
53
|
+
},
|
54
|
+
{
|
55
|
+
id: "pablo_neruda",
|
56
|
+
name: "Pablo Neruda"
|
57
|
+
}
|
58
|
+
],
|
59
|
+
'post' => [
|
60
|
+
{
|
61
|
+
title: "Inferno",
|
62
|
+
content: "Inferno is the last book in Dan Brown's collection...",
|
63
|
+
author: EntryLink.new("dan_brown")
|
64
|
+
},
|
65
|
+
{
|
66
|
+
title: "Alturas de Macchu Picchu",
|
67
|
+
content: "Alturas de Macchu Picchu is one of Pablo Neruda's most famous poetry books...",
|
68
|
+
author: EntryLink.new("pablo_neruda")
|
69
|
+
}
|
70
|
+
]
|
71
|
+
}
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ContentfulBootstrap
|
2
|
+
class Token
|
3
|
+
def self.present?
|
4
|
+
File.exist?(filename)
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.read
|
8
|
+
File.open(filename, "r") { |f|
|
9
|
+
f.readlines[0]
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.write(token)
|
14
|
+
File.open(filename, "w") { |f|
|
15
|
+
f.write(token)
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.filename
|
20
|
+
File.join(Dir.pwd, ".contentful_token")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: contentful_bootstrap
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David Litvak Bruno
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sinatra
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: launchy
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: contentful-management
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: deklarativna
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- david.litvakb@gmail.com
|
100
|
+
executables:
|
101
|
+
- contentful_bootstrap
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- ".gitignore"
|
106
|
+
- CONTRIBUTING.md
|
107
|
+
- Gemfile
|
108
|
+
- Gemfile.lock
|
109
|
+
- LICENSE
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- bin/contentful_bootstrap
|
113
|
+
- contentful_bootstrap.gemspec
|
114
|
+
- lib/contentful_bootstrap.rb
|
115
|
+
- lib/contentful_bootstrap/commands.rb
|
116
|
+
- lib/contentful_bootstrap/constants.rb
|
117
|
+
- lib/contentful_bootstrap/server.rb
|
118
|
+
- lib/contentful_bootstrap/support.rb
|
119
|
+
- lib/contentful_bootstrap/templates.rb
|
120
|
+
- lib/contentful_bootstrap/templates/base.rb
|
121
|
+
- lib/contentful_bootstrap/templates/blog.rb
|
122
|
+
- lib/contentful_bootstrap/templates/catalogue.rb
|
123
|
+
- lib/contentful_bootstrap/templates/entry_link.rb
|
124
|
+
- lib/contentful_bootstrap/templates/gallery.rb
|
125
|
+
- lib/contentful_bootstrap/token.rb
|
126
|
+
- lib/contentful_bootstrap/version.rb
|
127
|
+
homepage: https://www.contentful.com
|
128
|
+
licenses:
|
129
|
+
- MIT
|
130
|
+
metadata: {}
|
131
|
+
post_install_message:
|
132
|
+
rdoc_options: []
|
133
|
+
require_paths:
|
134
|
+
- lib
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
requirements: []
|
146
|
+
rubyforge_project:
|
147
|
+
rubygems_version: 2.2.2
|
148
|
+
signing_key:
|
149
|
+
specification_version: 4
|
150
|
+
summary: Contentful CLI tool for getting started with Contentful
|
151
|
+
test_files: []
|
152
|
+
has_rdoc:
|