will_paginate-foundation 0.1

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.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .idea/
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in will_paginate-foundation.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem "rake"
8
+ gem "nokogiri"
9
+ gem "minitest"
10
+ end
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Adrian Rangel
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,21 @@
1
+ # will_paginate-foundation
2
+
3
+ ![Foundation Pagination Component](https://raw.github.com/acrogenesis/will_paginate-foundation/master/pagination.png)
4
+
5
+ This gem integrates the [Foundation](http://foundation.zurb.com) [pagination component](http://foundation.zurb.com/docs/components/pagination.html) with the [will_paginate](https://github.com/mislav/will_paginate) pagination gem.
6
+
7
+ ## Install
8
+
9
+ * `gem install will_paginate-foundation`, *or*
10
+ * For projects using Bundler, add `gem 'will_paginate-foundation'` to your `Gemfile` (and then run `bundle install`).
11
+
12
+ ## Usage
13
+
14
+ ### Rails
15
+
16
+ 1. Load the Foundation CSS in your template.
17
+ 2. In your view, use the `renderer: FoundationPagination::Rails` option with the `will_paginate` helper, for example:
18
+
19
+ ```ruby
20
+ <%= will_paginate @collection, renderer: FoundationPagination::Rails %>
21
+ ```
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ #Rake::TestTask.new do |t|
5
+ # t.pattern = "spec/*_spec.rb"
6
+ #end
7
+
8
+ task :default => :test
@@ -0,0 +1,9 @@
1
+ require "will_paginate/view_helpers/action_view"
2
+ require "foundation_pagination/foundation_renderer"
3
+
4
+ module FoundationPagination
5
+ # A custom renderer class for WillPaginate that produces markup suitable for use with Twitter Bootstrap.
6
+ class Rails < WillPaginate::ActionView::LinkRenderer
7
+ include FoundationRenderer
8
+ end
9
+ end
@@ -0,0 +1,58 @@
1
+ require "foundation_pagination/version"
2
+
3
+ module FoundationPagination
4
+ # Contains functionality shared by all renderer classes.
5
+ module FoundationRenderer
6
+
7
+ def to_html
8
+ list_items = pagination.map do |item|
9
+ case item
10
+ when Fixnum
11
+ page_number(item)
12
+ else
13
+ send(item)
14
+ end
15
+ end.join(@options[:link_separator])
16
+
17
+ if @options[:foundation].to_i >= 3
18
+ tag("ul", list_items, class: "pagination")
19
+ else
20
+ html_container(tag("ul", list_items))
21
+ end
22
+ end
23
+ def html_container(html)
24
+ tag(:ul, html, container_attributes)
25
+ end
26
+
27
+ def container_attributes
28
+ super.except(*[:link_options])
29
+ end
30
+
31
+ protected
32
+
33
+ def page_number(page)
34
+ link_options = @options[:link_options] || {}
35
+ tag :li, link(page, page, link_options.merge(rel: rel_value(page))), :class => ('current' if page == current_page)
36
+ end
37
+
38
+ def gap
39
+ tag :li, link('&hellip;', '#'), :class => 'unavailable'
40
+ end
41
+
42
+ # def previous_page
43
+ # num = @collection.current_page > 1 && @collection.current_page - 1
44
+ # previous_or_next_page(num, @options[:previous_label], "prev")
45
+ # end
46
+
47
+ # def next_page
48
+ # num = @collection.current_page < @collection.total_pages && @collection.current_page + 1
49
+ # previous_or_next_page(num, @options[:next_label], "next")
50
+ # end
51
+
52
+ def previous_or_next_page(page, text, classname)
53
+ link_options = @options[:link_options] || {}
54
+ tag :li, link(text, page || '#', link_options), :class => [classname[0..3], classname, ('unavailable' unless page)].join(' ')
55
+
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,3 @@
1
+ module FoundationPagination
2
+ VERSION = "0.1"
3
+ end
@@ -0,0 +1 @@
1
+ require "will_paginate/foundation"
@@ -0,0 +1,5 @@
1
+ require 'will_paginate'
2
+
3
+ if defined?(ActionView)
4
+ require "foundation_pagination/action_view"
5
+ end
data/pagination.png ADDED
Binary file
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "foundation_pagination/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "will_paginate-foundation"
7
+ s.version = FoundationPagination::VERSION
8
+ s.authors = ["Adrian Rangel"]
9
+ s.email = ["adrian.rangel@gmail.com"]
10
+ s.homepage = "https://github.com/acrogenesis/will_paginate-foundation"
11
+ s.summary = %q{Integrates the Foundation pagination component with will_paginate}
12
+ s.description = %q{This gem integrates the Foundation pagination component with the will_paginate pagination gem. Supports Rails}
13
+ s.license = "MIT"
14
+
15
+ s.rubyforge_project = "will_paginate-foundation"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_runtime_dependency "will_paginate", ">= 3.0.3"
23
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: will_paginate-foundation
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Adrian Rangel
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-09-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: will_paginate
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 3.0.3
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 3.0.3
30
+ description: This gem integrates the Foundation pagination component with the will_paginate
31
+ pagination gem. Supports Rails
32
+ email:
33
+ - adrian.rangel@gmail.com
34
+ executables: []
35
+ extensions: []
36
+ extra_rdoc_files: []
37
+ files:
38
+ - .gitignore
39
+ - Gemfile
40
+ - MIT-LICENSE
41
+ - README.markdown
42
+ - Rakefile
43
+ - lib/foundation_pagination/action_view.rb
44
+ - lib/foundation_pagination/foundation_renderer.rb
45
+ - lib/foundation_pagination/version.rb
46
+ - lib/will_paginate-foundation.rb
47
+ - lib/will_paginate/foundation.rb
48
+ - pagination.png
49
+ - will_paginate-foundation.gemspec
50
+ homepage: https://github.com/acrogenesis/will_paginate-foundation
51
+ licenses:
52
+ - MIT
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubyforge_project: will_paginate-foundation
71
+ rubygems_version: 1.8.25
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: Integrates the Foundation pagination component with will_paginate
75
+ test_files: []