kaminari-0.17.0/ 0000755 0001750 0001750 00000000000 12727211600 013516 5 ustar abhijith abhijith kaminari-0.17.0/metadata.yml 0000644 0001750 0001750 00000023451 12727211600 016026 0 ustar abhijith abhijith --- !ruby/object:Gem::Specification name: kaminari version: !ruby/object:Gem::Version version: 0.17.0 platform: ruby authors: - Akira Matsuda - Yuki Nishijima - Zachary Scott - Hiroshi Shibata autorequire: bindir: bin cert_chain: [] date: 2016-05-31 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: activesupport requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: 3.0.0 type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: 3.0.0 - !ruby/object:Gem::Dependency name: actionpack requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: 3.0.0 type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: 3.0.0 - !ruby/object:Gem::Dependency name: bundler requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: 1.0.0 type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: 1.0.0 - !ruby/object:Gem::Dependency name: rake requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: tzinfo requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: rspec requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: rr requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: capybara requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '1.0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '1.0' - !ruby/object:Gem::Dependency name: database_cleaner requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: 1.2.0 type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: 1.2.0 - !ruby/object:Gem::Dependency name: rdoc requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' description: Kaminari is a Scope & Engine based, clean, powerful, agnostic, customizable and sophisticated paginator for Rails 3+ email: - ronnie@dio.jp executables: [] extensions: [] extra_rdoc_files: - README.rdoc files: - ".document" - ".gemtest" - ".gitignore" - ".rspec" - ".travis.yml" - CHANGELOG.rdoc - Gemfile - MIT-LICENSE - README.rdoc - Rakefile - app/views/kaminari/_first_page.html.erb - app/views/kaminari/_first_page.html.haml - app/views/kaminari/_first_page.html.slim - app/views/kaminari/_gap.html.erb - app/views/kaminari/_gap.html.haml - app/views/kaminari/_gap.html.slim - app/views/kaminari/_last_page.html.erb - app/views/kaminari/_last_page.html.haml - app/views/kaminari/_last_page.html.slim - app/views/kaminari/_next_page.html.erb - app/views/kaminari/_next_page.html.haml - app/views/kaminari/_next_page.html.slim - app/views/kaminari/_page.html.erb - app/views/kaminari/_page.html.haml - app/views/kaminari/_page.html.slim - app/views/kaminari/_paginator.html.erb - app/views/kaminari/_paginator.html.haml - app/views/kaminari/_paginator.html.slim - app/views/kaminari/_prev_page.html.erb - app/views/kaminari/_prev_page.html.haml - app/views/kaminari/_prev_page.html.slim - config/locales/kaminari.yml - gemfiles/active_record_30.gemfile - gemfiles/active_record_31.gemfile - gemfiles/active_record_32.gemfile - gemfiles/active_record_40.gemfile - gemfiles/active_record_41.gemfile - gemfiles/active_record_42.gemfile - gemfiles/active_record_edge.gemfile - gemfiles/data_mapper_12.gemfile - gemfiles/mongo_mapper.gemfile - gemfiles/mongoid_30.gemfile - gemfiles/mongoid_31.gemfile - gemfiles/mongoid_40.gemfile - gemfiles/mongoid_50.gemfile - gemfiles/sinatra_13.gemfile - gemfiles/sinatra_14.gemfile - kaminari.gemspec - lib/generators/kaminari/config_generator.rb - lib/generators/kaminari/templates/kaminari_config.rb - lib/generators/kaminari/views_generator.rb - lib/kaminari.rb - lib/kaminari/config.rb - lib/kaminari/engine.rb - lib/kaminari/grape.rb - lib/kaminari/helpers/action_view_extension.rb - lib/kaminari/helpers/paginator.rb - lib/kaminari/helpers/sinatra_helpers.rb - lib/kaminari/helpers/tags.rb - lib/kaminari/hooks.rb - lib/kaminari/models/active_record_extension.rb - lib/kaminari/models/active_record_model_extension.rb - lib/kaminari/models/active_record_relation_methods.rb - lib/kaminari/models/array_extension.rb - lib/kaminari/models/configuration_methods.rb - lib/kaminari/models/data_mapper_collection_methods.rb - lib/kaminari/models/data_mapper_extension.rb - lib/kaminari/models/mongo_mapper_extension.rb - lib/kaminari/models/mongoid_criteria_methods.rb - lib/kaminari/models/mongoid_extension.rb - lib/kaminari/models/page_scope_methods.rb - lib/kaminari/models/plucky_criteria_methods.rb - lib/kaminari/railtie.rb - lib/kaminari/sinatra.rb - lib/kaminari/version.rb - spec/config/config_spec.rb - spec/fake_app/active_record/config.rb - spec/fake_app/active_record/models.rb - spec/fake_app/data_mapper/config.rb - spec/fake_app/data_mapper/models.rb - spec/fake_app/mongo_mapper/config.rb - spec/fake_app/mongo_mapper/models.rb - spec/fake_app/mongoid/config.rb - spec/fake_app/mongoid/models.rb - spec/fake_app/rails_app.rb - spec/fake_app/sinatra_app.rb - spec/fake_app/views/alternative/kaminari/_first_page.html.erb - spec/fake_app/views/alternative/kaminari/_paginator.html.erb - spec/fake_app/views/kaminari/bootstrap/_page.html.erb - spec/fake_app/views/kaminari/bootstrap/_paginator.html.erb - spec/fake_gem.rb - spec/generators/views_generator_spec.rb - spec/helpers/action_view_extension_spec.rb - spec/helpers/helpers_spec.rb - spec/helpers/sinatra_helpers_spec.rb - spec/helpers/tags_spec.rb - spec/models/active_record/active_record_relation_methods_spec.rb - spec/models/active_record/inherited_spec.rb - spec/models/active_record/scopes_spec.rb - spec/models/array_spec.rb - spec/models/configuration_methods_spec.rb - spec/models/data_mapper/data_mapper_spec.rb - spec/models/mongo_mapper/mongo_mapper_spec.rb - spec/models/mongoid/mongoid_spec.rb - spec/requests/users_spec.rb - spec/spec_helper.rb - spec/spec_helper_for_sinatra.rb - spec/support/database_cleaner.rb - spec/support/matchers.rb homepage: https://github.com/amatsuda/kaminari licenses: - MIT metadata: {} post_install_message: rdoc_options: [] require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: kaminari rubygems_version: 2.6.4 signing_key: specification_version: 4 summary: A pagination engine plugin for Rails 3+ and other modern frameworks test_files: - spec/config/config_spec.rb - spec/fake_app/active_record/config.rb - spec/fake_app/active_record/models.rb - spec/fake_app/data_mapper/config.rb - spec/fake_app/data_mapper/models.rb - spec/fake_app/mongo_mapper/config.rb - spec/fake_app/mongo_mapper/models.rb - spec/fake_app/mongoid/config.rb - spec/fake_app/mongoid/models.rb - spec/fake_app/rails_app.rb - spec/fake_app/sinatra_app.rb - spec/fake_app/views/alternative/kaminari/_first_page.html.erb - spec/fake_app/views/alternative/kaminari/_paginator.html.erb - spec/fake_app/views/kaminari/bootstrap/_page.html.erb - spec/fake_app/views/kaminari/bootstrap/_paginator.html.erb - spec/fake_gem.rb - spec/generators/views_generator_spec.rb - spec/helpers/action_view_extension_spec.rb - spec/helpers/helpers_spec.rb - spec/helpers/sinatra_helpers_spec.rb - spec/helpers/tags_spec.rb - spec/models/active_record/active_record_relation_methods_spec.rb - spec/models/active_record/inherited_spec.rb - spec/models/active_record/scopes_spec.rb - spec/models/array_spec.rb - spec/models/configuration_methods_spec.rb - spec/models/data_mapper/data_mapper_spec.rb - spec/models/mongo_mapper/mongo_mapper_spec.rb - spec/models/mongoid/mongoid_spec.rb - spec/requests/users_spec.rb - spec/spec_helper.rb - spec/spec_helper_for_sinatra.rb - spec/support/database_cleaner.rb - spec/support/matchers.rb kaminari-0.17.0/.gemtest 0000644 0001750 0001750 00000000000 12727211600 015155 0 ustar abhijith abhijith kaminari-0.17.0/MIT-LICENSE 0000644 0001750 0001750 00000002041 12727211600 015147 0 ustar abhijith abhijith Copyright (c) 2011 Akira Matsuda Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. kaminari-0.17.0/.gitignore 0000644 0001750 0001750 00000000113 12727211600 015501 0 ustar abhijith abhijith *.gem .bundle .idea Gemfile.lock gemfiles/*.lock coverage/* pkg/* doc log kaminari-0.17.0/.travis.yml 0000644 0001750 0001750 00000003002 12727211600 015622 0 ustar abhijith abhijith language: ruby rvm: - 1.9.3 - 2.0.0 - 2.1.10 - 2.2.5 - 2.3.1 - jruby-1.7.25 - jruby-9.1.0.0 - rbx-2 gemfile: - gemfiles/active_record_30.gemfile - gemfiles/active_record_31.gemfile - gemfiles/active_record_32.gemfile - gemfiles/active_record_40.gemfile - gemfiles/active_record_41.gemfile - gemfiles/active_record_42.gemfile - gemfiles/active_record_edge.gemfile - gemfiles/data_mapper_12.gemfile - gemfiles/mongo_mapper.gemfile - gemfiles/mongoid_30.gemfile - gemfiles/mongoid_31.gemfile - gemfiles/mongoid_40.gemfile - gemfiles/mongoid_50.gemfile - gemfiles/sinatra_13.gemfile - gemfiles/sinatra_14.gemfile sudo: false services: mongodb script: "bundle exec rake spec" cache: bundler matrix: exclude: - rvm: 1.9.3 gemfile: gemfiles/active_record_edge.gemfile - rvm: 2.0.0 gemfile: gemfiles/active_record_edge.gemfile - rvm: 2.1.10 gemfile: gemfiles/active_record_edge.gemfile - rvm: 2.2.5 gemfile: gemfiles/active_record_30.gemfile - rvm: 2.2.5 gemfile: gemfiles/active_record_31.gemfile - rvm: 2.2.5 gemfile: gemfiles/active_record_32.gemfile - rvm: 2.3.1 gemfile: gemfiles/active_record_30.gemfile - rvm: 2.3.1 gemfile: gemfiles/active_record_31.gemfile - rvm: 2.3.1 gemfile: gemfiles/active_record_32.gemfile - rvm: jruby-1.7.25 gemfile: gemfiles/active_record_edge.gemfile allow_failures: - rvm: jruby-1.7.25 - rvm: jruby-9.1.0.0 - rvm: rbx-2 fast_finish: true kaminari-0.17.0/gemfiles/ 0000755 0001750 0001750 00000000000 12727211600 015311 5 ustar abhijith abhijith kaminari-0.17.0/gemfiles/data_mapper_12.gemfile 0000644 0001750 0001750 00000001255 12727211600 021425 0 ustar abhijith abhijith source 'https://rubygems.org' gem 'railties', '~> 3.2.21' gem 'dm-core', '~> 1.2.0' gem 'dm-migrations', '~> 1.2.0' gem 'dm-aggregates', '~> 1.2.0' gem 'dm-transactions', '~> 1.2.0' gem 'dm-active_model', '~> 1.2.1' gem 'dm-sqlite-adapter', '~> 1.2.0' gem 'rspec-rails', '~> 2.14.1' gem 'mime-types', '2.99' if RUBY_VERSION < '2.0.0' platforms :ruby do if RUBY_VERSION > "2.1.0" gem 'sqlite3' gem 'test-unit' else gem 'sqlite3', '1.3.8' end end platforms :jruby do gem 'activerecord-jdbcsqlite3-adapter', '~> 1.2.0' end platforms :rbx do gem 'rubysl', '~> 2.0' gem 'racc' gem 'rubysl-test-unit' gem 'rubinius-developer_tools' end gemspec :path => '../' kaminari-0.17.0/gemfiles/mongoid_30.gemfile 0000644 0001750 0001750 00000000663 12727211600 020606 0 ustar abhijith abhijith source 'https://rubygems.org' gem 'railties', '>= 3.2.3' gem 'mongoid', '~> 3.0.0' gem 'rspec-rails', '~> 2.14.1' gem 'origin' gem 'moped' gem 'activesupport', '~> 3.2.18' gem 'mime-types', '2.99' if RUBY_VERSION == '1.9.3' platforms :mri do gem 'test-unit' if RUBY_VERSION > "2.1.0" end platforms :rbx do gem 'rubysl', '~> 2.0' gem 'racc' gem 'rubysl-test-unit' gem 'rubinius-developer_tools' end gemspec :path => '../' kaminari-0.17.0/gemfiles/sinatra_14.gemfile 0000644 0001750 0001750 00000001161 12727211600 020607 0 ustar abhijith abhijith source 'https://rubygems.org' gem 'sinatra', '~> 1.4.0' gem 'rspec', '~> 2.14.1' gem 'activerecord', '>= 4.0.0', :require => 'active_record' gem 'padrino-helpers', '~> 0.12.0' gem 'rack-test', '>= 0' gem 'sinatra-contrib', '~> 1.4.0' if RUBY_VERSION == '1.9.3' gem 'mime-types', '2.99' end platforms :ruby do if RUBY_VERSION > "2.1.0" gem 'sqlite3' else gem 'sqlite3', '1.3.8' end end platforms :jruby do gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0' end platforms :rbx do gem 'rubysl', '~> 2.0' gem 'racc' gem 'rubysl-test-unit' gem 'rubinius-developer_tools' end gemspec :path => '../' kaminari-0.17.0/gemfiles/mongo_mapper.gemfile 0000644 0001750 0001750 00000000627 12727211600 021333 0 ustar abhijith abhijith source 'https://rubygems.org' gem 'railties', '>= 3.2.3' gem 'bson', '~> 1.9.2' gem 'mongo_mapper', '>= 0.11.0' gem 'rspec-rails', '~> 2.14.1' gem 'capybara' gem 'nokogiri' gem 'rubyzip' if RUBY_VERSION == '1.9.3' gem 'mime-types', '2.99' else gem 'mime-types' end platforms :rbx do gem 'rubysl', '~> 2.0' gem 'racc' gem 'minitest' gem 'rubinius-developer_tools' end gemspec :path => '../' kaminari-0.17.0/gemfiles/mongoid_31.gemfile 0000644 0001750 0001750 00000000620 12727211600 020600 0 ustar abhijith abhijith source 'https://rubygems.org' gem 'railties', '~> 3.2' gem 'mongoid', '~> 3.1.0' gem 'rspec-rails', '~> 2.14.1' gem 'origin' gem 'moped' gem 'mime-types', '2.99' if RUBY_VERSION == '1.9.3' platforms :mri do gem 'test-unit' if RUBY_VERSION > "2.1.0" end platforms :rbx do gem 'rubysl', '~> 2.0' gem 'racc' gem 'rubysl-test-unit' gem 'rubinius-developer_tools' end gemspec :path => '../' kaminari-0.17.0/gemfiles/active_record_41.gemfile 0000644 0001750 0001750 00000001012 12727211600 021752 0 ustar abhijith abhijith source 'https://rubygems.org' gem 'railties', '~> 4.1.0' gem 'activerecord', '~> 4.1.0', :require => 'active_record' gem 'rspec-rails', '~> 2.14.1' gem 'mime-types', '2.99' if RUBY_VERSION == '1.9.3' platforms :ruby do if RUBY_VERSION > "2.1.0" gem 'sqlite3' else gem 'sqlite3', '1.3.8' end end platforms :jruby do gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0' end platforms :rbx do gem 'rubysl', '~> 2.0' gem 'racc' gem 'minitest' gem 'rubinius-developer_tools' end gemspec :path => '../' kaminari-0.17.0/gemfiles/active_record_42.gemfile 0000644 0001750 0001750 00000001012 12727211600 021753 0 ustar abhijith abhijith source 'https://rubygems.org' gem 'railties', '~> 4.2.0' gem 'activerecord', '~> 4.2.0', :require => 'active_record' gem 'rspec-rails', '~> 2.14.1' gem 'mime-types', '2.99' if RUBY_VERSION == '1.9.3' platforms :ruby do if RUBY_VERSION > "2.1.0" gem 'sqlite3' else gem 'sqlite3', '1.3.8' end end platforms :jruby do gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0' end platforms :rbx do gem 'rubysl', '~> 2.0' gem 'racc' gem 'minitest' gem 'rubinius-developer_tools' end gemspec :path => '../' kaminari-0.17.0/gemfiles/mongoid_50.gemfile 0000644 0001750 0001750 00000000666 12727211600 020613 0 ustar abhijith abhijith source 'https://rubygems.org' gem 'railties', '~> 4.0' gem 'mongoid', '~> 5.0.0' gem 'rspec-rails', '~> 2.14.1' gem 'mime-types', '2.99' if RUBY_VERSION == '1.9.3' group :development, :test do gem 'database_cleaner', '~> 1.5.1' end platforms :mri do gem 'test-unit' if RUBY_VERSION > '2.1.0' end platforms :rbx do gem 'rubysl', '~> 2.0' gem 'racc' gem 'minitest' gem 'rubinius-developer_tools' end gemspec :path => '../' kaminari-0.17.0/gemfiles/active_record_31.gemfile 0000644 0001750 0001750 00000001024 12727211600 021754 0 ustar abhijith abhijith source 'https://rubygems.org' gem 'railties', '~> 3.1.12' gem 'activerecord', '~> 3.1.12', :require => 'active_record' gem 'rspec-rails', '~> 2.14.1' gem 'mime-types', '2.99' if RUBY_VERSION < '2.0.0' platforms :ruby do if RUBY_VERSION > "2.1.0" gem 'sqlite3' else gem 'sqlite3', '1.3.8' end end platforms :jruby do gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0' end platforms :rbx do gem 'rubysl', '~> 2.0' gem 'racc' gem 'rubysl-test-unit' gem 'rubinius-developer_tools' end gemspec :path => '../' kaminari-0.17.0/gemfiles/sinatra_13.gemfile 0000644 0001750 0001750 00000001337 12727211600 020613 0 ustar abhijith abhijith source 'https://rubygems.org' gem 'sinatra', '~> 1.3.0' gem 'tilt' if RUBY_VERSION >= "2.2.0" gem 'activerecord', '>= 4.0.0', :require => 'active_record' gem 'padrino-helpers' else gem 'activerecord', '~> 3.2.3', :require => 'active_record' gem 'padrino-helpers', '~> 0.10.6' end gem 'rack-test' gem 'sinatra-contrib' gem 'rspec', '~> 2.14.1' gem 'mime-types', '2.99' if RUBY_VERSION == '1.9.3' platforms :ruby do if RUBY_VERSION > "2.1.0" gem 'sqlite3' else gem 'sqlite3', '1.3.8' end end platforms :jruby do gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0' end platforms :rbx do gem 'rubysl', '~> 2.0' gem 'racc' gem 'rubysl-test-unit' gem 'rubinius-developer_tools' end gemspec :path => '../' kaminari-0.17.0/gemfiles/active_record_30.gemfile 0000644 0001750 0001750 00000001104 12727211600 021752 0 ustar abhijith abhijith source 'https://rubygems.org' gem 'railties', '~> 3.0.20' gem 'activerecord', '~> 3.0.20', :require => 'active_record' gem 'rspec-rails', '~> 2.14.1' gem 'nokogiri', '< 1.6' gem 'capybara', '< 2.1' gem 'mime-types', '2.99' if RUBY_VERSION < '2.0.0' platforms :ruby do if RUBY_VERSION > "2.1.0" gem 'sqlite3' else gem 'sqlite3', '1.3.8' end end platforms :jruby do gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0' end platforms :rbx do gem 'rubysl', '~> 2.0' gem 'racc' gem 'rubysl-test-unit' gem 'rubinius-developer_tools' end gemspec :path => '../' kaminari-0.17.0/gemfiles/active_record_40.gemfile 0000644 0001750 0001750 00000001046 12727211600 021760 0 ustar abhijith abhijith source 'https://rubygems.org' gem 'railties', '~> 4.0.0' gem 'activerecord', '~> 4.0.0', :require => 'active_record' gem 'rspec-rails', '~> 2.14.1' gem 'mime-types', '2.99' if RUBY_VERSION == '1.9.3' platforms :ruby do if RUBY_VERSION > "2.1.0" gem 'sqlite3' gem 'test-unit' else gem 'sqlite3', '1.3.8' end end platforms :jruby do gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0' end platforms :rbx do gem 'rubysl', '~> 2.0' gem 'racc' gem 'rubysl-test-unit' gem 'rubinius-developer_tools' end gemspec :path => '../' kaminari-0.17.0/gemfiles/active_record_32.gemfile 0000644 0001750 0001750 00000001021 12727211600 021752 0 ustar abhijith abhijith source 'https://rubygems.org' gem 'railties', '~> 3.2.3' gem 'activerecord', '~> 3.2.3', :require => 'active_record' gem 'rspec-rails', '~> 2.14.1' gem 'mime-types', '2.99' if RUBY_VERSION < '2.0.0' platforms :ruby do if RUBY_VERSION > "2.1.0" gem 'sqlite3' else gem 'sqlite3', '1.3.8' end end platforms :jruby do gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0' end platforms :rbx do gem 'rubysl', '~> 2.0' gem 'racc' gem 'rubysl-test-unit' gem 'rubinius-developer_tools' end gemspec :path => '../' kaminari-0.17.0/gemfiles/active_record_edge.gemfile 0000644 0001750 0001750 00000001101 12727211600 022431 0 ustar abhijith abhijith source 'https://rubygems.org' git 'git://github.com/rails/rails.git' do gem 'railties' gem 'activerecord', :require => 'active_record' gem 'actionview', :require => 'action_view' end gem 'arel', :github => 'rails/arel' platforms :ruby do if RUBY_VERSION > "2.1.0" gem 'sqlite3' else gem 'sqlite3', '1.3.8' end end platforms :jruby do gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0' end platforms :rbx do gem 'rubysl', '~> 2.0' gem 'racc' gem 'minitest' gem 'rubinius-developer_tools' end gem 'rspec-rails', '2.99.0' gemspec :path => '../' kaminari-0.17.0/gemfiles/mongoid_40.gemfile 0000644 0001750 0001750 00000000565 12727211600 020610 0 ustar abhijith abhijith source 'https://rubygems.org' gem 'railties', '~> 4.0' gem "mongoid", "~> 4.0.0.beta2" gem 'rspec-rails', '~> 2.14.1' gem 'mime-types', '2.99' if RUBY_VERSION == '1.9.3' platforms :mri do gem 'test-unit' if RUBY_VERSION > "2.1.0" end platforms :rbx do gem 'rubysl', '~> 2.0' gem 'racc' gem 'minitest' gem 'rubinius-developer_tools' end gemspec :path => '../' kaminari-0.17.0/app/ 0000755 0001750 0001750 00000000000 12727211600 014276 5 ustar abhijith abhijith kaminari-0.17.0/app/views/ 0000755 0001750 0001750 00000000000 12727211600 015433 5 ustar abhijith abhijith kaminari-0.17.0/app/views/kaminari/ 0000755 0001750 0001750 00000000000 12727211600 017226 5 ustar abhijith abhijith kaminari-0.17.0/app/views/kaminari/_gap.html.erb 0000644 0001750 0001750 00000000541 12727211600 021571 0 ustar abhijith abhijith <%# Non-link tag that stands for skipped pages... - available local variables current_page: a page object for the currently displayed page total_pages: total number of pages per_page: number of items to fetch per page remote: data-remote -%> <%= t('views.pagination.truncate').html_safe %> kaminari-0.17.0/app/views/kaminari/_page.html.slim 0000644 0001750 0001750 00000000772 12727211600 022140 0 ustar abhijith abhijith / Link showing page number - available local variables page : a page object for "this" page url : url to this page current_page : a page object for the currently displayed page total_pages : total number of pages per_page : number of items to fetch per page remote : data-remote span class="page#{' current' if page.current?}" == link_to_unless page.current?, page, url, {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} ' kaminari-0.17.0/app/views/kaminari/_paginator.html.erb 0000644 0001750 0001750 00000001502 12727211600 023004 0 ustar abhijith abhijith <%# The container tag - available local variables current_page: a page object for the currently displayed page total_pages: total number of pages per_page: number of items to fetch per page remote: data-remote paginator: the paginator that renders the pagination tags inside -%> <%= paginator.render do -%> <% end -%> kaminari-0.17.0/app/views/kaminari/_page.html.haml 0000644 0001750 0001750 00000001013 12727211600 022102 0 ustar abhijith abhijith -# Link showing page number -# available local variables -# page: a page object for "this" page -# url: url to this page -# current_page: a page object for the currently displayed page -# total_pages: total number of pages -# per_page: number of items to fetch per page -# remote: data-remote %span{:class => "page#{' current' if page.current?}"} = link_to_unless page.current?, page, url, {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} kaminari-0.17.0/app/views/kaminari/_next_page.html.slim 0000644 0001750 0001750 00000000637 12727211600 023176 0 ustar abhijith abhijith / Link to the "Next" page - available local variables url : url to the next page current_page : a page object for the currently displayed page total_pages : total number of pages per_page : number of items to fetch per page remote : data-remote span.next == link_to_unless current_page.last?, t('views.pagination.next').html_safe, url, :rel => 'next', :remote => remote ' kaminari-0.17.0/app/views/kaminari/_next_page.html.haml 0000644 0001750 0001750 00000000652 12727211600 023150 0 ustar abhijith abhijith -# Link to the "Next" page -# available local variables -# url: url to the next page -# current_page: a page object for the currently displayed page -# total_pages: total number of pages -# per_page: number of items to fetch per page -# remote: data-remote %span.next = link_to_unless current_page.last?, t('views.pagination.next').html_safe, url, :rel => 'next', :remote => remote kaminari-0.17.0/app/views/kaminari/_gap.html.slim 0000644 0001750 0001750 00000000513 12727211600 021764 0 ustar abhijith abhijith / Non-link tag that stands for skipped pages... - available local variables current_page : a page object for the currently displayed page total_pages : total number of pages per_page : number of items to fetch per page remote : data-remote span.page.gap == t('views.pagination.truncate').html_safe ' kaminari-0.17.0/app/views/kaminari/_prev_page.html.erb 0000644 0001750 0001750 00000000707 12727211600 022776 0 ustar abhijith abhijith <%# Link to the "Previous" page - available local variables url: url to the previous page current_page: a page object for the currently displayed page total_pages: total number of pages per_page: number of items to fetch per page remote: data-remote -%> <%= link_to_unless current_page.first?, t('views.pagination.previous').html_safe, url, :rel => 'prev', :remote => remote %> kaminari-0.17.0/app/views/kaminari/_prev_page.html.slim 0000644 0001750 0001750 00000000655 12727211600 023174 0 ustar abhijith abhijith / Link to the "Previous" page - available local variables url : url to the previous page current_page : a page object for the currently displayed page total_pages : total number of pages per_page : number of items to fetch per page remote : data-remote span.prev == link_to_unless current_page.first?, t('views.pagination.previous').html_safe, url, :rel => 'prev', :remote => remote ' kaminari-0.17.0/app/views/kaminari/_prev_page.html.haml 0000644 0001750 0001750 00000000667 12727211600 023154 0 ustar abhijith abhijith -# Link to the "Previous" page -# available local variables -# url: url to the previous page -# current_page: a page object for the currently displayed page -# total_pages: total number of pages -# per_page: number of items to fetch per page -# remote: data-remote %span.prev = link_to_unless current_page.first?, t('views.pagination.previous').html_safe, url, :rel => 'prev', :remote => remote kaminari-0.17.0/app/views/kaminari/_last_page.html.slim 0000644 0001750 0001750 00000000617 12727211600 023161 0 ustar abhijith abhijith / Link to the "Last" page - available local variables url : url to the last page current_page : a page object for the currently displayed page total_pages : total number of pages per_page : number of items to fetch per page remote : data-remote span.last == link_to_unless current_page.last?, t('views.pagination.last').html_safe, url, :remote => remote ' kaminari-0.17.0/app/views/kaminari/_last_page.html.erb 0000644 0001750 0001750 00000000652 12727211600 022764 0 ustar abhijith abhijith <%# Link to the "Last" page - available local variables url: url to the last page current_page: a page object for the currently displayed page total_pages: total number of pages per_page: number of items to fetch per page remote: data-remote -%> <%= link_to_unless current_page.last?, t('views.pagination.last').html_safe, url, :remote => remote %> kaminari-0.17.0/app/views/kaminari/_last_page.html.haml 0000644 0001750 0001750 00000000632 12727211600 023133 0 ustar abhijith abhijith -# Link to the "Last" page -# available local variables -# url: url to the last page -# current_page: a page object for the currently displayed page -# total_pages: total number of pages -# per_page: number of items to fetch per page -# remote: data-remote %span.last = link_to_unless current_page.last?, t('views.pagination.last').html_safe, url, :remote => remote kaminari-0.17.0/app/views/kaminari/_paginator.html.slim 0000644 0001750 0001750 00000001323 12727211600 023201 0 ustar abhijith abhijith / The container tag - available local variables current_page : a page object for the currently displayed page total_pages : total number of pages per_page : number of items to fetch per page remote : data-remote paginator : the paginator that renders the pagination tags inside == paginator.render do nav.pagination == first_page_tag unless current_page.first? == prev_page_tag unless current_page.first? - each_page do |page| - if page.left_outer? || page.right_outer? || page.inside_window? == page_tag page - elsif !page.was_truncated? == gap_tag == next_page_tag unless current_page.last? == last_page_tag unless current_page.last? kaminari-0.17.0/app/views/kaminari/_paginator.html.haml 0000644 0001750 0001750 00000001330 12727211600 023154 0 ustar abhijith abhijith -# The container tag -# available local variables -# current_page: a page object for the currently displayed page -# total_pages: total number of pages -# per_page: number of items to fetch per page -# remote: data-remote -# paginator: the paginator that renders the pagination tags inside = paginator.render do %nav.pagination = first_page_tag unless current_page.first? = prev_page_tag unless current_page.first? - each_page do |page| - if page.left_outer? || page.right_outer? || page.inside_window? = page_tag page - elsif !page.was_truncated? = gap_tag = next_page_tag unless current_page.last? = last_page_tag unless current_page.last? kaminari-0.17.0/app/views/kaminari/_first_page.html.slim 0000644 0001750 0001750 00000000625 12727211600 023344 0 ustar abhijith abhijith / Link to the "First" page - available local variables url : url to the first page current_page : a page object for the currently displayed page total_pages : total number of pages per_page : number of items to fetch per page remote : data-remote span.first == link_to_unless current_page.first?, t('views.pagination.first').html_safe, url, :remote => remote ' kaminari-0.17.0/app/views/kaminari/_next_page.html.erb 0000644 0001750 0001750 00000000672 12727211600 023001 0 ustar abhijith abhijith <%# Link to the "Next" page - available local variables url: url to the next page current_page: a page object for the currently displayed page total_pages: total number of pages per_page: number of items to fetch per page remote: data-remote -%> <%= link_to_unless current_page.last?, t('views.pagination.next').html_safe, url, :rel => 'next', :remote => remote %> kaminari-0.17.0/app/views/kaminari/_page.html.erb 0000644 0001750 0001750 00000001020 12727211600 021727 0 ustar abhijith abhijith <%# Link showing page number - available local variables page: a page object for "this" page url: url to this page current_page: a page object for the currently displayed page total_pages: total number of pages per_page: number of items to fetch per page remote: data-remote -%> <%= link_to_unless page.current?, page, url, {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} %> kaminari-0.17.0/app/views/kaminari/_first_page.html.haml 0000644 0001750 0001750 00000000637 12727211600 023324 0 ustar abhijith abhijith -# Link to the "First" page -# available local variables -# url: url to the first page -# current_page: a page object for the currently displayed page -# total_pages: total number of pages -# per_page: number of items to fetch per page -# remote: data-remote %span.first = link_to_unless current_page.first?, t('views.pagination.first').html_safe, url, :remote => remote kaminari-0.17.0/app/views/kaminari/_gap.html.haml 0000644 0001750 0001750 00000000523 12727211600 021742 0 ustar abhijith abhijith -# Non-link tag that stands for skipped pages... -# available local variables -# current_page: a page object for the currently displayed page -# total_pages: total number of pages -# per_page: number of items to fetch per page -# remote: data-remote %span.page.gap = t('views.pagination.truncate').html_safe kaminari-0.17.0/app/views/kaminari/_first_page.html.erb 0000644 0001750 0001750 00000000657 12727211600 023155 0 ustar abhijith abhijith <%# Link to the "First" page - available local variables url: url to the first page current_page: a page object for the currently displayed page total_pages: total number of pages per_page: number of items to fetch per page remote: data-remote -%> <%= link_to_unless current_page.first?, t('views.pagination.first').html_safe, url, :remote => remote %> kaminari-0.17.0/Gemfile 0000644 0001750 0001750 00000000135 12727211600 015010 0 ustar abhijith abhijith source 'https://rubygems.org' # Specify your gem's dependencies in kaminari.gemspec gemspec kaminari-0.17.0/config/ 0000755 0001750 0001750 00000000000 12727211600 014763 5 ustar abhijith abhijith kaminari-0.17.0/config/locales/ 0000755 0001750 0001750 00000000000 12727211600 016405 5 ustar abhijith abhijith kaminari-0.17.0/config/locales/kaminari.yml 0000644 0001750 0001750 00000001211 12727211600 020716 0 ustar abhijith abhijith # Sample localization file for Kaminari. You can override these values in your app's locales file if you want. en: views: pagination: first: "« First" last: "Last »" previous: "‹ Prev" next: "Next ›" truncate: "…" helpers: page_entries_info: one_page: display_entries: zero: "No %{entry_name} found" one: "Displaying 1 %{entry_name}" other: "Displaying all %{count} %{entry_name}" more_pages: display_entries: "Displaying %{entry_name} %{first} - %{last} of %{total} in total" kaminari-0.17.0/Rakefile 0000644 0001750 0001750 00000002627 12727211600 015172 0 ustar abhijith abhijith # encoding: utf-8 require 'bundler' Bundler::GemHelper.install_tasks require 'rspec/core' require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) do |spec| spec.pattern = FileList['spec/**/*_spec.rb'] end task :default => "spec:all" namespace :spec do mappers = %w( active_record_edge active_record_42 active_record_41 active_record_40 active_record_32 active_record_31 active_record_30 data_mapper_12 mongoid_50 mongoid_40 mongoid_31 mongoid_30 mongoid_24 mongo_mapper sinatra_13 sinatra_14 ) mappers.each do |gemfile| desc "Run Tests against #{gemfile}" task gemfile do sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle --quiet" sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle exec rake -t spec" end end desc "Run Tests against all ORMs" task :all do mappers.each do |gemfile| sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle --quiet" sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle exec rake spec" end end end begin require 'rdoc/task' Rake::RDocTask.new do |rdoc| require 'kaminari/version' rdoc.rdoc_dir = 'rdoc' rdoc.title = "kaminari #{Kaminari::VERSION}" rdoc.rdoc_files.include('README*') rdoc.rdoc_files.include('lib/**/*.rb') end rescue LoadError puts 'RDocTask is not supported on this VM and platform combination.' end kaminari-0.17.0/lib/ 0000755 0001750 0001750 00000000000 12727211600 014264 5 ustar abhijith abhijith kaminari-0.17.0/lib/kaminari/ 0000755 0001750 0001750 00000000000 12727211600 016057 5 ustar abhijith abhijith kaminari-0.17.0/lib/kaminari/sinatra.rb 0000644 0001750 0001750 00000000436 12727211600 020050 0 ustar abhijith abhijith require 'sinatra/base' require 'kaminari' require 'kaminari/helpers/sinatra_helpers' ActiveSupport::Deprecation.warn 'Kaminari Sinatra support has been extracted to a separate gem, and will be removed in the next 1.0 release. Please bundle kaminari-sinatra gem.' Kaminari::Hooks.init kaminari-0.17.0/lib/kaminari/helpers/ 0000755 0001750 0001750 00000000000 12727211600 017521 5 ustar abhijith abhijith kaminari-0.17.0/lib/kaminari/helpers/tags.rb 0000644 0001750 0001750 00000006006 12727211600 021006 0 ustar abhijith abhijith module Kaminari module Helpers # A tag stands for an HTML tag inside the paginator. # Basically, a tag has its own partial template file, so every tag can be # rendered into String using its partial template. # # The template file should be placed in your app/views/kaminari/ directory # with underscored class name (besides the "Tag" class. Tag is an abstract # class, so _tag parital is not needed). # e.g.) PrevLink -> app/views/kaminari/_prev_link.html.erb # # When no matching template were found in your app, the engine's pre # installed template will be used. # e.g.) Paginator -> $GEM_HOME/kaminari-x.x.x/app/views/kaminari/_paginator.html.erb class Tag def initialize(template, options = {}) #:nodoc: @template, @options = template, options.dup @param_name = @options.delete(:param_name) || Kaminari.config.param_name @theme = @options.delete(:theme) @views_prefix = @options.delete(:views_prefix) @params = template.params # @params in Rails 5 no longer inherits from Hash @params = @params.to_unsafe_h if @params.respond_to?(:to_unsafe_h) @params = @params.except(:script_name).merge(@options.delete(:params) || {}) end def to_s(locals = {}) #:nodoc: @template.render :partial => partial_path, :locals => @options.merge(locals), :formats => [:html] end def page_url_for(page) @template.url_for @params.merge(@param_name => (page <= 1 ? nil : page), :only_path => true) end def partial_path [ @views_prefix, "kaminari", @theme, self.class.name.demodulize.underscore ].compact.join("/") end end # Tag that contains a link module Link # target page number def page raise 'Override page with the actual page value to be a Page.' end # the link's href def url page_url_for page end def to_s(locals = {}) #:nodoc: super locals.merge(:url => url) end end # A page class Page < Tag include Link # target page number def page @options[:page] end def to_s(locals = {}) #:nodoc: super locals.merge(:page => page) end end # Link with page number that appears at the leftmost class FirstPage < Tag include Link def page #:nodoc: 1 end end # Link with page number that appears at the rightmost class LastPage < Tag include Link def page #:nodoc: @options[:total_pages] end end # The "previous" page of the current page class PrevPage < Tag include Link def page #:nodoc: @options[:current_page] - 1 end end # The "next" page of the current page class NextPage < Tag include Link def page #:nodoc: @options[:current_page] + 1 end end # Non-link tag that stands for skipped pages... class Gap < Tag end end end kaminari-0.17.0/lib/kaminari/helpers/paginator.rb 0000644 0001750 0001750 00000014312 12727211600 022033 0 ustar abhijith abhijith require 'active_support/inflector' require 'action_view' require 'action_view/log_subscriber' require 'action_view/context' require 'kaminari/helpers/tags' module Kaminari module Helpers # The main container tag class Paginator < Tag # so that this instance can actually "render" include ::ActionView::Context def initialize(template, options) #:nodoc: ActiveSupport::Deprecation.warn 'num_pages is deprecated and will be removed in Kaminari 1.0. Please use total_pages instead.' if options.has_key? :num_pages options[:num_pages] ||= options[:total_pages] @window_options = {}.tap do |h| h[:window] = options.delete(:window) || options.delete(:inner_window) || Kaminari.config.window outer_window = options.delete(:outer_window) || Kaminari.config.outer_window h[:left] = options.delete(:left) || Kaminari.config.left h[:left] = outer_window if h[:left] == 0 h[:right] = options.delete(:right) || Kaminari.config.right h[:right] = outer_window if h[:right] == 0 end @template, @options = template, options @theme = @options[:theme] @views_prefix = @options[:views_prefix] @window_options.merge! @options @window_options[:current_page] = @options[:current_page] = PageProxy.new(@window_options, @options[:current_page], nil) @last = nil # initialize the output_buffer for Context @output_buffer = ActionView::OutputBuffer.new end # render given block as a view template def render(&block) instance_eval(&block) if @options[:total_pages] > 1 @output_buffer end # enumerate each page providing PageProxy object as the block parameter # Because of performance reason, this doesn't actually enumerate all pages but pages that are seemingly relevant to the paginator. # "Relevant" pages are: # * pages inside the left outer window plus one for showing the gap tag # * pages inside the inner window plus one on the left plus one on the right for showing the gap tags # * pages inside the right outer window plus one for showing the gap tag def each_relevant_page return to_enum(:each_relevant_page) unless block_given? relevant_pages(@window_options).each do |page| yield PageProxy.new(@window_options, page, @last) end end alias each_page each_relevant_page def relevant_pages(options) left_window_plus_one = 1.upto(options[:left] + 1).to_a right_window_plus_one = (options[:total_pages] - options[:right]).upto(options[:total_pages]).to_a inside_window_plus_each_sides = (options[:current_page] - options[:window] - 1).upto(options[:current_page] + options[:window] + 1).to_a (left_window_plus_one + inside_window_plus_each_sides + right_window_plus_one).uniq.sort.reject {|x| (x < 1) || (x > options[:total_pages])} end private :relevant_pages def page_tag(page) @last = Page.new @template, @options.merge(:page => page) end %w[first_page prev_page next_page last_page gap].each do |tag| eval <<-DEF def #{tag}_tag @last = #{tag.classify}.new @template, @options end DEF end def to_s #:nodoc: subscriber = ActionView::LogSubscriber.log_subscribers.detect {|ls| ls.is_a? ActionView::LogSubscriber} # There is a logging subscriber # and we don't want it to log render_partial # It is threadsafe, but might not repress logging # consistently in a high-load environment if subscriber unless defined? subscriber.render_partial_with_logging class << subscriber alias_method :render_partial_with_logging, :render_partial attr_accessor :render_without_logging # ugly hack to make a renderer where # we can turn logging on or off def render_partial(event) render_partial_with_logging(event) unless render_without_logging end end end subscriber.render_without_logging = true ret = super @window_options.merge :paginator => self subscriber.render_without_logging = false ret else super @window_options.merge :paginator => self end end # delegates view helper methods to @template def method_missing(name, *args, &block) @template.respond_to?(name) ? @template.send(name, *args, &block) : super end private :method_missing # Wraps a "page number" and provides some utility methods class PageProxy include Comparable def initialize(options, page, last) #:nodoc: @options, @page, @last = options, page, last end # the page number def number @page end # current page or not def current? @page == @options[:current_page] end # the first page or not def first? @page == 1 end # the last page or not def last? @page == @options[:total_pages] end # the previous page or not def prev? @page == @options[:current_page] - 1 end # the next page or not def next? @page == @options[:current_page] + 1 end # within the left outer window or not def left_outer? @page <= @options[:left] end # within the right outer window or not def right_outer? @options[:total_pages] - @page < @options[:right] end # inside the inner window or not def inside_window? (@options[:current_page] - @page).abs <= @options[:window] end # The last rendered tag was "truncated" or not def was_truncated? @last.is_a? Gap end def to_i number end def to_s number.to_s end def +(other) to_i + other.to_i end def -(other) to_i - other.to_i end def <=>(other) to_i <=> other.to_i end end end end end kaminari-0.17.0/lib/kaminari/helpers/sinatra_helpers.rb 0000644 0001750 0001750 00000014330 12727211600 023232 0 ustar abhijith abhijith require 'active_support/core_ext/object' require 'active_support/core_ext/string' require 'action_dispatch/http/mime_type' begin require 'padrino-helpers' module Kaminari::Helpers module SinatraHelpers class << self def registered(app) app.register Padrino::Helpers app.helpers HelperMethods @app = app end def view_paths @app.views end alias included registered end class ActionViewTemplateProxy include Padrino::Helpers::OutputHelpers include Padrino::Helpers::TagHelpers include Padrino::Helpers::AssetTagHelpers include Padrino::Helpers::FormatHelpers include Padrino::Helpers::TranslationHelpers def initialize(opts={}) @current_path = opts[:current_path] @param_name = (opts[:param_name] || :page).to_sym @current_params = opts[:current_params] @current_params.delete(@param_name) end def render(*args) base = ActionView::Base.new.tap do |a| a.view_paths << SinatraHelpers.view_paths a.view_paths << File.expand_path('../../../../app/views', __FILE__) end base.render(*args) end def url_for(params) extra_params = {} if page = params[@param_name] and page != 1 extra_params[@param_name] = page end query = @current_params.merge(extra_params) @current_path + (query.empty? ? '' : "?#{query.to_query}") end def link_to_unless(condition, name, options = {}, html_options = {}, &block) options = url_for(options) if options.is_a? Hash if condition if block_given? block.arity <= 1 ? capture(name, &block) : capture(name, options, html_options, &block) else name end else link_to(name, options, html_options) end end def params @current_params end end module HelperMethods # A helper that renders the pagination links - for Sinatra. # # <%= paginate @articles %> # # ==== Options # * :window - The "inner window" size (4 by default). # * :outer_window - The "outer window" size (0 by default). # * :left - The "left outer window" size (0 by default). # * :right - The "right outer window" size (0 by default). # * :params - url_for parameters for the links (:id, :locale, etc.) # * :param_name - parameter name for page number in the links (:page by default) # * :remote - Ajax? (false by default) # * :ANY_OTHER_VALUES - Any other hash key & values would be directly passed into each tag as :locals value. def paginate(scope, options = {}, &block) current_path = env['PATH_INFO'] rescue nil current_params = Rack::Utils.parse_query(env['QUERY_STRING']).symbolize_keys rescue {} paginator = Kaminari::Helpers::Paginator.new( ActionViewTemplateProxy.new(:current_params => current_params, :current_path => current_path, :param_name => options[:param_name] || Kaminari.config.param_name), options.reverse_merge(:current_page => scope.current_page, :total_pages => scope.total_pages, :per_page => scope.limit_value, :param_name => Kaminari.config.param_name, :remote => false) ) paginator.to_s end # A simple "Twitter like" pagination link that creates a link to the previous page. # Works on Sinatra. # # ==== Examples # Basic usage: # # <%= link_to_previous_page @items, 'Previous Page' %> # # Ajax: # # <%= link_to_previous_page @items, 'Previous Page', :remote => true %> # # By default, it renders nothing if there are no more results on the previous page. # You can customize this output by passing a parameter :placeholder. # # <%= link_to_previous_page @users, 'Previous Page', :placeholder => %{At the Beginning} %> # def link_to_previous_page(scope, name, options = {}) params = options.delete(:params) || (Rack::Utils.parse_query(env['QUERY_STRING']).symbolize_keys rescue {}) param_name = options.delete(:param_name) || Kaminari.config.param_name placeholder = options.delete(:placeholder) unless scope.first_page? query = params.merge(param_name => scope.prev_page) link_to name, env['PATH_INFO'] + (query.empty? ? '' : "?#{query.to_query}"), options.reverse_merge(:rel => 'previous') else placeholder.to_s.html_safe end end # A simple "Twitter like" pagination link that creates a link to the next page. # Works on Sinatra. # # ==== Examples # Basic usage: # # <%= link_to_next_page @items, 'Next Page' %> # # Ajax: # # <%= link_to_next_page @items, 'Next Page', :remote => true %> # # By default, it renders nothing if there are no more results on the next page. # You can customize this output by passing a parameter :placeholder. # # <%= link_to_next_page @items, 'Next Page', :placeholder => %{No More Pages} %> # def link_to_next_page(scope, name, options = {}) params = options.delete(:params) || (Rack::Utils.parse_query(env['QUERY_STRING']).symbolize_keys rescue {}) param_name = options.delete(:param_name) || Kaminari.config.param_name placeholder = options.delete(:placeholder) unless scope.last_page? query = params.merge(param_name => scope.next_page) link_to name, env['PATH_INFO'] + (query.empty? ? '' : "?#{query.to_query}"), options.reverse_merge(:rel => 'next') else placeholder.to_s.html_safe end end end end end if defined? I18n I18n.load_path += Dir.glob(File.expand_path('../../../../config/locales/*.yml', __FILE__)) end rescue LoadError $stderr.puts "[!]You should install `padrino-helpers' gem if you want to use kaminari's pagination helpers with Sinatra." $stderr.puts "[!]Kaminari::Helpers::SinatraHelper does nothing now..." module Kaminari::Helpers module SinatraHelper def self.registered(*) end end end end kaminari-0.17.0/lib/kaminari/helpers/action_view_extension.rb 0000644 0001750 0001750 00000012403 12727211600 024451 0 ustar abhijith abhijith module Kaminari # = Helpers module ActionViewExtension # A helper that renders the pagination links. # # <%= paginate @articles %> # # ==== Options # * :window - The "inner window" size (4 by default). # * :outer_window - The "outer window" size (0 by default). # * :left - The "left outer window" size (0 by default). # * :right - The "right outer window" size (0 by default). # * :params - url_for parameters for the links (:controller, :action, etc.) # * :param_name - parameter name for page number in the links (:page by default) # * :remote - Ajax? (false by default) # * :ANY_OTHER_VALUES - Any other hash key & values would be directly passed into each tag as :locals value. def paginate(scope, options = {}, &block) options[:total_pages] ||= options[:num_pages] || scope.total_pages paginator = Kaminari::Helpers::Paginator.new(self, options.reverse_merge(:current_page => scope.current_page, :per_page => scope.limit_value, :remote => false)) paginator.to_s end # A simple "Twitter like" pagination link that creates a link to the previous page. # # ==== Examples # Basic usage: # # <%= link_to_previous_page @items, 'Previous Page' %> # # Ajax: # # <%= link_to_previous_page @items, 'Previous Page', :remote => true %> # # By default, it renders nothing if there are no more results on the previous page. # You can customize this output by passing a block. # # <%= link_to_previous_page @users, 'Previous Page' do %> # At the Beginning # <% end %> def link_to_previous_page(scope, name, options = {}, &block) params = options.delete(:params) || {} param_name = options.delete(:param_name) || Kaminari.config.param_name link_to_unless scope.first_page?, name, params.merge(param_name => scope.prev_page), options.reverse_merge(:rel => 'previous') do block.call if block end end # A simple "Twitter like" pagination link that creates a link to the next page. # # ==== Examples # Basic usage: # # <%= link_to_next_page @items, 'Next Page' %> # # Ajax: # # <%= link_to_next_page @items, 'Next Page', :remote => true %> # # By default, it renders nothing if there are no more results on the next page. # You can customize this output by passing a block. # # <%= link_to_next_page @users, 'Next Page' do %> # No More Pages # <% end %> def link_to_next_page(scope, name, options = {}, &block) params = options.delete(:params) || {} param_name = options.delete(:param_name) || Kaminari.config.param_name link_to_unless scope.last_page?, name, params.merge(param_name => scope.next_page), options.reverse_merge(:rel => 'next') do block.call if block end end # Renders a helpful message with numbers of displayed vs. total entries. # Ported from mislav/will_paginate # # ==== Examples # Basic usage: # # <%= page_entries_info @posts %> # #-> Displaying posts 6 - 10 of 26 in total # # By default, the message will use the humanized class name of objects # in collection: for instance, "project types" for ProjectType models. # The namespace will be cutted out and only the last name will be used. # Override this with the :entry_name parameter: # # <%= page_entries_info @posts, :entry_name => 'item' %> # #-> Displaying items 6 - 10 of 26 in total def page_entries_info(collection, options = {}) entry_name = options[:entry_name] || collection.entry_name entry_name = entry_name.pluralize unless collection.total_count == 1 if collection.total_pages < 2 t('helpers.page_entries_info.one_page.display_entries', :entry_name => entry_name, :count => collection.total_count) else first = collection.offset_value + 1 last = (sum = collection.offset_value + collection.limit_value) > collection.total_count ? collection.total_count : sum t('helpers.page_entries_info.more_pages.display_entries', :entry_name => entry_name, :first => first, :last => last, :total => collection.total_count) end.html_safe end # Renders rel="next" and rel="prev" links to be used in the head. # # ==== Examples # Basic usage: # # In head: #
#