buttercms 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a899685662a22b2ad2a4ec87e0f9e0683fbcdaa
4
- data.tar.gz: a7d27b415b8e3d6e16ce7368f1cfd527e60e4301
3
+ metadata.gz: e8cfd9c6d155d1d6af4e7ce36410d02caec5f155
4
+ data.tar.gz: 3e7eea1416ff87e322a4af8c55f63741a4e8c46c
5
5
  SHA512:
6
- metadata.gz: e1aae93ced97c476b91c31efdfa3ce2d4f6b82e30a9527d3963c9661ae3c07eb3aee0215d8d706f0f787a247f14e0c95d605e0731352b459a204fa40a7905e1d
7
- data.tar.gz: 2559999bf1ea8819f7d95334162e3e14e839af3aa1f120215167e08f2ae4419f7c42585cfa261f80729e4bb2a2efb627b3ed1434d669fd895439cd132217e778
6
+ metadata.gz: 67b0cc540d0b9c3ea17fbaac22cc2712b1d173fdeb7c6c94900412d239635f92da05200747c3acb94923090179e288012cae745b88bb9ce9299702e028a63dba
7
+ data.tar.gz: c92fce92b78b7989aef456e793433957e1087dade9fa5bd39b5c051772e47543ec2a4e1042d0ed6ffb9832c9f36acb32682eededaea28a144f552089a3759e71
data/README.rst CHANGED
@@ -1,5 +1,6 @@
1
+ ====================
1
2
  Butter CMS for Rails
2
- =========================
3
+ ====================
3
4
 
4
5
  https://www.buttercms.com
5
6
 
@@ -12,8 +13,10 @@ Butter provides a user friendly blogging UI, hosted on buttercms.com, and expose
12
13
  This package provides a Rails Engine that interacts with the Butter API to get you up and running in seconds.
13
14
 
14
15
 
16
+ ============
15
17
  Installation
16
- ------------
18
+ ============
19
+
17
20
  Add buttercms gem to your Gemfile and install it.
18
21
 
19
22
  .. code-block:: ruby
@@ -34,11 +37,29 @@ Mount the Buttercms engine in your config/routes.rb and define your blog path.
34
37
 
35
38
  Grab your API token from https://buttercms.com/api_token
36
39
 
37
- .. code:: ruby
40
+ **Rails 4.x**
41
+
42
+ For rails 4, add `BUTTER_CMS_TOKEN` to `secrets.yml`
43
+
44
+ .. code-block:: ruby
38
45
 
39
46
  # In config/secrets.yml
40
47
  # Add your BUTTER_CMS_TOKEN to both development: and production:
41
- BUTTER_CMS_TOKEN: <your_api_token>
48
+ development:
49
+ BUTTER_CMS_TOKEN: <your_api_token>
50
+ production:
51
+ BUTTER_CMS_TOKEN: <your_api_token>
52
+
53
+
54
+ **Rails 3.x**
55
+
56
+ For rails 3, set up a classic initializer to expose the api token to the Butter gem.
57
+
58
+ .. code-block:: ruby
59
+
60
+ # In config/initializers/butter.rb
61
+ Buttercms::BUTTER_CMS_TOKEN = <your_api_token>
62
+
42
63
 
43
64
  Nice job. You've now got a blog running natively in your Rails project. Nothing but Ruby goodness. (No PHP scripts here ;))
44
65
 
@@ -46,6 +67,73 @@ Check it out: localhost:3000/blog
46
67
 
47
68
  Log into https://buttercms.com/ to start blogging!
48
69
 
70
+ ==========================
71
+ Overview of key blog views
72
+ ==========================
73
+ The Butter gem implements several actions for your blog and provides a default view+layout for each of them. The gem also talks to an API that resides on https://buttercms.com to retrieve your blog content and makes that content easily available in each view.
74
+
75
+ Here's an overview each action+view and the available content:
76
+
77
+ home: /blog
78
+ -----------
79
+ .. code:: ruby
80
+
81
+ @next_page # Integer used for blog post pagination (i.e. 2)
82
+ @previous_page # Integer used for blog post pagination (i.e. 1)
83
+ @recent_posts # Array of blog posts
84
+
85
+ post: /blog/:post-slug
86
+ ----------------------
87
+ .. code:: ruby
88
+
89
+ @post # All content for a blog post
90
+
91
+ =begin
92
+ @post has the following structure
93
+ "url": "https://buttercms.com/blog/the-state-of-company-blogs",
94
+ "created": "05/16/2015",
95
+ "author": {
96
+ "first_name": "Butter",
97
+ "last_name": "Cms",
98
+ "slug": "butter-cms"
99
+ },
100
+ "categories": [
101
+ {
102
+ "name": "blogs",
103
+ "slug": "blogs"
104
+ },
105
+ {
106
+ "name": "butter",
107
+ "slug": "butter"
108
+ }
109
+ ],
110
+ "slug": "the-state-of-company-blogs",
111
+ "title": "The State of Company Blogs",
112
+ "body": "<h3>The problem</h3><p>Countless people and essentially every...</p>",
113
+ "summary": <h3>The problem</h3><p>Countless people and essentially...</p>,
114
+ "status": "published"
115
+ =end
116
+
117
+ author: /blog/author/:author-slug
118
+ ---------------------------------
119
+ .. code:: ruby
120
+
121
+ @first_name # First name of author
122
+ @last_name # Last name of author
123
+ @recent_posts # Array of blog posts
124
+
125
+ category: /blog/category/:category-slug
126
+ ---------------------------------------
127
+ .. code:: ruby
128
+
129
+ @name # Name of the category
130
+ @recent_posts # Array of blog posts
131
+
132
+
133
+ =====================
134
+ Customizing your blog
135
+ =====================
136
+
49
137
  Specify the Blog Layout
50
138
  -----------------------
51
139
  We've provided a default layout but we expect you'll want the blog to appear your branded layout so we've made this as simple as defining config.blog_layout.
@@ -55,35 +143,51 @@ We've provided a default layout but we expect you'll want the blog to appear you
55
143
  # In application.rb (or an initializer like constants.rb)
56
144
  config.blog_layout = "<your_blog_layout>"
57
145
 
58
- Note that an ideal layout simply defines the header and footer for the page and <%= yields %> the main body. Restart the server and go to localhost:3000/blog and you'll see your new branded blog!
146
+ Note that an ideal layout simply defines the header and footer for the page and `<%= yields %>` the main body. Restart the server and go to localhost:3000/blog and you'll see your new branded blog!
147
+
148
+ Customizing the view templates
149
+ ------------------------------
150
+ You can customize any view of your blog. Here is full list of page types + settings:
151
+
152
+ .. code:: ruby
153
+
154
+ # In application.rb
155
+ config.blog_home_template = "blog/home"
156
+ config.blog_post_template = "blog/post"
157
+ config.blog_author_template = "blog/author"
158
+ config.blog_category_template = "blog/category"
159
+
160
+ We recommend putting any custom templates in `views/blog/<template>.html.erb`
161
+
162
+ Below is a specific example of how to customize your blog post view to include Discus comments.
59
163
 
60
164
  Add comments to blog post template
61
165
  ----------------------------------
62
166
  If you want to customize the blog post template (for example to add `Disqus
63
167
  <https://disqus.com/>`_ comments at the bottom), it's simple:
64
168
 
65
- First create your template. We recommend putting it in `views/blog/post.html.erb`
169
+ First create your template: `views/blog/post.html.erb`
66
170
 
67
171
  .. code:: html
68
172
 
69
- <div class="post-preview">
70
- <h2 class="post-title">
173
+ <div class="post">
174
+ <h2 class="title">
71
175
  <%= @post['title'] %>
72
176
  </h2>
73
177
 
74
- <p class="post-meta">
178
+ <p class="meta">
75
179
  Posted by
76
180
  <%= link_to("#{@post['author']['first_name']} #{@post['author']['last_name']}", blog_author_path(:author_slug => @post['author']['slug'])) %>
77
181
  on <%= @post['created'] %>
78
182
 
79
183
  <% @post['categories'].each do |category| %>
80
- <span class="label label-default">
184
+ <span class="label">
81
185
  <%= link_to(category['name'], blog_category_path(:category_slug => category['slug'])) %>
82
186
  </span>
83
187
  <% end %>
84
188
  </p>
85
189
 
86
- <p class="post-body">
190
+ <p class="body">
87
191
  <%= @post['body'].html_safe %>
88
192
  </p>
89
193
  </div>
@@ -99,15 +203,4 @@ Then tell Butter about this template:
99
203
  # In application.rb
100
204
  config.blog_post_template = "blog/post"
101
205
 
102
-
103
- Customize other templates
104
- -------------------------
105
- You can customize other parts of the blog as well by following the same pattern. A full list of page types + settings is below:
106
-
107
- .. code:: ruby
108
-
109
- # In application.rb
110
- config.blog_home_template = "blog/home"
111
- config.blog_post_template = "blog/post"
112
- config.blog_author_template = "blog/author"
113
- config.blog_category_template = "blog/category"
206
+ That's it. Reload the server and you'll see your new customized blog post with comments!
@@ -15,7 +15,11 @@ module Buttercms
15
15
  end
16
16
 
17
17
  def get_token
18
- if Rails.application.secrets.BUTTER_CMS_TOKEN
18
+ # Rails 3
19
+ if defined? Buttercms::BUTTER_CMS_TOKEN
20
+ return Buttercms::BUTTER_CMS_TOKEN
21
+ # Rails 4
22
+ elsif defined? Rails.application.secrets.BUTTER_CMS_TOKEN
19
23
  return Rails.application.secrets.BUTTER_CMS_TOKEN
20
24
  else
21
25
  return DEFAULT_TOKEN
@@ -28,6 +32,8 @@ module Buttercms
28
32
  rescue SocketError => e
29
33
  raise Exception.new("Unable to connect to ButterCms. Please double check your internet connection.")
30
34
  rescue => e
35
+ puts e.message
36
+
31
37
  case e.response.code
32
38
  when 404
33
39
  not_found
data/buttercms.gemspec CHANGED
@@ -20,14 +20,10 @@ Gem::Specification.new do |spec|
20
20
  spec.files = `git ls-files -z`.split("\x0")
21
21
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
22
 
23
- # spec.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
24
- # spec.test_files = Dir["test/**/*"]
25
- # spec.add_dependency "rails", "~> 4.2.1"
26
-
27
- spec.add_development_dependency "bundler", "~> 1.7"
28
- spec.add_development_dependency "rake", "~> 10.0"
29
- spec.add_development_dependency "json"
30
- spec.add_development_dependency "rest-client"
23
+ spec.add_dependency "bundler", "~> 1.7"
24
+ spec.add_dependency "rake", "~> 10.0"
25
+ spec.add_dependency "json"
26
+ spec.add_dependency "rest-client"
31
27
 
32
28
 
33
29
  end
@@ -1,3 +1,3 @@
1
1
  module Buttercms
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buttercms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - ButterCms
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-13 00:00:00.000000000 Z
11
+ date: 2015-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -17,7 +17,7 @@ dependencies:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.7'
20
- type: :development
20
+ type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
@@ -31,7 +31,7 @@ dependencies:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.0'
34
- type: :development
34
+ type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
@@ -45,7 +45,7 @@ dependencies:
45
45
  - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
- type: :development
48
+ type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
@@ -59,7 +59,7 @@ dependencies:
59
59
  - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
- type: :development
62
+ type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements: