will_paginate_serial_link_renderer 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fffe9f47ea8e950bd932421eeb267bd0b52562ea
4
+ data.tar.gz: cea1182d5884e9de3c629eb7219366cec91337ce
5
+ SHA512:
6
+ metadata.gz: 409f92546e9562bc0c68144639eb7e491c1f4802eeee62d816344cd0c67302231fa9b7190718c1edb42b0ee0ee1e5b33c112bad99428ce29f4f681e6107f68c7
7
+ data.tar.gz: 2ac3644469451a24c842fc49658a3854224dd8bf7cb44c290efe9ac7bc54f31796f4c47bdf56b6dc32f3de54d5017476f9a6d60fcd4e9087b4b068e4262a1b74
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in will_paginate_serial_link_renderer.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Morgan Laco
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # WillPaginateSerialLinkRenderer
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'will_paginate_serial_link_renderer'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install will_paginate_serial_link_renderer
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/will_paginate_serial_link_renderer/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,50 @@
1
+ require "will_paginate_serial_link_renderer/version"
2
+
3
+ module WillPaginateSerialLinkRenderer
4
+ # Your code goes here...
5
+ class LinkRenderer < WillPaginate::ViewHelpers::LinkRendererBase
6
+ # * +collection+ is a WillPaginate::Collection instance or any other object
7
+ # that conforms to that API
8
+ # * +options+ are forwarded from +will_paginate+ view helper
9
+ # * +template+ is the reference to the template being rendered
10
+ def prepare(collection, options, template)
11
+ super(collection, options)
12
+ @template = template
13
+ @container_attributes = @base_url_params = nil
14
+ end
15
+
16
+ def to_html
17
+ [
18
+ previous_page_tag,
19
+ tag(:div, nil, {:"data-pagination" => pagination[1..-2]}),
20
+ next_page_tag
21
+ ].join('')
22
+ end
23
+
24
+ protected
25
+
26
+ def previous_page
27
+ @collection.current_page > 1 && @collection.current_page - 1
28
+ end
29
+
30
+ def next_page
31
+ @collection.current_page < total_pages && @collection.current_page + 1
32
+ end
33
+
34
+ def previous_page_tag
35
+ if previous_page
36
+ tag(:div, "Previous", {:"data-pagination" => previous_page})
37
+ else
38
+ previous_or_next_page(nil, @options[:previous_label], 'previous_page')
39
+ end
40
+ end
41
+
42
+ def next_page_tag
43
+ if next_page
44
+ tag(:div, "Next", {:"data-pagination" => next_page})
45
+ else
46
+ previous_or_next_page(nil, @options[:next_label], 'next_page')
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,3 @@
1
+ module WillPaginateSerialLinkRenderer
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'will_paginate_serial_link_renderer/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "will_paginate_serial_link_renderer"
8
+ spec.version = WillPaginateSerialLinkRenderer::VERSION
9
+ spec.authors = ["Morgan Laco"]
10
+ spec.email = ["morgan@codeschool.com"]
11
+ spec.summary = "Link renderer for use with [will_paginate](https://github.com/mislav/will_paginate) that produces output suitable for serialized transmission."
12
+ spec.description = %q{
13
+ Link renderer for use with [will_paginate](https://github.com/mislav/will_paginate).
14
+ When paginated results are loaded asyncronously, it is not ideal to output fully fleshed-out html for the links; there is too much redundancy in doing so.
15
+ Additionally, if you're requesting pagination asyncronously, you don't want links anyway, because you'd want to allow users to view results on other pages
16
+ without a page reload.
17
+ This gem reduces each link to its minimal form: a page number.
18
+ }
19
+ spec.homepage = "https://github.com/mlaco/will_paginate_serial_link_renderer"
20
+ spec.license = "MIT"
21
+
22
+ spec.files = `git ls-files -z`.split("\x0")
23
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
24
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
25
+ spec.require_paths = ["lib"]
26
+
27
+ spec.add_dependency "will_paginate", "~> 3.1"
28
+
29
+ spec.add_development_dependency "bundler", "~> 1.7"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: will_paginate_serial_link_renderer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Morgan Laco
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2016-09-16 00:00:00 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: will_paginate
16
+ requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: "3.1"
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: *id001
24
+ - !ruby/object:Gem::Dependency
25
+ name: bundler
26
+ requirement: &id002 !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: "1.7"
31
+ type: :development
32
+ prerelease: false
33
+ version_requirements: *id002
34
+ - !ruby/object:Gem::Dependency
35
+ name: rake
36
+ requirement: &id003 !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: "10.0"
41
+ type: :development
42
+ prerelease: false
43
+ version_requirements: *id003
44
+ description: "\n Link renderer for use with [will_paginate](https://github.com/mislav/will_paginate).\n When paginated results are loaded asyncronously, it is not ideal to output fully fleshed-out html for the links; there is too much redundancy in doing so.\n Additionally, if you're requesting pagination asyncronously, you don't want links anyway, because you'd want to allow users to view results on other pages\n without a page reload.\n This gem reduces each link to its minimal form: a page number.\n "
45
+ email:
46
+ - morgan@codeschool.com
47
+ executables: []
48
+
49
+ extensions: []
50
+
51
+ extra_rdoc_files: []
52
+
53
+ files:
54
+ - .gitignore
55
+ - Gemfile
56
+ - LICENSE.txt
57
+ - README.md
58
+ - Rakefile
59
+ - lib/will_paginate_serial_link_renderer.rb
60
+ - lib/will_paginate_serial_link_renderer/version.rb
61
+ - will_paginate_serial_link_renderer.gemspec
62
+ homepage: https://github.com/mlaco/will_paginate_serial_link_renderer
63
+ licenses:
64
+ - MIT
65
+ metadata: {}
66
+
67
+ post_install_message:
68
+ rdoc_options: []
69
+
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - &id004
75
+ - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: "0"
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - *id004
81
+ requirements: []
82
+
83
+ rubyforge_project:
84
+ rubygems_version: 2.4.1
85
+ signing_key:
86
+ specification_version: 4
87
+ summary: Link renderer for use with [will_paginate](https://github.com/mislav/will_paginate) that produces output suitable for serialized transmission.
88
+ test_files: []
89
+