effective_posts 1.0.6 → 1.1.0

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
- SHA256:
3
- metadata.gz: f0f0f0face589b9c5f7aea2880a79a96ce46d7b3650f78efedba278907e1b0ef
4
- data.tar.gz: 6829e35d9706eb0ad8307e5589278bd7630f8fe0c86455af4e93d74b554f2cc4
2
+ SHA1:
3
+ metadata.gz: 47bb689897ed31ceb48ad5648df6c3d4ecbd1106
4
+ data.tar.gz: ebe12bb48e0f6ad2bf48d307acd04ba5927b7a38
5
5
  SHA512:
6
- metadata.gz: dc99afaa84f8fb2ea362b2edf2ebc8c7c870aced3cff565a34b22990add9cc5f0bca04d20d102e9f4f87f93d771e57c4d40270205b3c29be0e954fc5c01a71f1
7
- data.tar.gz: 5f7d254014eb35ebec4f3bd661aea6ddb3d9089942c94f5b774264c3314d120fd619e807fe87824483a927ef770134b3bdad564542c9ad32ac140d6544a89b57
6
+ metadata.gz: b46abfef0b22ff676af43f48d221151aeeb697bc8fd7724133bf04c79626eeb2b8bebbd3f0e3a6fc419aaa2e85be3b4c46c29a11b3caabb22bbc8cb336bfb175
7
+ data.tar.gz: 907116a6c0e6f8a97a22b6bf053694824e776fa5d2f7d252a5b23e303c7d85f77564d6a11a445fbe0f4f1fc1e968860baf53276b848fa2b71382ac9c2cd17e3f
data/README.md CHANGED
@@ -2,11 +2,6 @@
2
2
 
3
3
  A blog implementation with WYSIWYG content editing, post scheduling, pagination and optional top level routes for each post category.
4
4
 
5
- Built ontop of effective_regions for post content entry and Kaminari for pagination.
6
-
7
- Rails 3.2.x and 4.x
8
-
9
-
10
5
  ## effective_posts 1.0
11
6
 
12
7
  This is the 1.0 series of effective_posts.
@@ -88,13 +83,10 @@ Use `post_excerpt(post)` to display the excerpt for a post. Or `post_excerpt(po
88
83
 
89
84
  ## Pagination
90
85
 
91
- The [kaminari](https://github.com/amatsuda/kaminari) gem is used for pagination on all posts#index type screens.
86
+ The [effective_bootstrap](https://github.com/code-and-effect/effective_bootstrap) gem is used for pagination on all posts#index type screens.
92
87
 
93
88
  The per_page for posts may be configured via the `/app/config/initializers/effective_posts.rb` initializer.
94
89
 
95
- Included within this gem is the bootstrap3 theme for kaminari, but, as with any gem, your app-specific kaminari views will take priority over these included views.
96
-
97
-
98
90
 
99
91
  ## Authorization
100
92
 
@@ -12,7 +12,7 @@ module Effective
12
12
  unpublished: EffectivePosts.authorized?(self, :admin, :effective_posts)
13
13
  )
14
14
 
15
- @posts = @posts.page(params[:page]).per(EffectivePosts.per_page)
15
+ @posts = @posts.paginate(page: params[:page])
16
16
 
17
17
  if params[:category] == 'events'
18
18
  @posts = @posts.reorder(:start_at).where('start_at > ?', Time.zone.now)
@@ -40,6 +40,13 @@ module Effective
40
40
  scope :unpublished, -> { where(draft: true).or(where("#{EffectivePosts.posts_table_name}.published_at > ?", Time.zone.now)) }
41
41
  scope :with_category, -> (category) { where(category: category.to_s.downcase) }
42
42
 
43
+ scope :paginate, -> (page: nil, per_page: EffectivePosts.per_page) {
44
+ page = (page || 1).to_i
45
+ offset = [(page - 1), 0].max * per_page
46
+
47
+ limit(per_page).offset(offset)
48
+ }
49
+
43
50
  scope :posts, -> (user: nil, category: nil, unpublished: false) {
44
51
  scope = all.includes(:regions).order(published_at: :desc)
45
52
 
@@ -1,9 +1,8 @@
1
1
  %h1= @page_title
2
2
 
3
3
  = render 'layout' do
4
- %nav= paginate @posts
5
-
6
4
  .effective-posts
7
5
  = render partial: @posts, spacer_template: 'spacer'
8
6
 
9
- %nav= paginate @posts
7
+ %nav.d-flex.justify-content-center
8
+ = paginate(@posts, per_page: EffectivePosts.per_page)
@@ -21,7 +21,7 @@ EffectivePosts.setup do |config|
21
21
  # /blog/1-post-title is posts#show
22
22
  config.use_blog_routes = true
23
23
 
24
- # Number of posts displayed per page (Kaminari)
24
+ # Number of posts displayed per page
25
25
  config.per_page = 10
26
26
 
27
27
  # Post Meta behaviour
@@ -1,4 +1,3 @@
1
- require 'kaminari'
2
1
  require 'nokogiri'
3
2
  require 'effective_datatables'
4
3
  require 'effective_regions'
@@ -1,3 +1,3 @@
1
1
  module EffectivePosts
2
- VERSION = '1.0.6'.freeze
2
+ VERSION = '1.1.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_posts
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-02 00:00:00.000000000 Z
11
+ date: 2019-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: kaminari
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: nokogiri
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -170,13 +156,6 @@ files:
170
156
  - app/views/effective/posts/submitted.html.haml
171
157
  - app/views/effective/posts_mailer/post_submitted_to_admin.html.haml
172
158
  - app/views/effective/snippets/_read_more_divider.html.haml
173
- - app/views/kaminari/_first_page.html.haml
174
- - app/views/kaminari/_gap.html.haml
175
- - app/views/kaminari/_last_page.html.haml
176
- - app/views/kaminari/_next_page.html.haml
177
- - app/views/kaminari/_page.html.haml
178
- - app/views/kaminari/_paginator.html.haml
179
- - app/views/kaminari/_prev_page.html.haml
180
159
  - app/views/layouts/effective_posts_mailer_layout.html.haml
181
160
  - config/effective_posts.rb
182
161
  - config/routes.rb
@@ -206,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
206
185
  version: '0'
207
186
  requirements: []
208
187
  rubyforge_project:
209
- rubygems_version: 2.7.3
188
+ rubygems_version: 2.4.5.1
210
189
  signing_key:
211
190
  specification_version: 4
212
191
  summary: A blog implementation with WYSIWYG content editing, post scheduling, pagination
@@ -1,2 +0,0 @@
1
- %li
2
- = link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, :remote => remote
@@ -1,2 +0,0 @@
1
- %li.disabled
2
- = content_tag :a, raw(t 'views.pagination.truncate')
@@ -1,2 +0,0 @@
1
- %li
2
- = link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, {:remote => remote}
@@ -1,2 +0,0 @@
1
- %li
2
- = link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, :rel => 'next', :remote => remote
@@ -1,6 +0,0 @@
1
- - if page.current?
2
- %li.active
3
- = content_tag :a, page, remote: remote, rel: (page.next? ? 'next' : (page.prev? ? 'prev' : nil))
4
- - else
5
- %li
6
- = link_to page, url, remote: remote, rel: (page.next? ? 'next' : (page.prev? ? 'prev' : nil))
@@ -1,11 +0,0 @@
1
- = paginator.render do
2
- %ul.pagination
3
- = first_page_tag unless current_page.first?
4
- = prev_page_tag unless current_page.first?
5
- - each_page do |page|
6
- - if page.left_outer? || page.right_outer? || page.inside_window?
7
- = page_tag page
8
- - elsif !page.was_truncated?
9
- = gap_tag
10
- = next_page_tag unless current_page.last?
11
- = last_page_tag unless current_page.last?
@@ -1,2 +0,0 @@
1
- %li
2
- = link_to_unless current_page.first?, raw(t 'views.pagination.previous'), url, :rel => 'prev', :remote => remote