minimalistic_kaminari_paginate 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in minimalistic_kaminari_paginate.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Edwin Cruz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Edwin Cruz
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.
@@ -0,0 +1,45 @@
1
+ Minimalistic kaminari paginate helper
2
+ ==============================
3
+
4
+ Minimalistic kaminari paginate view helper, but much faster
5
+
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'minimalistic_kaminari_paginate'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install minimalistic_kaminari_paginate
20
+
21
+ ## Usage
22
+
23
+ Instead of normal kaminari paginate helper, use minimalistic_paginate
24
+
25
+ minimalistic_paginate collection, window: 4, sides: 3
26
+
27
+ ## Contributing
28
+
29
+ 1. Fork it
30
+ 2. Create your feature branch (`git checkout -b my-new-awesome-feature`)
31
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
32
+ 4. Push to the branch (`git push origin my-new-feature`)
33
+ 5. Create new Pull Request
34
+
35
+ ## License
36
+
37
+ MIT License, see LICENSE file
38
+
39
+ ## About the Author
40
+
41
+ I work at [Crowd Interactive](http://www.crowdint.com), it is a leading Ruby and Rails
42
+ consultancy firm based in Mexico currently doing business with startups in the
43
+ United States. We specialize in building and growing Rails applications, by increasing
44
+ your IT crew onsite or offsite. We pick our projects carefully, as we only work
45
+ with companies we believe in.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,18 @@
1
+ require "minimalistic_kaminari_paginate/version"
2
+
3
+ module MinimalisticKaminariPaginate
4
+ end
5
+
6
+ # load Rails/Railtie
7
+ begin
8
+ require 'rails'
9
+ rescue LoadError
10
+ #do nothing
11
+ end
12
+
13
+ require 'minimalistic_kaminari_paginate/helpers/action_view_extension'
14
+ require 'minimalistic_kaminari_paginate/hooks'
15
+
16
+ if defined? Rails
17
+ require 'minimalistic_kaminari_paginate/railtie'
18
+ end
@@ -0,0 +1,42 @@
1
+ module MinimalisticKaminariPaginate
2
+ module ActionViewExtension
3
+
4
+ # A helper that renders the pagination links. But much faster
5
+ #
6
+ # <%= minimalistic_paginate @articles %>
7
+ #
8
+ # ==== Options
9
+ # * <tt>:window</tt> - The "inner window" size (4 by default).
10
+ # * <tt>:sides</tt> - The "left/right outer window" size (3 by default).
11
+ # * <tt>:params</tt> - url_for parameters for the links (:controller, :action, etc.)
12
+ def minimalistic_paginate collection, options = {}
13
+ window = options[:window] || 4
14
+ side_size = options[:sides] || 3
15
+ output = ''
16
+ if collection.num_pages > 1
17
+ output << "<nav class='pagination'>"
18
+ page_base = collection.current_page
19
+ if page_base > window
20
+ output << content_tag(:span, class: 'first') do
21
+ link_to raw(t 'views.pagination.first'), url_for(params.merge(page: 1))
22
+ end
23
+ output << content_tag(:span, class: 'page gap') { '... ' }
24
+ end
25
+
26
+ (page_base <= side_size ? 1 : page_base - 3).upto(page_base > collection.num_pages - side_size ? collection.num_pages : page_base + side_size) do |page|
27
+ output << content_tag(:span, class: "page") do
28
+ link_to_unless (collection.current_page == page), page.to_s, url_for(params.merge(page: page))
29
+ end
30
+ end
31
+ if page_base < collection.num_pages - side_size
32
+ output << content_tag(:span, class: 'page gap') { '... ' }
33
+ output << content_tag(:span, class: 'last') do
34
+ link_to raw(t 'views.pagination.last'), url_for(params.merge(page: collection.num_pages))
35
+ end
36
+ end
37
+ output << "</nav>"
38
+ end
39
+ output.html_safe
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,9 @@
1
+ module MinimalisticKaminariPaginate
2
+ class Hooks
3
+ def self.init
4
+ ActiveSupport.on_load(:action_view) do
5
+ ::ActionView::Base.send :include, MinimalisticKaminariPaginate::ActionViewExtension
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ module MinimalisticKaminariPaginate
2
+ class Railtie < ::Rails::Railtie #:nodoc:
3
+ initializer 'minimalistic_kaminari_paginate' do |_app|
4
+ MinimalisticKaminariPaginate::Hooks.init
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module MinimalisticKaminariPaginate
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'minimalistic_kaminari_paginate/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "minimalistic_kaminari_paginate"
8
+ spec.version = MinimalisticKaminariPaginate::VERSION
9
+ spec.authors = ["Edwin Cruz"]
10
+ spec.email = ["softr8@gmail.com"]
11
+ spec.description = %q{Minimalistic kaminari paginate replacement, much faster}
12
+ spec.summary = %q{Built in kaminari paginate helper is great, highly customizable, but unfortunately slow}
13
+ spec.homepage = "https://github.com/softr8/minimalistic_kaminari_paginate"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: minimalistic_kaminari_paginate
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Edwin Cruz
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-11-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Minimalistic kaminari paginate replacement, much faster
47
+ email:
48
+ - softr8@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - Gemfile
55
+ - LICENSE
56
+ - LICENSE.txt
57
+ - README.md
58
+ - Rakefile
59
+ - lib/minimalistic_kaminari_paginate.rb
60
+ - lib/minimalistic_kaminari_paginate/helpers/action_view_extension.rb
61
+ - lib/minimalistic_kaminari_paginate/hooks.rb
62
+ - lib/minimalistic_kaminari_paginate/railtie.rb
63
+ - lib/minimalistic_kaminari_paginate/version.rb
64
+ - minimalistic_kaminari_paginate.gemspec
65
+ homepage: https://github.com/softr8/minimalistic_kaminari_paginate
66
+ licenses:
67
+ - MIT
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 1.8.25
87
+ signing_key:
88
+ specification_version: 3
89
+ summary: Built in kaminari paginate helper is great, highly customizable, but unfortunately
90
+ slow
91
+ test_files: []
92
+ has_rdoc: