buttercms 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 45e2252eee39b31c0a91efb2dfeeeeac7e305a95
4
- data.tar.gz: 8e33b39e32a8dac8806b84297af2554b7aa6d697
3
+ metadata.gz: 3244e5e1565d4a57f022236036ce1950e27744f2
4
+ data.tar.gz: fc3fbffba109a913e350b518f58309f35ff4bbbe
5
5
  SHA512:
6
- metadata.gz: c52380177f1a93f317d6dbb7dcc56996c2838a9d335c3e7a21314310f71fb5ae76fdc78ad3312d5a44ea717602124b6bb1da9afb79dfb428f90576169ae41b04
7
- data.tar.gz: 911ee20a90c3887948b13fe4d3a8a2f7dc95b4e3049154412fca87d51274f8686273698ad3431875c0b226e05f793d66da1659d82637169c05bfb71c49112710
6
+ metadata.gz: 2b5c1fdcd7884125147391c7c03d99d8b507226caeb1037ca872126c29d1f0cdcf480abbd489b30140c49b4766f296c4d68a2004eb37e84c4d444919b6a73b75
7
+ data.tar.gz: 07aed0d6394defb4db0c39672095981cceee77936d6c60e5ef6378463aaeb47973d763d46f23193b37ec1d415ff75343bde248d0bc043115c11e0bbf3313d71e
data/README.rst CHANGED
@@ -59,126 +59,3 @@ We've provided a default layout but we expect you'll want the blog to appear you
59
59
  config.layout = "<your_blog_layout>"
60
60
 
61
61
  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 http://localhost:3000/blog and you'll see your new branded blog!
62
-
63
- Customizing the view templates
64
- ------------------------------
65
- You can customize any view of your blog. Here is full list of page types + settings:
66
-
67
- .. code:: ruby
68
-
69
- # In initializers/butter.rb
70
- config.home_template = "blog/home"
71
- config.post_template = "blog/post"
72
- config.author_template = "blog/author"
73
- config.category_template = "blog/category"
74
-
75
- We recommend putting any custom templates in `views/blog/<template>.html.erb`
76
-
77
- Below is a specific example of how to customize your blog post view to include Discus comments.
78
-
79
- Add comments to blog post template
80
- ----------------------------------
81
- If you want to customize the blog post template (for example to add `Disqus
82
- <https://disqus.com/>`_ comments at the bottom), it's simple:
83
-
84
- First create your template: `views/blog/post.html.erb`
85
-
86
- .. code:: html
87
-
88
- <div class="post">
89
- <h2 class="title">
90
- <%= @post['title'] %>
91
- </h2>
92
-
93
- <p class="meta">
94
- Posted by
95
- <%= link_to("#{@post['author']['first_name']} #{@post['author']['last_name']}", blog_author_path(:author_slug => @post['author']['slug'])) %>
96
- on <%= @post['created'] %>
97
-
98
- <% @post['categories'].each do |category| %>
99
- <span class="label">
100
- <%= link_to(category['name'], blog_category_path(:category_slug => category['slug'])) %>
101
- </span>
102
- <% end %>
103
- </p>
104
-
105
- <p class="body">
106
- <%= @post['body'].html_safe %>
107
- </p>
108
- </div>
109
-
110
- <hr>
111
-
112
- <!-- Paste your Disqus embed code here --->
113
-
114
- Then tell Butter about this template:
115
-
116
- .. code:: ruby
117
-
118
- # In initializers/butter.rb
119
- config.post_template = "blog/post"
120
-
121
- That's it. Reload the server and you'll see your new customized blog post with comments!
122
-
123
-
124
- ==========================
125
- Overview of key blog views
126
- ==========================
127
- 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.
128
-
129
- Here's an overview each action+view and the available content:
130
-
131
- home: /blog
132
- -----------
133
- .. code:: ruby
134
-
135
- @next_page # Integer used for blog post pagination (i.e. 2)
136
- @previous_page # Integer used for blog post pagination (i.e. 1)
137
- @recent_posts # Array of blog posts
138
-
139
- post: /blog/:post-slug
140
- ----------------------
141
- .. code:: ruby
142
-
143
- @post # All content for a blog post
144
-
145
- =begin
146
- @post has the following structure
147
- "url": "https://buttercms.com/blog/the-state-of-company-blogs",
148
- "created": "05/16/2015",
149
- "author": {
150
- "first_name": "Butter",
151
- "last_name": "Cms",
152
- "slug": "butter-cms"
153
- },
154
- "categories": [
155
- {
156
- "name": "blogs",
157
- "slug": "blogs"
158
- },
159
- {
160
- "name": "butter",
161
- "slug": "butter"
162
- }
163
- ],
164
- "slug": "the-state-of-company-blogs",
165
- "title": "The State of Company Blogs",
166
- "body": "<h3>The problem</h3><p>Countless people and essentially every...</p>",
167
- "summary": <h3>The problem</h3><p>Countless people and essentially...</p>,
168
- "status": "published"
169
- =end
170
-
171
- author: /blog/author/:author-slug
172
- ---------------------------------
173
- .. code:: ruby
174
-
175
- @first_name # First name of author
176
- @last_name # Last name of author
177
- @recent_posts # Array of blog posts
178
-
179
- category: /blog/category/:category-slug
180
- ---------------------------------------
181
- .. code:: ruby
182
-
183
- @name # Name of the category
184
- @recent_posts # Array of blog posts
@@ -95,22 +95,14 @@ module Buttercms
95
95
  @previous_page = response_json['previous_page']
96
96
  @recent_posts = response_json['results']
97
97
 
98
- if defined? Buttercms.configuration
99
- if !Buttercms.configuration.home_template.nil?
100
- render template: Buttercms.configuration.home_template
101
- end
102
- end
98
+ render template: "blog/home"
103
99
  end
104
100
 
105
101
  def butter_post
106
102
  response = make_butter_request("#{API_URL}posts/#{params[:slug]}")
107
103
  @post = JSON.parse(response)
108
104
 
109
- if defined? Buttercms.configuration
110
- if !Buttercms.configuration.post_template.nil?
111
- render template: Buttercms.configuration.post_template
112
- end
113
- end
105
+ render template: "blog/post"
114
106
  end
115
107
 
116
108
  def butter_author
@@ -121,11 +113,7 @@ module Buttercms
121
113
  @email = response_json['email']
122
114
  @recent_posts = response_json['recent_posts']
123
115
 
124
- if defined? Buttercms.configuration
125
- if !Buttercms.configuration.author_template.nil?
126
- render template: Buttercms.configuration.author_template
127
- end
128
- end
116
+ render template: "blog/author"
129
117
  end
130
118
 
131
119
  def butter_category
@@ -134,11 +122,7 @@ module Buttercms
134
122
  @name = response_json['name']
135
123
  @recent_posts = response_json['recent_posts']
136
124
 
137
- if defined? Buttercms.configuration
138
- if !Buttercms.configuration.category_template.nil?
139
- render template: Buttercms.configuration.category_template
140
- end
141
- end
125
+ render template: "blog/category"
142
126
  end
143
127
  end
144
128
  end
@@ -1,3 +1,3 @@
1
1
  module Buttercms
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
@@ -2,13 +2,22 @@ module Buttercms
2
2
  module Generators
3
3
  class InstallGenerator < Rails::Generators::Base
4
4
  source_root File.expand_path("../../templates", __FILE__)
5
- desc "Creates Buttercms initializer for your application"
5
+ desc "Creates Butter initializer and blog views for your application."
6
6
 
7
7
  def copy_initializer
8
- template "butter_initializer.rb", "config/initializers/butter.rb"
9
- route "mount Buttercms::Engine => '/blog'"
8
+ puts "Copying blog templates into app/views/blog/"
9
+ copy_file "home.html.erb", "app/views/blog/home.html.erb"
10
+ copy_file "post.html.erb", "app/views/blog/post.html.erb"
11
+ copy_file "author.html.erb", "app/views/blog/author.html.erb"
12
+ copy_file "category.html.erb", "app/views/blog/category.html.erb"
13
+ copy_file "_pagers.html.erb", "app/views/blog/_pagers.html.erb"
14
+ copy_file "_post.html.erb", "app/views/blog/_post.html.erb"
15
+ puts "Success"
10
16
 
11
- puts "Butter token and route installed! See your blog at localhost:3000/blog"
17
+ puts "Installing ButterCMS API token and /blog route."
18
+ copy_file "butter_initializer.rb", "config/initializers/butter.rb"
19
+ route "mount Buttercms::Engine => '/blog'"
20
+ puts "Success! View your blog at localhost:3000/blog"
12
21
  end
13
22
  end
14
23
  end
@@ -1,6 +1,6 @@
1
1
  <ul class="pager">
2
2
  <% if next_page %>
3
- <li class="previous">
3
+ <li class="next">
4
4
  <%= link_to("&larr; Older Posts".html_safe, archive_path(:page => next_page)) %>
5
5
  </li>
6
6
  <% end %>
@@ -6,7 +6,7 @@
6
6
  <p class="post-meta">
7
7
  Posted by
8
8
  <%= link_to("#{post['author']['first_name']} #{post['author']['last_name']}", blog_author_path(:author_slug => post['author']['slug'])) %>
9
- on <%= post['created'] %>
9
+ on <%= post['published'] %>
10
10
 
11
11
  <% post['categories'].each do |category| %>
12
12
  <span class="label label-default">
@@ -0,0 +1,3 @@
1
+ <h2>Recent posts from <%=@first_name %> <%=@last_name %> (<%=@email %>)</h2>
2
+
3
+ <%= render partial: "blog/post", collection: @recent_posts %>
@@ -8,20 +8,4 @@ Buttercms.configure do |config|
8
8
  # For example uncomment the line below and define the layout in /view/layout/blog.html.erb
9
9
  # You can of course also use your existing main application layout.
10
10
  # config.layout = "blog"
11
-
12
-
13
- # You can customize any view of your blog. Here is full list of page types + settings.
14
- # We recommend putting custom templates in views/blog/<template>.html.erb
15
-
16
- # This is the blog home page. Route: /blog
17
- # config.home_template = "blog/home"
18
-
19
- # This is the blog post page. Route: /blog/:post-slug
20
- # config.post_template = "blog/post"
21
-
22
- # This is the author page. Route: /blog/author/:author-slug
23
- # config.author_template = "blog/author"
24
-
25
- # This is the category page. Route: /blog/category/:category-slug
26
- # config.category_template = "blog/category"
27
11
  end
@@ -0,0 +1,3 @@
1
+ <h2>Recent <%=@name %> posts</h2>
2
+
3
+ <%= render partial: "blog/post", collection: @recent_posts %>
@@ -0,0 +1,3 @@
1
+ <%= render partial: "blog/post", collection: @recent_posts %>
2
+
3
+ <%= render partial: "blog/pagers", locals: {next_page: @next_page, previous_page: @previous_page} %>
@@ -0,0 +1,76 @@
1
+ <!--
2
+ For reference, @post has the following attributes:
3
+
4
+ "url": "https://buttercms.com/blog/the-state-of-company-blogs",
5
+ "created": "05/16/2015",
6
+ "published": "05/16/2015",
7
+ "author": {
8
+ "first_name": "Butter",
9
+ "last_name": "Cms",
10
+ "email": "buttercms@example.com",
11
+ "slug": "butter-cms"
12
+ },
13
+ "categories": [
14
+ {
15
+ "name": "blogs",
16
+ "slug": "blogs"
17
+ },
18
+ {
19
+ "name": "butter",
20
+ "slug": "butter"
21
+ }
22
+ ],
23
+ "slug": "the-state-of-company-blogs",
24
+ "title": "The State of Company Blogs",
25
+ "featured_image": "http://www.example.com/image.png",
26
+ "body": "<h3>The problem</h3><p>Countless people and essentially every...</p>",
27
+ "summary": <h3>The problem</h3><p>Countless people and essentially...</p>,
28
+ "status": "published"
29
+ -->
30
+
31
+ <div class="post-preview">
32
+ <h2 class="post-title">
33
+ <%= @post['title'] %>
34
+ </h2>
35
+
36
+ <p class="post-meta">
37
+ Posted by
38
+ <%= link_to("#{@post['author']['first_name']} #{@post['author']['last_name']}",
39
+ blog_author_path(:author_slug => @post['author']['slug'])) %>
40
+ on
41
+ <%= @post['published'] %>
42
+
43
+ <% @post['categories'].each do |category| %>
44
+ <span class="label label-default">
45
+ <%= link_to(category['name'], blog_category_path(:category_slug => category['slug'])) %>
46
+ </span>
47
+ <% end %>
48
+ </p>
49
+
50
+ <p class="post-body">
51
+ <%= @post['body'].html_safe %>
52
+ </p>
53
+ </div>
54
+
55
+
56
+ <!--
57
+ // For post comments, we recommend https://disqus.com/
58
+ // Create a Disqus account and paste your embed code below.
59
+ // Here's a sample
60
+ <hr>
61
+
62
+ <div id="disqus_thread"></div>
63
+ <script type="text/javascript">
64
+ /* * * CONFIGURATION VARIABLES * * */
65
+ var disqus_shortname = 'XXXXXXXX';
66
+
67
+ /* * * DON'T EDIT BELOW THIS LINE * * */
68
+ (function() {
69
+ var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
70
+ dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
71
+ (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
72
+ })();
73
+ </script>
74
+ -->
75
+
76
+ </div>
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.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - ButterCms
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-16 00:00:00.000000000 Z
11
+ date: 2015-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -85,12 +85,6 @@ files:
85
85
  - app/assets/stylesheets/buttercms/application.css
86
86
  - app/controllers/buttercms/blog_controller.rb
87
87
  - app/helpers/buttercms/application_helper.rb
88
- - app/views/buttercms/blog/_pagers.html.erb
89
- - app/views/buttercms/blog/_post.html.erb
90
- - app/views/buttercms/blog/butter_author.html.erb
91
- - app/views/buttercms/blog/butter_category.html.erb
92
- - app/views/buttercms/blog/butter_home.html.erb
93
- - app/views/buttercms/blog/butter_post.html.erb
94
88
  - app/views/layouts/buttercms/application.html.erb
95
89
  - buttercms.gemspec
96
90
  - config/routes.rb
@@ -98,7 +92,13 @@ files:
98
92
  - lib/buttercms/engine.rb
99
93
  - lib/buttercms/version.rb
100
94
  - lib/generators/buttercms/install_generator.rb
95
+ - lib/generators/templates/_pagers.html.erb
96
+ - lib/generators/templates/_post.html.erb
97
+ - lib/generators/templates/author.html.erb
101
98
  - lib/generators/templates/butter_initializer.rb
99
+ - lib/generators/templates/category.html.erb
100
+ - lib/generators/templates/home.html.erb
101
+ - lib/generators/templates/post.html.erb
102
102
  - lib/tasks/buttercms_tasks.rake
103
103
  - test/buttercms_test.rb
104
104
  - test/integration/navigation_test.rb
@@ -1,3 +0,0 @@
1
- <h2>Recent posts from <%=@first_name %> <%=@last_name %></h2>
2
-
3
- <%= render partial: "post", collection: @recent_posts %>
@@ -1,3 +0,0 @@
1
- <h2>Recent <%=@name %> posts</h2>
2
-
3
- <%= render partial: "post", collection: @recent_posts %>
@@ -1,3 +0,0 @@
1
- <%= render partial: "post", collection: @recent_posts %>
2
-
3
- <%= render partial: "pagers", locals: {next_page: @next_page, previous_page: @previous_page} %>
@@ -1,22 +0,0 @@
1
- <div class="post-preview">
2
-
3
- <h2 class="post-title">
4
- <%= @post['title'] %>
5
- </h2>
6
-
7
- <p class="post-meta">
8
- Posted by
9
- <%= link_to("#{@post['author']['first_name']} #{@post['author']['last_name']}", blog_author_path(:author_slug => @post['author']['slug'])) %>
10
- on <%= @post['created'] %>
11
-
12
- <% @post['categories'].each do |category| %>
13
- <span class="label label-default">
14
- <%= link_to(category['name'], blog_category_path(:category_slug => category['slug'])) %>
15
- </span>
16
- <% end %>
17
- </p>
18
-
19
- <p class="post-body">
20
- <%= @post['body'].html_safe %>
21
- </p>
22
- </div>