flow_pagination 1.1 → 1.2

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig ADDED
Binary file
data/Manifest CHANGED
@@ -1,6 +1,7 @@
1
+ MIT-LICENSE
1
2
  Manifest
2
3
  README.rdoc
3
4
  Rakefile
5
+ flow_pagination.gemspec
4
6
  init.rb
5
7
  lib/flow_pagination.rb
6
- MIT-LICENSE
data/README.rdoc CHANGED
@@ -39,6 +39,67 @@ To install these gems type the following rake task:
39
39
  script/plugin install git://github.com/mislav/will_paginate.git
40
40
  script/plugin install git://github.com/mexpolk/flow_pagination.git
41
41
 
42
+ == Problem with SearchLogic and Nested Hashes as URL parameters in Rails
43
+
44
+ It seems to be a problem with nested hashes with the url_for helper. When using SearchLogic
45
+ or parameters with nested hashes url_for does a pretty bad job:
46
+
47
+ url_for(:controller => "posts", :action => "index", :search => { :title => "Flow" })
48
+ => http://localhost:3000/posts?title=Flow
49
+
50
+ # Where it should be:
51
+
52
+ => http://localhost:3000/posts?search%5Btitle%5D=Flow
53
+
54
+ To fix this problem you should patch +Hash+ class by adding the following
55
+ code in +config/initializers/hash.rb+ to work properly:
56
+
57
+ class Hash
58
+ # Flatten a hash into a flat form suitable for an URL.
59
+ # Accepts as an optional parameter an array of names that pretend to be the ancestor key names.
60
+ #
61
+ # Example 1:
62
+ #
63
+ # { 'animals' => {
64
+ # 'fish' => { 'legs' => 0, 'sound' => 'Blub' }
65
+ # 'cat' => { 'legs' => 4, 'sound' => 'Miaow' }
66
+ # }.flatten_for_url
67
+ #
68
+ # # => { 'animals[fish][legs]' => 0,
69
+ # 'animals[fish][sound]' => 'Blub',
70
+ # 'animals[cat][legs]' => 4,
71
+ # 'animals[cat][sound]' => 'Miaow'
72
+ # }
73
+ #
74
+ # Example 2:
75
+ #
76
+ # {'color' => 'blue'}.flatten_for_url( %w(world things) ) # => {'world[things][color]' => 'blue'}
77
+ #
78
+ def flatten_for_url(ancestor_names = [])
79
+ flat_hash = Hash.new
80
+
81
+ each do |key, value|
82
+ names = Array.new(ancestor_names)
83
+ names << key
84
+
85
+ if value.is_a?(Hash)
86
+ flat_hash.merge!(value.flatten_for_url(names))
87
+ else
88
+ flat_key = names.shift.to_s.dup
89
+ names.each do |name|
90
+ flat_key << "[#{name}]"
91
+ end
92
+ flat_key << "[]" if value.is_a?(Array)
93
+ flat_hash[flat_key] = value
94
+ end
95
+ end
96
+
97
+ flat_hash
98
+ end
99
+ end
100
+
101
+ Thanks to Rowan Rodrik for the code (http://blog.bigsmoke.us/2007/02/19/nested-hashes-derail-rails-url-helpers).
102
+
42
103
  == Usage
43
104
 
44
105
  There's flow_pagination_example[http://github.com/mexpolk/flow_pagination_example/tree/master]
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'echoe'
2
2
 
3
- Echoe.new('flow_pagination', '1.1') do |e|
3
+ Echoe.new('flow_pagination', '1.2') do |e|
4
4
  e.description = "FlowPagination link renderer plugin for Mislav's WillPaginate plugin (Twitter like pagination)."
5
5
  e.url = "http://github.com/mexpolk/flow_pagination"
6
6
  e.author = "Ivan Torres"
@@ -2,27 +2,29 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{flow_pagination}
5
- s.version = "1.1"
5
+ s.version = "1.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Ivan Torres"]
9
- s.date = %q{2009-08-12}
9
+ s.cert_chain = ["/Users/ivan/.ssh/gem-public_cert.pem"]
10
+ s.date = %q{2010-09-26}
10
11
  s.description = %q{FlowPagination link renderer plugin for Mislav's WillPaginate plugin (Twitter like pagination).}
11
12
  s.email = %q{mexpolk@gmail.com}
12
13
  s.extra_rdoc_files = ["README.rdoc", "lib/flow_pagination.rb"]
13
- s.files = ["Manifest", "README.rdoc", "Rakefile", "init.rb", "lib/flow_pagination.rb", "MIT-LICENSE", "flow_pagination.gemspec"]
14
+ s.files = ["MIT-LICENSE", "Manifest", "README.rdoc", "Rakefile", "flow_pagination.gemspec", "init.rb", "lib/flow_pagination.rb"]
14
15
  s.homepage = %q{http://github.com/mexpolk/flow_pagination}
15
16
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Flow_pagination", "--main", "README.rdoc"]
16
17
  s.require_paths = ["lib"]
17
18
  s.rubyforge_project = %q{flow_pagination}
18
- s.rubygems_version = %q{1.3.5}
19
+ s.rubygems_version = %q{1.3.7}
20
+ s.signing_key = %q{/Users/ivan/.ssh/gem-private_key.pem}
19
21
  s.summary = %q{FlowPagination link renderer plugin for Mislav's WillPaginate plugin (Twitter like pagination).}
20
22
 
21
23
  if s.respond_to? :specification_version then
22
24
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
25
  s.specification_version = 3
24
26
 
25
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
28
  else
27
29
  end
28
30
  else
@@ -8,12 +8,25 @@ module FlowPagination
8
8
  flow_pagination = ''
9
9
 
10
10
  if self.current_page < self.last_page
11
+
12
+ @template_params = @template.params.clone
13
+ @template_params.delete(:controller)
14
+ @template_params.delete(:action)
15
+
16
+ @url_params = {
17
+ :controller => @template.controller_name,
18
+ :action => @template.action_name,
19
+ :page => self.next_page
20
+ }
21
+
22
+ stringified_merge @url_params, @template_params if @template.request.get?
23
+ stringified_merge @url_params, @options[:params] if @options[:params]
24
+
11
25
  flow_pagination = @template.button_to_remote(
12
26
  @template.t('flow_pagination.button', :default => 'More'),
13
- :url => { :controller => @template.controller_name,
14
- :action => @template.action_name,
15
- :params => @template.params.merge!(:page => self.next_page)},
27
+ :url => @url_params.flatten_for_url,
16
28
  :method => @template.request.request_method)
29
+
17
30
  end
18
31
 
19
32
  @template.content_tag(:div, flow_pagination, :id => 'flow_pagination')
metadata CHANGED
@@ -1,15 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flow_pagination
3
3
  version: !ruby/object:Gem::Version
4
- version: "1.1"
4
+ hash: 11
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 2
9
+ version: "1.2"
5
10
  platform: ruby
6
11
  authors:
7
12
  - Ivan Torres
8
13
  autorequire:
9
14
  bindir: bin
10
- cert_chain: []
15
+ cert_chain:
16
+ - |
17
+ -----BEGIN CERTIFICATE-----
18
+ MIIDMDCCAhigAwIBAgIBADANBgkqhkiG9w0BAQUFADA+MRAwDgYDVQQDDAdtZXhw
19
+ b2xrMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZFgNjb20w
20
+ HhcNMTAwOTIzMTYzODI3WhcNMTEwOTIzMTYzODI3WjA+MRAwDgYDVQQDDAdtZXhw
21
+ b2xrMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZFgNjb20w
22
+ ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDS4zDOIsDwqhcJFGH1Cs0S
23
+ BCp0fEo68xB+4jPoqG5mxqo94//FA3XhKqlvCgqpf4bGXLycHu42W7AlzaFFZ/SL
24
+ z77hvNgLPrA5EmcVg92ydhjMgnIMzJ/ksM0bNNPAH7GhBxl+HPYP7Dkx4U5F0/hz
25
+ xw2MLPIDSV/je0aomK9LWoHpSfCbr5/YBaDbairHcR8yJ87UVo4rqs1tamSle0iU
26
+ 6LnNCljLa1vSBHOeZOW/i28Go02qqDCPYHr6NPw/dd+jqlO+fqvnH9dlmeUknAso
27
+ terNme2M56MW5fZ8ORj2YKVC7IJnVT4mBCwgkJSVFBCX+TprJbrEYAHObPqLHTYl
28
+ AgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBQLQeOW
29
+ xCxK39VboHu0bOm2hHFJfDANBgkqhkiG9w0BAQUFAAOCAQEAtRlYI7JfoRo88U6C
30
+ ay1YFkceNeJolb8yJcuGKiFvpjOmd4yoai5rj44UBq/k4mrZSYVq+r7ZMotAC4zq
31
+ b0nt+cBmpYxX/yXpEi+1MpVBewoq3XsVqJ+RKMcIn3z0DtdRqCGsBH6MO/EoQK7A
32
+ B3tuPCW0jZ7WlChY2eu/ygbtsa/Ik7iZyBiykZVfw/bXLuhlwKh/4NoIYERHckuP
33
+ FQhG9HbmCEnmAw9e6YytIrQDqp0hiRAJAFsO7xwhvV0J9DEtIjoVhST+DxMJv7ey
34
+ ffB/5PGg058D8Xm4rzXkzFrU+m14EtW4nc2/e09NXrF/PuFiurPvMr47qHqYzrPF
35
+ MKLC1g==
36
+ -----END CERTIFICATE-----
11
37
 
12
- date: 2009-08-12 00:00:00 -05:00
38
+ date: 2010-09-26 00:00:00 -05:00
13
39
  default_executable:
14
40
  dependencies: []
15
41
 
@@ -23,13 +49,13 @@ extra_rdoc_files:
23
49
  - README.rdoc
24
50
  - lib/flow_pagination.rb
25
51
  files:
52
+ - MIT-LICENSE
26
53
  - Manifest
27
54
  - README.rdoc
28
55
  - Rakefile
56
+ - flow_pagination.gemspec
29
57
  - init.rb
30
58
  - lib/flow_pagination.rb
31
- - MIT-LICENSE
32
- - flow_pagination.gemspec
33
59
  has_rdoc: true
34
60
  homepage: http://github.com/mexpolk/flow_pagination
35
61
  licenses: []
@@ -45,21 +71,28 @@ rdoc_options:
45
71
  require_paths:
46
72
  - lib
47
73
  required_ruby_version: !ruby/object:Gem::Requirement
74
+ none: false
48
75
  requirements:
49
76
  - - ">="
50
77
  - !ruby/object:Gem::Version
78
+ hash: 3
79
+ segments:
80
+ - 0
51
81
  version: "0"
52
- version:
53
82
  required_rubygems_version: !ruby/object:Gem::Requirement
83
+ none: false
54
84
  requirements:
55
85
  - - ">="
56
86
  - !ruby/object:Gem::Version
87
+ hash: 11
88
+ segments:
89
+ - 1
90
+ - 2
57
91
  version: "1.2"
58
- version:
59
92
  requirements: []
60
93
 
61
94
  rubyforge_project: flow_pagination
62
- rubygems_version: 1.3.5
95
+ rubygems_version: 1.3.7
63
96
  signing_key:
64
97
  specification_version: 3
65
98
  summary: FlowPagination link renderer plugin for Mislav's WillPaginate plugin (Twitter like pagination).
metadata.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ U�@��S�0��:����*6��H��B.�u�{Q�J�����A�*k�LVj�G�)��Ov��<��ֹ���B���� ���5䍯�U�rGvxX2�T���b�g���dF�t*H-jB�*�I�Ǻ���A�)���1�����J�Eo�/C+�g�<�q�'
2
+ Յ��>