buttercms 0.1.4 → 0.1.5

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: 011636c65a7805bebf4508d06043e5c530d5c281
4
- data.tar.gz: ee5605a5e3854743db839c04cd033140c5de5797
3
+ metadata.gz: cdaf25f92202f5af0f2abe882d1d57e6dce8afaa
4
+ data.tar.gz: 68cc14b6e2510c9a3d9f2e330a0158d8c1d25050
5
5
  SHA512:
6
- metadata.gz: 8f1ad496e7bf4eaed110d89e2ae2ac2335117e2fb3cd5d06e66117f0240f74f4b025229f663ea4e8acbfa7f5c8e24096860de88c753a7989da8d8ca18f8dd93a
7
- data.tar.gz: 65c64531e34b81b33bb80dd4ad513bc06193f8801e8e77dea1e43f3641be0aecd8a0a3b2934e67f22062e311d1b46bcc9050c59ed6c61adb01d86004a7689492
6
+ metadata.gz: 5e30acd6680bf3702b9f870e7e11cdb3e473b5db66e5327973ce205a34a0a192a23b06e79f3ab38a516c553aa6442cda574a45d71196977a67fc6bab9db57ce6
7
+ data.tar.gz: 3d1b05d4449fb621dba58525fbbfc1daf7119e7855f81963b5b83693e90eac0ce186ce5277bf07deb322c25b323ec9bbe8661da5e3353576e2121bd60b4d0da7
@@ -7,13 +7,25 @@ module Buttercms
7
7
  API_URL = 'https://buttercms.com/api/'
8
8
 
9
9
  class BlogController < ApplicationController
10
+ layout :get_butter_layout
11
+ helper Rails.application.helpers
10
12
 
11
- def not_found
13
+ def get_butter_layout
14
+ if defined? Buttercms.configuration
15
+ if !Buttercms.configuration.layout.nil?
16
+ return Buttercms.configuration.layout
17
+ end
18
+ end
19
+
20
+ # Default to the included layout.
21
+ return "buttercms/application"
22
+ end
23
+
24
+ def butter_not_found
12
25
  raise ActionController::RoutingError.new('Not Found')
13
26
  end
14
27
 
15
- def get_token
16
-
28
+ def get_butter_token
17
29
  # Make sure the Buttercms has been initialized.
18
30
  if defined? Buttercms.configuration
19
31
  if defined? Buttercms.configuration.token
@@ -24,9 +36,9 @@ module Buttercms
24
36
  raise Exception.new("/config/intitializer/butter.rb is missing. Please run $ rails g buttercms:install")
25
37
  end
26
38
 
27
- def make_request(path)
39
+ def make_butter_request(path)
28
40
  begin
29
- response = RestClient.get path, {:Authorization => "Token #{get_token}"}
41
+ response = RestClient.get path, {:Authorization => "Token #{get_butter_token}"}
30
42
  rescue SocketError => e
31
43
  raise Exception.new("Unable to connect to ButterCms. Please double check your internet connection.")
32
44
  rescue => e
@@ -34,7 +46,7 @@ module Buttercms
34
46
 
35
47
  case e.response.code
36
48
  when 404
37
- not_found
49
+ butter_not_found
38
50
  when 401
39
51
  raise Exception.new("This token has not been registered. Please register one @ https://buttercms.com/api_token/")
40
52
  else
@@ -45,7 +57,7 @@ module Buttercms
45
57
  return response
46
58
  end
47
59
 
48
- def home
60
+ def butter_home
49
61
  # Check for pagination
50
62
  if params[:page]
51
63
  page_param = "?page=#{params[:page]}"
@@ -53,7 +65,7 @@ module Buttercms
53
65
  page_param = ''
54
66
  end
55
67
 
56
- response = make_request("#{API_URL}posts/#{page_param}")
68
+ response = make_butter_request("#{API_URL}posts/#{page_param}")
57
69
  response_json = JSON.parse(response)
58
70
  @next_page = response_json['next_page']
59
71
  @previous_page = response_json['previous_page']
@@ -66,8 +78,8 @@ module Buttercms
66
78
  end
67
79
  end
68
80
 
69
- def post
70
- response = make_request("#{API_URL}posts/#{params[:slug]}")
81
+ def butter_post
82
+ response = make_butter_request("#{API_URL}posts/#{params[:slug]}")
71
83
  @post = JSON.parse(response)
72
84
 
73
85
  if defined? Buttercms.configuration
@@ -77,8 +89,8 @@ module Buttercms
77
89
  end
78
90
  end
79
91
 
80
- def author
81
- response = make_request("#{API_URL}authors/#{params[:author_slug]}")
92
+ def butter_author
93
+ response = make_butter_request("#{API_URL}authors/#{params[:author_slug]}")
82
94
  response_json = JSON.parse(response)
83
95
  @first_name = response_json['first_name']
84
96
  @last_name = response_json['last_name']
@@ -91,8 +103,8 @@ module Buttercms
91
103
  end
92
104
  end
93
105
 
94
- def category
95
- response = make_request("#{API_URL}categories/#{params[:category_slug]}")
106
+ def butter_category
107
+ response = make_butter_request("#{API_URL}categories/#{params[:category_slug]}")
96
108
  response_json = JSON.parse(response)
97
109
  @name = response_json['name']
98
110
  @recent_posts = response_json['recent_posts']
data/config/routes.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  Buttercms::Engine.routes.draw do
2
- get '/' => 'blog#home', as: :blog
3
- get '/page/:page' => 'blog#home', as: :archive
4
- get '/author/:author_slug' => 'blog#author', as: :blog_author
5
- get '/category/:category_slug' => 'blog#category', as: :blog_category
2
+ get '/' => 'blog#butter_home', as: :blog
3
+ get '/page/:page' => 'blog#butter_home', as: :archive
4
+ get '/author/:author_slug' => 'blog#butter_author', as: :blog_author
5
+ get '/category/:category_slug' => 'blog#butter_category', as: :blog_category
6
6
 
7
7
  # This must appear last since it's a catch all
8
- get '/:slug' => 'blog#post', as: :blog_post
8
+ get '/:slug' => 'blog#butter_post', as: :blog_post
9
9
  end
@@ -1,3 +1,3 @@
1
1
  module Buttercms
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buttercms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - ButterCms
@@ -84,15 +84,14 @@ files:
84
84
  - app/assets/images/buttercms/.keep
85
85
  - app/assets/javascripts/buttercms/application.js
86
86
  - app/assets/stylesheets/buttercms/application.css
87
- - app/controllers/buttercms/application_controller.rb
88
87
  - app/controllers/buttercms/blog_controller.rb
89
88
  - app/helpers/buttercms/application_helper.rb
90
89
  - app/views/buttercms/blog/_pagers.html.erb
91
90
  - app/views/buttercms/blog/_post.html.erb
92
- - app/views/buttercms/blog/author.html.erb
93
- - app/views/buttercms/blog/category.html.erb
94
- - app/views/buttercms/blog/home.html.erb
95
- - app/views/buttercms/blog/post.html.erb
91
+ - app/views/buttercms/blog/butter_author.html.erb
92
+ - app/views/buttercms/blog/butter_category.html.erb
93
+ - app/views/buttercms/blog/butter_home.html.erb
94
+ - app/views/buttercms/blog/butter_post.html.erb
96
95
  - app/views/layouts/buttercms/application.html.erb
97
96
  - bin/rails
98
97
  - buttercms.gemspec
@@ -1,17 +0,0 @@
1
- module Buttercms
2
- class ApplicationController < ActionController::Base
3
- layout :get_layout
4
- helper Rails.application.helpers
5
-
6
- def get_layout
7
- if defined? Buttercms.configuration
8
- if !Buttercms.configuration.layout.nil?
9
- return Buttercms.configuration.layout
10
- end
11
- end
12
-
13
- # Default to the included layout.
14
- return "buttercms/application"
15
- end
16
- end
17
- end