buttercms 0.1.4 → 0.1.5
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 +4 -4
- data/app/controllers/buttercms/blog_controller.rb +26 -14
- data/app/views/buttercms/blog/{author.html.erb → butter_author.html.erb} +0 -0
- data/app/views/buttercms/blog/{category.html.erb → butter_category.html.erb} +0 -0
- data/app/views/buttercms/blog/{home.html.erb → butter_home.html.erb} +0 -0
- data/app/views/buttercms/blog/{post.html.erb → butter_post.html.erb} +0 -0
- data/config/routes.rb +5 -5
- data/lib/buttercms/version.rb +1 -1
- metadata +5 -6
- data/app/controllers/buttercms/application_controller.rb +0 -17
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: cdaf25f92202f5af0f2abe882d1d57e6dce8afaa
         | 
| 4 | 
            +
              data.tar.gz: 68cc14b6e2510c9a3d9f2e330a0158d8c1d25050
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 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  | 
| 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  | 
| 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  | 
| 39 | 
            +
                def make_butter_request(path)
         | 
| 28 40 | 
             
                  begin
         | 
| 29 | 
            -
                    response = RestClient.get path, {:Authorization => "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 | 
            -
                         | 
| 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  | 
| 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 =  | 
| 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  | 
| 70 | 
            -
                  response =  | 
| 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  | 
| 81 | 
            -
                  response =  | 
| 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  | 
| 95 | 
            -
                  response =  | 
| 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']
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
    
        data/config/routes.rb
    CHANGED
    
    | @@ -1,9 +1,9 @@ | |
| 1 1 | 
             
            Buttercms::Engine.routes.draw do
         | 
| 2 | 
            -
                get '/' => 'blog# | 
| 3 | 
            -
                get '/page/:page' => 'blog# | 
| 4 | 
            -
                get '/author/:author_slug' => 'blog# | 
| 5 | 
            -
                get '/category/:category_slug' => 'blog# | 
| 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# | 
| 8 | 
            +
                get '/:slug' => 'blog#butter_post', as: :blog_post
         | 
| 9 9 | 
             
            end
         | 
    
        data/lib/buttercms/version.rb
    CHANGED
    
    
    
        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 | 
            +
              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/ | 
| 93 | 
            -
            - app/views/buttercms/blog/ | 
| 94 | 
            -
            - app/views/buttercms/blog/ | 
| 95 | 
            -
            - app/views/buttercms/blog/ | 
| 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
         |