buttercms 0.0.2 → 0.0.3

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: 93b6a0e0792ce8b2169b4667e7b9ec9c9dd14de5
4
- data.tar.gz: f800f177dca63d6ae49f47c572339de495e0b31f
3
+ metadata.gz: 55f6699fcd36b9e43d3e71e61efd09f864bc5766
4
+ data.tar.gz: 1735ef0367b65646be7a234be8ad6985581ef23f
5
5
  SHA512:
6
- metadata.gz: 7e24e9f5b41556dc688da01f17ffb074371fa42b44caa22dbaf182c8ff539f998abb26d8258dd21ab59eeb6c1778b4532767f017bb3bb0444f6da2f3a9aade0b
7
- data.tar.gz: e758cff407b66f481f8e6988c22a9c37cb9ed1cfefccd2adb00753c79aded5edbe97f0919532fec7fe9edbf2b934140707afeae52ec77ef611b48a67ee79a06b
6
+ metadata.gz: 8fc98f77fc5e32a8839921dc91c67f136ae9c01912669f973c1518cf192b69a6f201424a92140a4f260706bd930150014488a7867c04891049acdaccc053778f
7
+ data.tar.gz: c7fdd1b97b1fca18a552fd709ceecbc2274671d6a43be85d1a2d5a341812a82413d4fb0056b44cbb8f4cbec2c0ee14b87d86465c0310745a603990bef4d9253b
data/Rakefile CHANGED
@@ -1,39 +1 @@
1
- require "bundler/gem_tasks"
2
-
3
- # begin
4
- # require 'bundler/setup'
5
- # rescue LoadError
6
- # puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
- # end
8
-
9
- # require 'rdoc/task'
10
-
11
- # RDoc::Task.new(:rdoc) do |rdoc|
12
- # rdoc.rdoc_dir = 'rdoc'
13
- # rdoc.title = 'Buttercms'
14
- # rdoc.options << '--line-numbers'
15
- # rdoc.rdoc_files.include('README.rdoc')
16
- # rdoc.rdoc_files.include('lib/**/*.rb')
17
- # end
18
-
19
- # APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
20
- # load 'rails/tasks/engine.rake'
21
-
22
-
23
- # load 'rails/tasks/statistics.rake'
24
-
25
-
26
-
27
- # Bundler::GemHelper.install_tasks
28
-
29
- # require 'rake/testtask'
30
-
31
- # Rake::TestTask.new(:test) do |t|
32
- # t.libs << 'lib'
33
- # t.libs << 'test'
34
- # t.pattern = 'test/**/*_test.rb'
35
- # t.verbose = false
36
- # end
37
-
38
-
39
- # task default: :test
1
+ require "bundler/gem_tasks"
@@ -5,7 +5,7 @@ require 'rest-client'
5
5
  module Buttercms
6
6
 
7
7
  # Displays a default blog post with instructions on getting a personal token.
8
- DEFAULT_TOKEN = '6d7505c309afd84e80d806e8e2cb91be12b896ad'
8
+ DEFAULT_TOKEN = 'f97d131d955f48af0769a4c827bb47728cbd5d05'
9
9
  API_URL = 'https://buttercms.com/api/'
10
10
 
11
11
  class BlogController < ApplicationController
@@ -42,15 +42,33 @@ module Buttercms
42
42
  end
43
43
 
44
44
  def home
45
- response = make_request("#{API_URL}posts/")
46
- @recent_posts = JSON.parse(response)
45
+ # Check for pagination
46
+ if params[:page]
47
+ page_param = "?page=#{params[:page]}"
48
+ else
49
+ page_param = ''
50
+ end
51
+
52
+ p "#{API_URL}posts/#{page_param}"
53
+
54
+ response = make_request("#{API_URL}posts/#{page_param}")
55
+ response_json = JSON.parse(response)
56
+ @next_page = response_json['next_page']
57
+ @previous_page = response_json['previous_page']
58
+ @recent_posts = response_json['results']
47
59
  end
48
60
 
49
61
  def post
50
62
  response = make_request("#{API_URL}posts/#{params[:slug]}")
51
- @blog_post = JSON.parse(response)
63
+ @post = JSON.parse(response)
64
+ end
65
+
66
+ def author
67
+ response = make_request("#{API_URL}authors/#{params[:author_slug]}")
68
+ response_json = JSON.parse(response)
69
+ @first_name = response_json['first_name']
70
+ @last_name = response_json['last_name']
71
+ @recent_posts = response_json['recent_posts']
52
72
  end
53
73
  end
54
74
  end
55
-
56
-
@@ -0,0 +1,19 @@
1
+ <h2>Recent posts from <%=@first_name %> <%=@last_name %></h2>
2
+
3
+ <% @recent_posts.each do |post| %>
4
+ <div class="post-preview">
5
+ <h2 class="post-title">
6
+ <%= link_to(post['title'], blog_post_path(:slug => post['slug'])) %>
7
+ </h2>
8
+
9
+ <p class="post-meta">
10
+ Posted by
11
+ <%= link_to("#{post['author']['first_name']} #{post['author']['last_name']}", blog_author_path(:author_slug => post['author']['slug'])) %>
12
+ on <%= post['created'] %></p>
13
+
14
+ <p class="post-summary">
15
+ <%= post['summary'] %>
16
+ </p>
17
+ </div>
18
+ <hr>
19
+ <% end %>
@@ -4,11 +4,28 @@
4
4
  <%= link_to(post['title'], blog_post_path(:slug => post['slug'])) %>
5
5
  </h2>
6
6
 
7
- <p class="post-meta">Posted by <%= post['author']['first_name'] %> <%= post['author']['last_name'] %> on <%= post['created'] %></p>
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'] %></p>
8
11
 
9
12
  <p class="post-summary">
10
13
  <%= post['summary'] %>
11
14
  </p>
12
15
  </div>
13
16
  <hr>
14
- <% end %>
17
+ <% end %>
18
+
19
+ <ul class="pager">
20
+ <% if @next_page %>
21
+ <li class="previous">
22
+ <%= link_to("&larr; Older Posts".html_safe, archive_path(:page => @next_page)) %>
23
+ </li>
24
+ <% end %>
25
+
26
+ <% if @previous_page %>
27
+ <li class="previous">
28
+ <%= link_to("Newer Posts &rarr;".html_safe, archive_path(:page => @previous_page)) %>
29
+ </li>
30
+ <% end %>
31
+ </ul>
@@ -1,12 +1,15 @@
1
1
  <div class="post-preview">
2
2
 
3
3
  <h2 class="post-title">
4
- <%= @blog_post['title'] %>
4
+ <%= @post['title'] %>
5
5
  </h2>
6
6
 
7
- <p class="post-meta">Posted by <%= @blog_post['author']['first_name'] %> <%= @blog_post['author']['last_name'] %> on <%= @blog_post['created'] %></p>
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'] %></p>
8
11
 
9
12
  <p class="post-body">
10
- <%= @blog_post['body'].html_safe %>
13
+ <%= @post['body'].html_safe %>
11
14
  </p>
12
15
  </div>
@@ -16,6 +16,7 @@ Gem::Specification.new do |spec|
16
16
 
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.require_paths = ["lib"]
19
+ # Note that files like new views must be commited and tracked via git for them to be included when building.
19
20
  spec.files = `git ls-files -z`.split("\x0")
20
21
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
22
 
@@ -1,4 +1,8 @@
1
1
  Buttercms::Engine.routes.draw do
2
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
+
6
+ # This must appear last since it's a catch all
3
7
  get '/:slug' => 'blog#post', as: :blog_post
4
8
  end
@@ -1,3 +1,3 @@
1
1
  module Buttercms
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
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.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ButterCms
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-25 00:00:00.000000000 Z
11
+ date: 2015-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -87,6 +87,7 @@ files:
87
87
  - app/controllers/buttercms/application_controller.rb
88
88
  - app/controllers/buttercms/blog_controller.rb
89
89
  - app/helpers/buttercms/application_helper.rb
90
+ - app/views/buttercms/blog/author.html.erb
90
91
  - app/views/buttercms/blog/home.html.erb
91
92
  - app/views/buttercms/blog/post.html.erb
92
93
  - app/views/layouts/buttercms/application.html.erb