will_paginate-bulma 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4ccc0c732a394a3f23b4f5cdd982f9dc15112598
4
+ data.tar.gz: 10b2915b025170df1c35ab56214c5c1bcdd6820d
5
+ SHA512:
6
+ metadata.gz: a76db5988e14fcd92f00aa2e84e3f778ab1553deeb3661b7b9516249eb564fc9c70541ff7849a3bd3e8b00eb44169da7be591cc5c942ea2a7859bfd23ef8c02e
7
+ data.tar.gz: 513c35671a63a46d05b777513add5243e3feab3e9bd71c2c7108321f052aeec1d409a2d0d5a230e6f5beb859396eea715b9ff1c950abe59ce58fe0b209fb2afd
@@ -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
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2017 Paul Hoffer
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.
@@ -0,0 +1,67 @@
1
+ # will_paginate-bulma
2
+
3
+ ![Bulma Pagination Component](https://raw.github.com/phoffer/will_paginate-bulma/master/pagination.png)
4
+
5
+ This gem integrates the [Bulma](http://bulma.io) [pagination component](http://bulma.io/documentation/components/pagination/) with the [will_paginate](https://github.com/mislav/will_paginate) pagination gem.
6
+
7
+ ## Supports Bulma 0.4.2
8
+
9
+ ## Install
10
+
11
+ * `gem install will_paginate-bulma`, *or*
12
+ * For projects using Bundler, add `gem 'will_paginate-bulma'` to your `Gemfile` (and then run `bundle install`).
13
+
14
+ ## Usage
15
+
16
+ ### Hanami
17
+
18
+ 1. To work with Hanami, you'll need to bundle a fork of will_paginate at [phoffer/will_paginate](https://github.com/phoffer/will_paginate) with the `hanami` branch. (Hopefully it will be merged soon!)
19
+ 2. Add the helper to the app you want to use will_paginate in application.rb. This enables will_pagination in Hanami.
20
+ 3. To render, use `BulmaPagination::Hanami` as the renderer.
21
+
22
+ ```
23
+ # apps/web/application.rb
24
+ view.prepare do
25
+ ...
26
+ include WillPaginate::Hanami
27
+ end
28
+ # rendering
29
+ <%= will_paginate collection, renderer: BulmaPagination::Hanami %>
30
+ ```
31
+
32
+ ### Rails
33
+
34
+ 1. Load the Bulma CSS in your template.
35
+ 2. In your view, use the `renderer: BulmaPagination::Rails` option with the `will_paginate` helper, for example:
36
+
37
+ ```
38
+ <%= will_paginate @collection, renderer: BulmaPagination::Rails %>
39
+ ```
40
+
41
+ ### Sinatra
42
+
43
+ 1. Load the Bulma CSS in your template.
44
+ 2. `require "will_paginate-bulma"` in your Sinatra app.
45
+ 3. In your view, use the `renderer: BulmaPagination::Sinatra` option with the `will_paginate` helper, for example:
46
+
47
+ ```
48
+ <%= will_paginate @collection, renderer: BulmaPagination::Sinatra %>
49
+ ```
50
+
51
+
52
+ Contributing
53
+ ------------
54
+
55
+ 1. Fork it.
56
+ 2. Create a branch (`git checkout -b my_markup`)
57
+ 3. Commit your changes (`git commit -am "Cool new feature"`)
58
+ 4. Push to the branch (`git push origin my_markup`)
59
+ 5. Open a [Pull Request][1]
60
+
61
+ ### Special Thanks
62
+
63
+ This gem code was based on [will_paginate-foundation](https://github.com/acrogenesis/will_paginate-foundation) by Adrian Rangel ([@acrogenesis](https://github.com/acrogenesis)).
64
+
65
+ License
66
+ ------------
67
+ The MIT License (MIT)
@@ -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,33 @@
1
+ require "sinatra"
2
+ require "will_paginate-bulma"
3
+ require "will_paginate/collection"
4
+
5
+ $template = <<EOHTML
6
+ <html>
7
+ <head>
8
+ <title>will_paginate-bulma Example App</title>
9
+ <link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.4.2/css/bulma.min.css" rel="stylesheet">
10
+ </head>
11
+ <body>
12
+ </br>
13
+ <div style='width: 800px; margin-left: 50px;'>
14
+ <%= will_paginate @collection, renderer: BulmaPagination::Sinatra, class: 'is-centered' %>
15
+ </div>
16
+ </body>
17
+ </html>
18
+ EOHTML
19
+
20
+ def build_collection
21
+ page = if params[:page].to_i > 0
22
+ params[:page].to_i
23
+ else
24
+ 1
25
+ end
26
+
27
+ @collection = WillPaginate::Collection.new page, 10, 100000
28
+ end
29
+
30
+ get "/" do
31
+ build_collection
32
+ erb $template
33
+ end
@@ -0,0 +1,9 @@
1
+ require "will_paginate/view_helpers/action_view"
2
+ require "bulma_pagination/bulma_renderer"
3
+
4
+ module BulmaPagination
5
+ # A custom renderer class for WillPaginate that produces markup suitable for use with Zurb Foundation.
6
+ class Rails < WillPaginate::ActionView::LinkRenderer
7
+ include BulmaRenderer
8
+ end
9
+ end
@@ -0,0 +1,60 @@
1
+ require "bulma_pagination/version"
2
+
3
+ module BulmaPagination
4
+ # Contains functionality shared by all renderer classes.
5
+ module BulmaRenderer
6
+
7
+ def to_html
8
+ pages = pagination
9
+ page_prev = pages.delete(:previous_page)
10
+ page_next = pages.delete(:next_page)
11
+ list_items = pages.map do |item|
12
+ item.is_a?(Integer) ? page_number(item) : send(item)
13
+ end.join(@options[:link_separator])
14
+ content = tag("ul", list_items, class: "pagination-list")
15
+ content.prepend(next_page) if page_next
16
+ content.prepend(previous_page) if page_prev
17
+ tag("nav", content, class: "pagination #{@options[:class]}")
18
+ end
19
+
20
+ def container_attributes
21
+ super.except(*[:link_options])
22
+ end
23
+
24
+ protected
25
+
26
+ def page_number(page)
27
+ link_options = @options[:link_options] || {}
28
+
29
+ if page == current_page
30
+ tag :li, tag(:span, page), class: ('pagination-link is-current')
31
+ else
32
+ tag :li, link(page, page, link_options.merge(rel: rel_value(page), class: 'pagination-link'))
33
+ end
34
+ end
35
+
36
+ def previous_or_next_page(page, text, classname)
37
+ link_options = @options[:link_options] || {}
38
+ if page
39
+ tag :li, link(text, page, link_options), class: classname
40
+ else
41
+ tag :li, tag(:span, text), class: classname, disabled: true
42
+ end
43
+ end
44
+
45
+ def gap
46
+ tag :li, '<span class="pagination-ellipsis">&hellip;</span>'
47
+ end
48
+
49
+ def previous_page
50
+ num = @collection.current_page > 1 && @collection.current_page - 1
51
+ previous_or_next_page(num, @options[:previous_label], "pagination-previous")
52
+ end
53
+
54
+ def next_page
55
+ num = @collection.current_page < @collection.total_pages && @collection.current_page + 1
56
+ previous_or_next_page(num, @options[:next_label], "pagination-next")
57
+ end
58
+
59
+ end
60
+ end
@@ -0,0 +1,9 @@
1
+ require "will_paginate/view_helpers/hanami"
2
+ require "bulma_pagination/bulma_renderer"
3
+
4
+ module BulmaPagination
5
+ # A custom renderer class for WillPaginate that produces markup suitable for use with Bulma CSS.
6
+ class Hanami < WillPaginate::Hanami::LinkRenderer
7
+ include BulmaRenderer
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ require "will_paginate/view_helpers/sinatra"
2
+ require "bulma_pagination/bulma_renderer"
3
+
4
+ module BulmaPagination
5
+ # A custom renderer class for WillPaginate that produces markup suitable for use with Bulma CSS.
6
+ class Sinatra < WillPaginate::Sinatra::LinkRenderer
7
+ include BulmaRenderer
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module BulmaPagination
2
+ VERSION = '1.0.0'
3
+ end
@@ -0,0 +1 @@
1
+ require "will_paginate/bulma"
@@ -0,0 +1,13 @@
1
+ require 'will_paginate'
2
+
3
+ if defined?(ActionView)
4
+ require "bulma_pagination/action_view"
5
+ end
6
+
7
+ if defined?(Sinatra)
8
+ require "bulma_pagination/sinatra"
9
+ end
10
+
11
+ if defined?(Hanami::View)
12
+ require "bulma_pagination/hanami"
13
+ end
Binary file
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "bulma_pagination/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "will_paginate-bulma"
7
+ s.version = BulmaPagination::VERSION
8
+ s.authors = ["Paul Hoffer"]
9
+ s.email = ["git@paulhoffer.com"]
10
+ s.homepage = "https://github.com/phoffer/will_paginate-bulma"
11
+ s.summary = %q{Integrates the Bulma pagination component with will_paginate}
12
+ s.description = %q{This gem integrates the Bulma pagination component with the will_paginate pagination gem. Supports Hanami, Sinatra, and Rails}
13
+ s.license = "MIT"
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+
20
+ s.add_runtime_dependency "will_paginate", ">= 3.0.3"
21
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: will_paginate-bulma
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Paul Hoffer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-07-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: will_paginate
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 3.0.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 3.0.3
27
+ description: This gem integrates the Bulma pagination component with the will_paginate
28
+ pagination gem. Supports Hanami, Sinatra, and Rails
29
+ email:
30
+ - git@paulhoffer.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".gitignore"
36
+ - Gemfile
37
+ - MIT-LICENSE
38
+ - README.markdown
39
+ - Rakefile
40
+ - example/app.rb
41
+ - lib/bulma_pagination/action_view.rb
42
+ - lib/bulma_pagination/bulma_renderer.rb
43
+ - lib/bulma_pagination/hanami.rb
44
+ - lib/bulma_pagination/sinatra.rb
45
+ - lib/bulma_pagination/version.rb
46
+ - lib/will_paginate-bulma.rb
47
+ - lib/will_paginate/bulma.rb
48
+ - pagination.png
49
+ - will_paginate-bulma.gemspec
50
+ homepage: https://github.com/phoffer/will_paginate-bulma
51
+ licenses:
52
+ - MIT
53
+ metadata: {}
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubyforge_project:
70
+ rubygems_version: 2.6.11
71
+ signing_key:
72
+ specification_version: 4
73
+ summary: Integrates the Bulma pagination component with will_paginate
74
+ test_files: []