date_paginate 0.0.1 → 0.0.2

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: 1ddbde00a4e66f4f3dc40034dedd120fb3111627
4
- data.tar.gz: 2bf193b3e26e9e1af79b711fcdd4c71629f9cdf7
3
+ metadata.gz: e83eeb515cf4a5037db8c82a7b08dda1fa0840bf
4
+ data.tar.gz: 6349d2179b9b52aac193cb2452f32162ca311963
5
5
  SHA512:
6
- metadata.gz: 08fe527c750371c94f5aa426e1c8b1a0092712851f20e2c0af5761d0ca339377b5dbfc209e3cda4dfb90c47a2ab352b3c93c806479ede92eb26e1a93d3ff6403
7
- data.tar.gz: 142ab10240acbb9c8de9cd010d7060870593bb12af51e030d5599c848873fd483f9ad7c2fde90b396a939f0d764308fa5f174ae9970d38ba3957bbaf46234485
6
+ metadata.gz: 05fffc1ce465b407b56aba16d630432ded3a60f40a54201cfa0f65deff007969b3d90abd90651fd51d02eb4dee670e860016f1a342dc649b4a95d11c49d06a1c
7
+ data.tar.gz: 087fd3e93a5f76ff02ff869e548de2b29a2e1c778699f97e0771bd9004a52787230d140ba2633746353b63949fea1209eea032b8fdf7931aa30cf4b58f386a73
@@ -3,7 +3,7 @@
3
3
  <% recent_days.each do |begin_time| %>
4
4
  <% begin_time = begin_time.in_time_zone if date.is_a? ActiveSupport::TimeWithZone %>
5
5
  <span class="page<%=' current' if (date.between? begin_time, begin_time.end_of_day) %>">
6
- <%= link_to_unless (date.between? begin_time, begin_time.end_of_day), begin_time.strftime('%Y-%m-%d'), year: begin_time.year, month: begin_time.month, day: begin_time.day %>
6
+ <%= link_to_unless (date.between? begin_time, begin_time.end_of_day), begin_time.strftime('%Y-%m-%d'), params.merge(year: begin_time.year, month: begin_time.month, day: begin_time.day) %>
7
7
  </span>
8
8
  <% end %>
9
9
  </nav>
@@ -3,7 +3,7 @@
3
3
  <% recent_months.each do |begin_date| %>
4
4
  <% begin_date = begin_date.in_time_zone if date.is_a? ActiveSupport::TimeWithZone %>
5
5
  <span class="page<%=' current' if (date.between? begin_date, begin_date.end_of_month) %>">
6
- <%= link_to_unless (date.between? begin_date, begin_date.end_of_month), begin_date.strftime('%Y-%m'), year: begin_date.year, month: begin_date.month %>
6
+ <%= link_to_unless (date.between? begin_date, begin_date.end_of_month), begin_date.strftime('%Y-%m'), params.merge(year: begin_date.year, month: begin_date.month) %>
7
7
  </span>
8
8
  <% end %>
9
9
  </nav>
@@ -3,7 +3,7 @@
3
3
  <% recent_weeks.each do |begin_date| %>
4
4
  <% begin_date = begin_date.in_time_zone if date.is_a? ActiveSupport::TimeWithZone %>
5
5
  <span class="page<%=' current' if (date.between? begin_date, begin_date.end_of_week) %>">
6
- <%= link_to_unless (date.between? begin_date, begin_date.end_of_week), "#{begin_date.strftime('%Y-%m-%d')} ~ #{begin_date.end_of_week.strftime('%Y-%m-%d')}", year: begin_date.year, month: begin_date.month, day: begin_date.day %>
6
+ <%= link_to_unless (date.between? begin_date, begin_date.end_of_week), "#{begin_date.strftime('%Y-%m-%d')} ~ #{begin_date.end_of_week.strftime('%Y-%m-%d')}", params.merge(year: begin_date.year, month: begin_date.month, day: begin_date.day) %>
7
7
  </span>
8
8
  <% end %>
9
9
  </nav>
@@ -7,6 +7,8 @@ module DatePaginate
7
7
  class Paginator
8
8
  include ::ActionView::Context
9
9
 
10
+ PARAM_KEY_BLACKLIST = :authenticity_token, :commit, :utf8, :_method
11
+
10
12
  def self.paginate_type_list
11
13
  [:days, :weeks, :months]
12
14
  end
@@ -23,6 +25,7 @@ module DatePaginate
23
25
  @date_paginate_type = @options.delete(:date_paginate_type)
24
26
  @num_pages = @options.delete(:num_pages)
25
27
  @options["recent_#{@date_paginate_type}".to_sym] = send("recent_#{@date_paginate_type}")
28
+ @params = template.params.except(*PARAM_KEY_BLACKLIST).merge(@options.delete(:params) || {})
26
29
  end
27
30
 
28
31
  paginate_type_list.each do |date_paginate_type|
@@ -53,7 +56,8 @@ module DatePaginate
53
56
  private :method_missing
54
57
 
55
58
  def to_s(locals = {})
56
- @template.render :partial => partial_path, :locals => @options.merge(locals), :formats => [:html]
59
+ locals = @options.merge(params: @params).merge(locals)
60
+ @template.render :partial => partial_path, :locals => locals, :formats => [:html]
57
61
  end
58
62
  end
59
63
  end
@@ -1,3 +1,3 @@
1
1
  module DatePaginate
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -8,6 +8,11 @@ describe DiariesController do
8
8
  get "index", year: Time.current.months_ago(1).year, month: Time.current.months_ago(1).month
9
9
  expect(response.body.scan(/<a href=\"\/diaries\?.+">/).size).to eq(5)
10
10
  end
11
+
12
+ it "with other params" do
13
+ get "index", status: 0, year: Time.current.months_ago(1).year, month: Time.current.months_ago(1).month
14
+ expect(response.body.scan(/<a href=\"\/diaries\?.+status=0.+">/).size).to eq(5)
15
+ end
11
16
  end
12
17
 
13
18
  describe "set_week" do
@@ -15,6 +20,11 @@ describe DiariesController do
15
20
  get "week_partition", year: Time.current.year, month: Time.current.month, day: Time.current.day
16
21
  expect(response.body.scan(/<a href=\"\/diaries\/week_partition\/archive\/\d+\/\d+\/\d+\">/).size).to eq(5)
17
22
  end
23
+
24
+ it "with other params" do
25
+ get "week_partition", status: 0, year: Time.current.year, month: Time.current.month, day: Time.current.day
26
+ expect(response.body.scan(/<a href=\"\/diaries\/week_partition\/archive\/\d+\/\d+\/\d+\?status=0\">/).size).to eq(5)
27
+ end
18
28
  end
19
29
 
20
30
  describe "set_date" do
@@ -22,5 +32,10 @@ describe DiariesController do
22
32
  get "day_partition", year: Time.current.year, month: Time.current.month, day: Time.current.day
23
33
  expect(response.body.scan(/<a href=\"\/diaries\/day_partition\/archive\/\d+\/\d+\/\d+\">/).size).to eq(2)
24
34
  end
35
+
36
+ it "with other params" do
37
+ get "week_partition", status: 0, year: Time.current.year, month: Time.current.month, day: Time.current.day
38
+ expect(response.body.scan(/<a href=\"\/diaries\/week_partition\/archive\/\d+\/\d+\/\d+\?status=0\">/).size).to eq(5)
39
+ end
25
40
  end
26
41
  end