go_blog 0.1.3 → 0.1.4

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: f9d486ae15e31b43612c2f1a969387cf15cc91b2
4
- data.tar.gz: 5b7261dbdedb26660e8558bf80fa02b7ca7b98e4
3
+ metadata.gz: fb6bfb2449235be656dc7ce3b75badba94ba7f0d
4
+ data.tar.gz: eea8b106187bf50d0a145e316b036230484e2808
5
5
  SHA512:
6
- metadata.gz: e646daa920af309d35a245b0aa05780fe2f7a91dcb614addc32f83a434bb98847853b3af5ffef4fa298737d5410493ac5eb5d5c7136185a4722d6f73de410e19
7
- data.tar.gz: 9bb1088768068a9d122e558f68e577b072fd08d9e0dff24d84bd302e6b0e34af40c9f3c0ed7bfb21d5869e1ef474bdb80326a3186ef325a309a30e6a916784b5
6
+ metadata.gz: 8bf78a5192bad9cce53e6dc5a8150df6079b1d8b0cc6193d236d758e1e2a3450efc55cdc5f4391af938d4f93b5f15a1dc8bf640db30465c6e6048c8dee9e4b45
7
+ data.tar.gz: ac2cd29b119d9b72966d37f6e113de70bbea2d0a73c2f488fc6baadd814a23edef3dbf66af2d9c0ca45ae4685c5b9d7727bb2addcc94fbeb502d349726ba445e
@@ -1,21 +1,23 @@
1
1
  module Blog
2
2
  class PostsController < ApplicationController
3
- before_action :set_blog_post, only: [:show, :edit, :update, :destroy,:show_list]
3
+ before_action :set_blog_post, only: [:show, :edit, :update, :destroy, :show_list]
4
4
  before_action :authenticate_user!, except: [:list, :show_list]
5
- load_and_authorize_resource except: [:list, :show_list,:create]
5
+ load_and_authorize_resource except: [:list, :show_list, :create]
6
6
  # GET /blog/posts
7
7
  def index
8
- @blog_posts = Post.all
8
+ @blog_posts = Post.all.page params[:page]
9
9
  end
10
10
 
11
11
  def list
12
- @blog_posts = Post.all
12
+ @blog_posts = Post.where('? >= published_at and draft = ?', DateTime.now, false).includes(:user).page params[:page]
13
13
  end
14
14
 
15
15
  # GET /blog/posts/1
16
16
  def show
17
17
  end
18
+
18
19
  def show_list
20
+ @blog_post.increment!(:access_count)
19
21
  end
20
22
 
21
23
  # GET /blog/posts/new
@@ -23,6 +23,18 @@ module Blog
23
23
  end
24
24
  end
25
25
 
26
+
27
+ def link_to_author
28
+ h.link_to h.user_path(id: self.user),
29
+ class: 'link-effect font-s13 font-w600',
30
+ title: '',
31
+ style: '' do
32
+ h.content_tag :span do
33
+ self.user.decorate.name
34
+ end
35
+ end
36
+ end
37
+
26
38
  def link_to_title
27
39
  h.link_to h.show_list_blog_posts_path(id: self.id),
28
40
  class: 'text-primary-dark',
@@ -1,5 +1,6 @@
1
1
  module Blog
2
2
  class Post < ApplicationRecord
3
+ validates_presence_of :title, :user_id, :body
3
4
  belongs_to :user
4
5
  end
5
6
  end
@@ -10,7 +10,7 @@
10
10
  <div class="col-md-12">
11
11
  <div class="font-s12 push-10">
12
12
  <em class="pull-right"><!--10 min--></em>
13
- <a href="base_pages_profile.php"><%= resource.user.decorate.name %></a> <%= converte_date(resource.published_at) %>
13
+ <%= resource.decorate.link_to_author %> - <%= converte_date(resource.published_at) %>
14
14
  </div>
15
15
  <h4 class="text-uppercase push-10">
16
16
  <%= resource.decorate.link_to_title %></h4>
@@ -24,3 +24,4 @@
24
24
  </div>
25
25
  </div>
26
26
  <% end %>
27
+
@@ -0,0 +1,4 @@
1
+ <div class="paging_simple_numbers">
2
+ <%= paginate collection %>
3
+ </div>
4
+
@@ -37,6 +37,8 @@
37
37
  <%= render 'collection', collection: @blog_posts %>
38
38
  </tbody>
39
39
  </table>
40
+ <%=render 'pagination',collection: @blog_posts%>
41
+
40
42
  </div>
41
43
  </div>
42
44
  </div>
@@ -41,6 +41,8 @@
41
41
  <!--</li>-->
42
42
  <!--</ul>-->
43
43
  <!--</nav>-->
44
+ <%=render 'pagination',collection: @blog_posts%>
45
+
44
46
  </div>
45
47
  <!--<div class="col-md-4">-->
46
48
  <!--<div class="block">-->
@@ -142,6 +144,7 @@
142
144
  <!--</div>-->
143
145
  <!--</div>-->
144
146
  <!--</div>-->
147
+
145
148
  </div>
146
149
  </div>
147
150
  </section>
@@ -11,7 +11,7 @@
11
11
  <div class="bg-white">
12
12
  <section class="content content-boxed">
13
13
  <div class="text-center">
14
- <a class="link-effect font-s13 font-w600" href="javascript:void(0)"><%= @blog_post.user.decorate.name %></a> <%= converte_date(@blog_post.published_at) %> <em></em>
14
+ <%= @blog_post.decorate.link_to_author %> - <%= converte_date(@blog_post.published_at) %> <em>visualizado <%=@blog_post.access_count%></em>
15
15
  </div>
16
16
  <div class="row push-50-t push-50 nice-copy-story">
17
17
  <div class="col-sm-8 col-sm-offset-2">
@@ -1,3 +1,3 @@
1
1
  module GoBlog
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: go_blog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - João Carlos Ottobboni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-09 00:00:00.000000000 Z
11
+ date: 2017-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: draper
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sqlite3
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description: blog engine
56
70
  email:
57
71
  - jcottobboni@gmail.com
@@ -75,6 +89,7 @@ files:
75
89
  - app/views/blog/posts/_collection.html.erb
76
90
  - app/views/blog/posts/_collection_list.html.erb
77
91
  - app/views/blog/posts/_form.html.erb
92
+ - app/views/blog/posts/_pagination.html.erb
78
93
  - app/views/blog/posts/edit.html.erb
79
94
  - app/views/blog/posts/index.html.erb
80
95
  - app/views/blog/posts/list.html.erb