smart_pagination 0.2.1 → 0.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 338a3e6b702bd084479deb4e0d2b0bc43038a496
4
- data.tar.gz: 01fb72960591a31c7b1447a3336ec22114c58af3
3
+ metadata.gz: 9e34390880f7d6e8e725b07d68be352337b694da
4
+ data.tar.gz: 81b5027beb3fca871376b1182dab770e7c7ff136
5
5
  SHA512:
6
- metadata.gz: 7812a25b268ee04edaec35ff04a8e57571a6d9531d2731361fd8c43789ae0063ba95fae9ff90d7528913084df3110960ca57c6fa3a3836943da19e68fd90340f
7
- data.tar.gz: 240314d129d9c3a5d3c954d422fd4875cad9c6ae52da55a47d65dfa3028c2d7e1b0504371178952876dee43d873d8d89cdbfb9ce06ddc1fba536c45fcf51b569
6
+ metadata.gz: 232b5893d40fd58fdf5cee76c173993b1a08d5a1617901adf4993d1b0ac76763db810bec0f4f7207f4945d4e6459f31e5bd8cd2dfda81baa873938d8d780abfb
7
+ data.tar.gz: 3b502147daf912f88be2bf2742710a771c40a31395d6e303e6c03356a7c3ccc8223bc9d27f01f1982c00dfb5de75af9ce05b9b31d60ebce4c71c491b7f3abd03
@@ -92,8 +92,10 @@ module SmartPagination
92
92
 
93
93
  # Current url parameters
94
94
  def url_params
95
- url = URI.parse(@context.request.url)
96
- Rack::Utils.parse_nested_query(url.query).symbolize_keys
95
+ url = URI.parse(@context.request.url)
96
+ params = Rack::Utils.parse_nested_query(url.query).symbolize_keys
97
+
98
+ params.except(:page)
97
99
  end
98
100
 
99
101
  # Get page numbers
@@ -135,11 +137,8 @@ module SmartPagination
135
137
 
136
138
  # Get link params
137
139
  def link_params(page)
138
- if page.is_a? Integer
139
- { page: page }
140
- else
141
- { page: @collection.send(:"#{page}_page") }
142
- end
140
+ page = @collection.send(:"#{page}_page") unless page.is_a? Integer
141
+ { page: page }
143
142
  end
144
143
 
145
144
  # Get link options
@@ -192,10 +191,11 @@ module SmartPagination
192
191
 
193
192
  # Render link tag
194
193
  def link_to(text, params={}, html_options={})
195
- url = @context.url_for url_params.merge(params)
194
+ prm = params.except(:page) if params[:page] == 1
195
+ url = @context.url_for url_params.merge(prm || params)
196
196
  opt = html_options.to_h
197
+ opt = opt.merge(href: url) if params[:page].present?
197
198
 
198
- opt.merge!(href: url) if params[:page].present?
199
199
  tag :a, "#{text}".html_safe, opt
200
200
  end
201
201
 
@@ -1,3 +1,3 @@
1
1
  module SmartPagination
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_pagination
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonian Guveli
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-27 00:00:00.000000000 Z
11
+ date: 2017-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: smart_paginate