buttercms-rails 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5b7d9e3d4a7a3c021b5f5722d36969dc3a923ebe
4
+ data.tar.gz: e0c31ec249e7275ed72c017d6d70c16c9cc0a9a7
5
+ SHA512:
6
+ metadata.gz: ea18f9957675892feabc232b766c300d46a6a9e7c2451e95890a7849c8d2ce57c000d79bf34fe41cff8b9d90fdb24d8fc0ca859279a159aa113b2c903ed9497f
7
+ data.tar.gz: 0198992bd5ddbd2b263d12624181ae4dfbe017ebbcb22934c42e768c6d8bad9ae88d857b28f18d9d70821068d1f2025f1eb69d83135bf13970b36aad7b1eee7c
@@ -0,0 +1,44 @@
1
+ *.rbc
2
+ capybara-*.html
3
+ .rspec
4
+ /log
5
+ /tmp
6
+ /db/*.sqlite3
7
+ /db/*.sqlite3-journal
8
+ /public/system
9
+ /coverage/
10
+ /spec/tmp
11
+ /Gemfile.lock
12
+ **.orig
13
+ rerun.txt
14
+ pickle-email-*.html
15
+
16
+ # TODO Comment out these rules if you are OK with secrets being uploaded to the repo
17
+ config/initializers/secret_token.rb
18
+ config/secrets.yml
19
+
20
+ ## Environment normalisation:
21
+ /.bundle
22
+ /vendor/bundle
23
+
24
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
25
+ .rvmrc
26
+
27
+ # if using bower-rails ignore default bower_components path bower.json files
28
+ /vendor/assets/bower_components
29
+ *.bowerrc
30
+ bower.json
31
+
32
+ # Ignore pow environment settings
33
+ .powenv
34
+
35
+ pkg/*
36
+ *.log
37
+
38
+ .DS_Store
39
+
40
+
41
+ test/dummy/tmp/
42
+ test/dummy/db/development.sqlite3
43
+ test/dummy/db/production.sqlite3
44
+ test/dummy/log/test.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Butter
4
+ https://buttercms.com/
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
@@ -0,0 +1,69 @@
1
+ # ButterCMS Rails SDK
2
+
3
+ The ButterCMS Rails SDK provides a generator that expedites setup of your blog.
4
+
5
+ ### Installation
6
+
7
+ To get started, first install the gem by adding it to your Gemfile:
8
+
9
+ ```
10
+ gem 'buttercms-rails', '1.0.0'
11
+ ```
12
+
13
+ After installing, run the genereator provided by the gem:
14
+
15
+ ```
16
+ rails generate butter:install_blog
17
+ ```
18
+
19
+ The generator creates an initializer file and default controllers and views:
20
+
21
+ ```
22
+ |-- app
23
+ |-- controllers
24
+ |-- buttercms
25
+ |-- authors_controller.rb
26
+ |-- base_controller.rb
27
+ |-- categories_controller.rb
28
+ |-- feeds_controller.rb
29
+ |-- posts_controller.rb
30
+ |-- views
31
+ |-- buttercms
32
+ |-- authors
33
+ |-- show.html.erb
34
+ |-- categories
35
+ |-- show.html.erb
36
+ |-- posts
37
+ |-- _post.html.erb
38
+ |-- index.html.erb
39
+ |-- show.html.erb
40
+ |-- layouts
41
+ |-- buttercms
42
+ |-- default.html.erb
43
+
44
+ |-- config
45
+ |-- initializers
46
+ |-- buttercms.rb
47
+ ```
48
+
49
+ It also adds routes to your `routes.rb` file:
50
+
51
+ ```ruby
52
+ scope :module => 'buttercms' do
53
+ get '/categories/:slug' => 'categories#show', :as => :buttercms_category
54
+ get '/author/:slug' => 'authors#show', :as => :buttercms_author
55
+
56
+ get '/blog/rss' => 'feeds#rss', :format => 'rss', :as => :buttercms_blog_rss
57
+ get '/blog/atom' => 'feeds#atom', :format => 'atom', :as => :buttercms_blog_atom
58
+ get '/blog/sitemap.xml' => 'feeds#sitemap', :format => 'xml', :as => :buttercms_blog_sitemap
59
+
60
+ get '/blog(/page/:page)' => 'posts#index', :defaults => {:page => 1}, :as => :buttercms_blog
61
+ get '/blog/:slug' => 'posts#show', :as => :buttercms_post
62
+ end
63
+ ```
64
+
65
+ After running the generator, set your API token in `config/initializers/buttercms.rb` and then start your server to view your blog.
66
+
67
+ ### Customization
68
+
69
+ Extending and customizing your blog is easy. The ButterCMS Rails SDK uses the [ButterCMS Ruby API Client](https://github.com/buttercms/buttercms-ruby). Email [support@buttercms.com](mailto:support@buttercms.com) for help!
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.1
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.unshift(File.join(File.dirname(__FILE__), 'lib'))
3
+
4
+ require "butter/version"
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "buttercms-rails"
8
+ s.version = Butter::VERSION
9
+ s.required_ruby_version = '>= 1.9.3'
10
+ s.require_paths = ["lib"]
11
+ s.summary = 'A Rails gem for the buttercms.com REST API'
12
+ s.description = 'Butter is a blogging platform loved by engineers. See https://buttercms.com for details.'
13
+ s.authors = ["ButterCMS"]
14
+ s.email= ["support@buttercms.com"]
15
+ s.homepage = "https://buttercms.com/docs"
16
+ s.license = 'MIT'
17
+
18
+ s.add_runtime_dependency "buttercms-ruby", "~> 1.0.1"
19
+ s.add_development_dependency "rails", ">= 3.2.0"
20
+
21
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
+ s.files = `git ls-files`.split("\n")
23
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
24
+ end
@@ -0,0 +1,3 @@
1
+ module Butter
2
+ VERSION = "1.0.1"
3
+ end
@@ -0,0 +1,5 @@
1
+ require 'rails/generators'
2
+ require "generators/butter/install_blog_generator"
3
+
4
+ module Butter
5
+ end
@@ -0,0 +1,39 @@
1
+ module Butter
2
+ module Generators
3
+ class InstallBlogGenerator < Rails::Generators::Base
4
+ source_root File.expand_path("../../templates", __FILE__)
5
+
6
+ desc "Creates ButterCMS initializer, controllers, views, and routes."
7
+ def install
8
+ # Create initializer
9
+ copy_file "config/initializers/buttercms.rb", "config/initializers/buttercms.rb"
10
+
11
+ # Create controllers
12
+ directory "app/controllers/buttercms", "app/controllers/buttercms"
13
+
14
+ # Create views
15
+ directory "app/views/buttercms", "app/views/buttercms"
16
+
17
+ # Create default layout
18
+ directory "app/views/layouts/buttercms", "app/views/layouts/buttercms"
19
+
20
+ # Add routes
21
+ route %{
22
+ scope :module => 'buttercms' do
23
+ get '/categories/:slug' => 'categories#show', :as => :buttercms_category
24
+ get '/author/:slug' => 'authors#show', :as => :buttercms_author
25
+
26
+ get '/blog/rss' => 'feeds#rss', :format => 'rss', :as => :buttercms_blog_rss
27
+ get '/blog/atom' => 'feeds#atom', :format => 'atom', :as => :buttercms_blog_atom
28
+ get '/blog/sitemap.xml' => 'feeds#sitemap', :format => 'xml', :as => :buttercms_blog_sitemap
29
+
30
+ get '/blog(/page/:page)' => 'posts#index', :defaults => {:page => 1}, :as => :buttercms_blog
31
+ get '/blog/:slug' => 'posts#show', :as => :buttercms_post
32
+ end
33
+ }
34
+
35
+ puts "Success! Configure your API token in config/initializers/buttercms.rb, restart your server, and view your blog at /blog"
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,5 @@
1
+ class Buttercms::AuthorsController < Buttercms::BaseController
2
+ def show
3
+ @author = ButterCMS::Author.find(params[:slug], :include => :recent_posts)
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class Buttercms::BaseController < ActionController::Base
2
+ # You can of course change this layout to your main application layout
3
+ # to have your blog match the rest of your site.
4
+ layout 'buttercms/default'
5
+ end
@@ -0,0 +1,5 @@
1
+ class Buttercms::CategoriesController < Buttercms::BaseController
2
+ def show
3
+ @category = ButterCMS::Category.find(params[:slug], :include => :recent_posts)
4
+ end
5
+ end
@@ -0,0 +1,19 @@
1
+ class Buttercms::FeedsController < Buttercms::BaseController
2
+ def sitemap
3
+ feed = ButterCMS::Feed.find(:sitemap)
4
+
5
+ render :xml => feed.data
6
+ end
7
+
8
+ def atom
9
+ feed = ButterCMS::Feed.find(:atom)
10
+
11
+ render :xml => feed.data
12
+ end
13
+
14
+ def rss
15
+ feed = ButterCMS::Feed.find(:rss)
16
+
17
+ render :xml => feed.data
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ class Buttercms::PostsController < Buttercms::BaseController
2
+ def index
3
+ @posts = ButterCMS::Post.all(:page => params[:page], :page_size => 10)
4
+
5
+ @next_page = @posts.meta.next_page
6
+ @previous_page = @posts.meta.previous_page
7
+ end
8
+
9
+ def show
10
+ @post = ButterCMS::Post.find(params[:slug])
11
+
12
+ @next_post = @post.meta.next_post
13
+ @previous_post = @post.meta.previous_post
14
+ end
15
+ end
@@ -0,0 +1,17 @@
1
+ <%= content_for :html_title, "#{@author.first_name} #{@author.last_name}" %>
2
+ <%= content_for :meta_description, @author.bio %>
3
+
4
+ <!-- Author name -->
5
+ <h2><%= @author.first_name %> <%= @author.last_name %></h2>
6
+
7
+ <!-- Author profile -->
8
+ <div>
9
+ <%= @author.title %>
10
+ <%= @author.bio %>
11
+ </div>
12
+
13
+ <!-- Recent posts -->
14
+ <h4>Recent posts</h4>
15
+ <% @author.recent_posts.each do |post| %>
16
+ <%= render :partial => 'buttercms/posts/post', :locals => {:post => post} %>
17
+ <% end %>
@@ -0,0 +1,10 @@
1
+ <%= content_for :html_title, @category.name %>
2
+
3
+ <!-- Category name -->
4
+ <h2><%= @category.name %></h2>
5
+
6
+ <!-- Recent posts -->
7
+ <h4>Recent posts</h4>
8
+ <% @category.recent_posts.each do |post| %>
9
+ <%= render :partial => 'buttercms/posts/post', :locals => {:post => post} %>
10
+ <% end %>
@@ -0,0 +1,18 @@
1
+ <div>
2
+ <!-- Featured image -->
3
+ <%= image_tag(post.featured_image) if post.featured_image %>
4
+
5
+ <!-- Post title -->
6
+ <%= link_to post.title, buttercms_post_path(post.slug), :title => post.title %>
7
+
8
+ <!-- Post author -->
9
+ <%= link_to "#{post.author.first_name} #{post.author.last_name}", buttercms_author_path(post.author.slug) %>
10
+
11
+ <!-- Post summary -->
12
+ <%= post.summary %>
13
+
14
+ <!-- Post categories -->
15
+ <% post.categories.each do |category| %>
16
+ <%= link_to category.name, buttercms_category_path(category.slug), :title => category.name %>
17
+ <% end %>
18
+ </div>
@@ -0,0 +1,17 @@
1
+ <h2>Posts</h2>
2
+
3
+ <!-- List of posts -->
4
+ <% @posts.each do |post| %>
5
+ <%= render :partial => 'post', :locals => {:post => post} %>
6
+ <% end %>
7
+
8
+ <!-- Pagination links -->
9
+ <div>
10
+ <% if @previous_page %>
11
+ <%= link_to "Prev", buttercms_blog_path(:page => @previous_page) %>
12
+ <% end %>
13
+
14
+ <% if @next_page %>
15
+ <%= link_to "Next", buttercms_blog_path(:page => @next_page) %>
16
+ <% end %>
17
+ </div>
@@ -0,0 +1,42 @@
1
+ <%= content_for :html_title, @post.seo_title %>
2
+ <%= content_for :meta_description, @post.meta_description %>
3
+
4
+ <!-- Post title -->
5
+ <h2><%= @post.title %></h2>
6
+
7
+ <!-- Post author -->
8
+ <%= link_to "#{@post.author.first_name} #{@post.author.last_name}", buttercms_author_path(@post.author.slug) %>
9
+
10
+ <!-- Post categories -->
11
+ <% @post.categories.each do |category| %>
12
+ <%= link_to category.name, buttercms_category_path(category.slug), :title => category.name %>
13
+ <% end %>
14
+
15
+ <!-- Publish date -->
16
+ <%= @post.published %>
17
+
18
+ <!-- Post body -->
19
+ <%= @post.body.html_safe %>
20
+
21
+ <!-- Link to Next Post -->
22
+ <% if @next_post %>
23
+ <%= link_to @next_post.title, buttercms_post_path(@next_post.slug), :title => @next_post.title %>
24
+ <% end %>
25
+
26
+ <!--
27
+ // For commenting, we recommend https://disqus.com/
28
+ // Create a Disqus account and paste your snippet below
29
+
30
+ <div id="disqus_thread"></div>
31
+ <script type="text/javascript">
32
+ /* * * CONFIGURATION VARIABLES * * */
33
+ var disqus_shortname = 'XXXXXXXX';
34
+
35
+ /* * * DON'T EDIT BELOW THIS LINE * * */
36
+ (function() {
37
+ var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
38
+ dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
39
+ (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
40
+ })();
41
+ </script>
42
+ -->
@@ -0,0 +1,16 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title><%= content_for?(:html_title) ? "#{content_for(:html_title)} | My Blog" : "My Blog" %></title>
5
+
6
+ <meta name="description" content="<%= content_for?(:meta_description) ? content_for(:meta_description) : "My Blog" %>">
7
+
8
+ <link rel="alternate" type="application/atom+xml" title="My Blog - Atom" href="<%= buttercms_blog_atom_path %>">
9
+ <link rel="alternate" type="application/rss+xml" title="My Blog - RSS" href="<%= buttercms_blog_rss_path %>">
10
+ </head>
11
+ <body>
12
+ <%= link_to "Blog home", buttercms_blog_path %>
13
+
14
+ <%= yield %>
15
+ </body>
16
+ </html>
@@ -0,0 +1,6 @@
1
+ require 'buttercms-ruby'
2
+
3
+ # If you added the Heroku Butter add-on, ENV["BUTTER_TOKEN"] will be defined.
4
+ # Otherwise, grab your token at https://buttercms.com/profile/ and either set it below
5
+ # or in an environment variable.
6
+ ButterCMS::api_token = ENV['BUTTER_TOKEN']
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: buttercms-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - ButterCMS
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: buttercms-ruby
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 3.2.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 3.2.0
41
+ description: Butter is a blogging platform loved by engineers. See https://buttercms.com
42
+ for details.
43
+ email:
44
+ - support@buttercms.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - .gitignore
50
+ - Gemfile
51
+ - LICENSE
52
+ - README.md
53
+ - VERSION
54
+ - buttercms-rails.gemspec
55
+ - lib/butter/version.rb
56
+ - lib/buttercms-rails.rb
57
+ - lib/generators/butter/install_blog_generator.rb
58
+ - lib/generators/templates/app/controllers/buttercms/authors_controller.rb
59
+ - lib/generators/templates/app/controllers/buttercms/base_controller.rb
60
+ - lib/generators/templates/app/controllers/buttercms/categories_controller.rb
61
+ - lib/generators/templates/app/controllers/buttercms/feeds_controller.rb
62
+ - lib/generators/templates/app/controllers/buttercms/posts_controller.rb
63
+ - lib/generators/templates/app/views/buttercms/authors/show.html.erb
64
+ - lib/generators/templates/app/views/buttercms/categories/show.html.erb
65
+ - lib/generators/templates/app/views/buttercms/posts/_post.html.erb
66
+ - lib/generators/templates/app/views/buttercms/posts/index.html.erb
67
+ - lib/generators/templates/app/views/buttercms/posts/show.html.erb
68
+ - lib/generators/templates/app/views/layouts/buttercms/default.html.erb
69
+ - lib/generators/templates/config/initializers/buttercms.rb
70
+ homepage: https://buttercms.com/docs
71
+ licenses:
72
+ - MIT
73
+ metadata: {}
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: 1.9.3
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubyforge_project:
90
+ rubygems_version: 2.0.14
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: A Rails gem for the buttercms.com REST API
94
+ test_files: []