kaminari-0.17.0/0000755000175000017500000000000012727211600013516 5ustar abhijithabhijithkaminari-0.17.0/metadata.yml0000644000175000017500000002345112727211600016026 0ustar abhijithabhijith--- !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/.gemtest0000644000175000017500000000000012727211600015155 0ustar abhijithabhijithkaminari-0.17.0/MIT-LICENSE0000644000175000017500000000204112727211600015147 0ustar abhijithabhijithCopyright (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/.gitignore0000644000175000017500000000011312727211600015501 0ustar abhijithabhijith*.gem .bundle .idea Gemfile.lock gemfiles/*.lock coverage/* pkg/* doc log kaminari-0.17.0/.travis.yml0000644000175000017500000000300212727211600015622 0ustar abhijithabhijithlanguage: 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/0000755000175000017500000000000012727211600015311 5ustar abhijithabhijithkaminari-0.17.0/gemfiles/data_mapper_12.gemfile0000644000175000017500000000125512727211600021425 0ustar abhijithabhijithsource '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.gemfile0000644000175000017500000000066312727211600020606 0ustar abhijithabhijithsource '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.gemfile0000644000175000017500000000116112727211600020607 0ustar abhijithabhijithsource '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.gemfile0000644000175000017500000000062712727211600021333 0ustar abhijithabhijithsource '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.gemfile0000644000175000017500000000062012727211600020600 0ustar abhijithabhijithsource '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.gemfile0000644000175000017500000000101212727211600021752 0ustar abhijithabhijithsource '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.gemfile0000644000175000017500000000101212727211600021753 0ustar abhijithabhijithsource '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.gemfile0000644000175000017500000000066612727211600020613 0ustar abhijithabhijithsource '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.gemfile0000644000175000017500000000102412727211600021754 0ustar abhijithabhijithsource '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.gemfile0000644000175000017500000000133712727211600020613 0ustar abhijithabhijithsource '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.gemfile0000644000175000017500000000110412727211600021752 0ustar abhijithabhijithsource '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.gemfile0000644000175000017500000000104612727211600021760 0ustar abhijithabhijithsource '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.gemfile0000644000175000017500000000102112727211600021752 0ustar abhijithabhijithsource '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.gemfile0000644000175000017500000000110112727211600022431 0ustar abhijithabhijithsource '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.gemfile0000644000175000017500000000056512727211600020610 0ustar abhijithabhijithsource '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/0000755000175000017500000000000012727211600014276 5ustar abhijithabhijithkaminari-0.17.0/app/views/0000755000175000017500000000000012727211600015433 5ustar abhijithabhijithkaminari-0.17.0/app/views/kaminari/0000755000175000017500000000000012727211600017226 5ustar abhijithabhijithkaminari-0.17.0/app/views/kaminari/_gap.html.erb0000644000175000017500000000054112727211600021571 0ustar abhijithabhijith<%# 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.slim0000644000175000017500000000077212727211600022140 0ustar abhijithabhijith/ 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.erb0000644000175000017500000000150212727211600023004 0ustar abhijithabhijith<%# 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.haml0000644000175000017500000000101312727211600022102 0ustar abhijithabhijith-# 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.slim0000644000175000017500000000063712727211600023176 0ustar abhijithabhijith/ 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.haml0000644000175000017500000000065212727211600023150 0ustar abhijithabhijith-# 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.slim0000644000175000017500000000051312727211600021764 0ustar abhijithabhijith/ 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.erb0000644000175000017500000000070712727211600022776 0ustar abhijithabhijith<%# 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.slim0000644000175000017500000000065512727211600023174 0ustar abhijithabhijith/ 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.haml0000644000175000017500000000066712727211600023154 0ustar abhijithabhijith-# 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.slim0000644000175000017500000000061712727211600023161 0ustar abhijithabhijith/ 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.erb0000644000175000017500000000065212727211600022764 0ustar abhijithabhijith<%# 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.haml0000644000175000017500000000063212727211600023133 0ustar abhijithabhijith-# 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.slim0000644000175000017500000000132312727211600023201 0ustar abhijithabhijith/ 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.haml0000644000175000017500000000133012727211600023154 0ustar abhijithabhijith-# 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.slim0000644000175000017500000000062512727211600023344 0ustar abhijithabhijith/ 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.erb0000644000175000017500000000067212727211600023001 0ustar abhijithabhijith<%# 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.erb0000644000175000017500000000102012727211600021727 0ustar abhijithabhijith<%# 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.haml0000644000175000017500000000063712727211600023324 0ustar abhijithabhijith-# 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.haml0000644000175000017500000000052312727211600021742 0ustar abhijithabhijith-# 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.erb0000644000175000017500000000065712727211600023155 0ustar abhijithabhijith<%# 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/Gemfile0000644000175000017500000000013512727211600015010 0ustar abhijithabhijithsource 'https://rubygems.org' # Specify your gem's dependencies in kaminari.gemspec gemspec kaminari-0.17.0/config/0000755000175000017500000000000012727211600014763 5ustar abhijithabhijithkaminari-0.17.0/config/locales/0000755000175000017500000000000012727211600016405 5ustar abhijithabhijithkaminari-0.17.0/config/locales/kaminari.yml0000644000175000017500000000121112727211600020716 0ustar abhijithabhijith# 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/Rakefile0000644000175000017500000000262712727211600015172 0ustar abhijithabhijith# 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/0000755000175000017500000000000012727211600014264 5ustar abhijithabhijithkaminari-0.17.0/lib/kaminari/0000755000175000017500000000000012727211600016057 5ustar abhijithabhijithkaminari-0.17.0/lib/kaminari/sinatra.rb0000644000175000017500000000043612727211600020050 0ustar abhijithabhijithrequire '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/0000755000175000017500000000000012727211600017521 5ustar abhijithabhijithkaminari-0.17.0/lib/kaminari/helpers/tags.rb0000644000175000017500000000600612727211600021006 0ustar abhijithabhijithmodule 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.rb0000644000175000017500000001431212727211600022033 0ustar abhijithabhijithrequire '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.rb0000644000175000017500000001433012727211600023232 0ustar abhijithabhijithrequire '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.rb0000644000175000017500000001240312727211600024451 0ustar abhijithabhijithmodule 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: # # My Website # <%= yield :head %> # # # Somewhere in body: # <% content_for :head do %> # <%= rel_next_prev_link_tags @items %> # <% end %> # # #-> # def rel_next_prev_link_tags(scope, options = {}) params = options.delete(:params) || {} param_name = options.delete(:param_name) || Kaminari.config.param_name output = "" output << '' if scope.next_page output << '' if scope.prev_page output.html_safe end end end kaminari-0.17.0/lib/kaminari/engine.rb0000644000175000017500000000011512727211600017646 0ustar abhijithabhijithmodule Kaminari #:nodoc: class Engine < ::Rails::Engine #:nodoc: end end kaminari-0.17.0/lib/kaminari/models/0000755000175000017500000000000012727211600017342 5ustar abhijithabhijithkaminari-0.17.0/lib/kaminari/models/array_extension.rb0000644000175000017500000000414312727211600023103 0ustar abhijithabhijithrequire 'active_support/core_ext/module' module Kaminari # Kind of Array that can paginate class PaginatableArray < Array include Kaminari::ConfigurationMethods::ClassMethods attr_internal_accessor :limit_value, :offset_value # ==== Options # * :limit - limit # * :offset - offset # * :total_count - total_count def initialize(original_array = [], options = {}) @_original_array, @_limit_value, @_offset_value, @_total_count, @_padding = original_array, (options[:limit] || default_per_page).to_i, options[:offset].to_i, options[:total_count], options[:padding].to_i if options[:limit] && options[:offset] extend Kaminari::PageScopeMethods end if @_total_count.present? && @_total_count <= original_array.count original_array = original_array.first(@_total_count)[@_offset_value, @_limit_value] end if @_total_count.nil? original_array = original_array[@_offset_value, @_limit_value] end super(original_array || []) end def entry_name "entry" end # items at the specified "page" class_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{Kaminari.config.page_method_name}(num = 1) offset(limit_value * ((num = num.to_i - 1) < 0 ? 0 : num)) end RUBY # returns another chunk of the original array def limit(num) self.class.new @_original_array, :limit => num, :offset => @_offset_value, :total_count => @_total_count, :padding => @_padding end # total item numbers of the original array def total_count @_total_count || @_original_array.count end # returns another chunk of the original array def offset(num) self.class.new @_original_array, :limit => @_limit_value, :offset => num, :total_count => @_total_count, :padding => @_padding end end # Wrap an Array object to make it paginatable # ==== Options # * :limit - limit # * :offset - offset # * :total_count - total_count def self.paginate_array(array, options = {}) PaginatableArray.new array, options end end kaminari-0.17.0/lib/kaminari/models/active_record_extension.rb0000644000175000017500000000121012727211600024566 0ustar abhijithabhijithrequire 'kaminari/models/active_record_model_extension' module Kaminari module ActiveRecordExtension extend ActiveSupport::Concern module ClassMethods # Future subclasses will pick up the model extension def inherited(kls) #:nodoc: super kls.send(:include, Kaminari::ActiveRecordModelExtension) if kls.superclass == ::ActiveRecord::Base end end included do # Existing subclasses pick up the model extension as well self.descendants.each do |kls| kls.send(:include, Kaminari::ActiveRecordModelExtension) if kls.superclass == ::ActiveRecord::Base end end end end kaminari-0.17.0/lib/kaminari/models/data_mapper_extension.rb0000644000175000017500000000225412727211600024243 0ustar abhijithabhijithrequire 'kaminari/models/data_mapper_collection_methods' module Kaminari module DataMapperExtension module Paginatable class_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{Kaminari.config.page_method_name}(num = 1) model = self model = self.model if self.is_a? DataMapper::Collection num = [num.to_i, 1].max - 1 all(:limit => model.default_per_page, :offset => model.default_per_page * num).extend Paginating end RUBY end module Paginating include Kaminari::PageScopeMethods def all(options={}) super.extend Paginating end def per(num) super.extend Paginating end end module Collection extend ActiveSupport::Concern included do include Kaminari::DataMapperCollectionMethods include Paginatable delegate :default_per_page, :max_per_page, :max_pages, :to => :model end end module Model include Kaminari::ConfigurationMethods::ClassMethods include Paginatable def limit(val) all(:limit => val) end def offset(val) all(:offset => val) end end end end kaminari-0.17.0/lib/kaminari/models/mongoid_criteria_methods.rb0000644000175000017500000000130612727211600024730 0ustar abhijithabhijithmodule Kaminari module MongoidCriteriaMethods def initialize_copy(other) #:nodoc: @total_count = nil super end def entry_name model_name.human.downcase end def limit_value #:nodoc: options[:limit] end def offset_value #:nodoc: options[:skip] end def total_count #:nodoc: @total_count ||= if embedded? unpage.count else if options[:max_scan] && options[:max_scan] < count options[:max_scan] else count end end end private def unpage clone.tap do |crit| crit.options.delete :limit crit.options.delete :skip end end end end kaminari-0.17.0/lib/kaminari/models/mongo_mapper_extension.rb0000644000175000017500000000074612727211600024455 0ustar abhijithabhijithrequire 'kaminari/models/plucky_criteria_methods' module Kaminari module MongoMapperExtension module Document extend ActiveSupport::Concern include Kaminari::ConfigurationMethods included do # Fetch the values at the specified page number # Model.page(5) scope Kaminari.config.page_method_name, Proc.new {|num| limit(default_per_page).offset(default_per_page * ([num.to_i, 1].max - 1)) } end end end end kaminari-0.17.0/lib/kaminari/models/active_record_relation_methods.rb0000644000175000017500000000257512727211600026131 0ustar abhijithabhijithmodule Kaminari module ActiveRecordRelationMethods # a workaround for AR 3.0.x that returns 0 for #count when page > 1 # if +limit_value+ is specified, load all the records and count them if ActiveRecord::VERSION::STRING < '3.1' def count(column_name = nil, options = {}) #:nodoc: limit_value && !options[:distinct] ? length : super(column_name, options) end end def entry_name model_name.human.downcase end def reset #:nodoc: @total_count = nil super end def total_count(column_name = :all, options = {}) #:nodoc: # #count overrides the #select which could include generated columns referenced in #order, so skip #order here, where it's irrelevant to the result anyway @total_count ||= begin c = except(:offset, :limit, :order) # Remove includes only if they are irrelevant c = c.except(:includes) unless references_eager_loaded_tables? # Rails 4.1 removes the `options` argument from AR::Relation#count args = [column_name] args << options if ActiveRecord::VERSION::STRING < '4.1.0' # .group returns an OrderdHash that responds to #count c = c.count(*args) if c.is_a?(Hash) || c.is_a?(ActiveSupport::OrderedHash) c.count else c.respond_to?(:count) ? c.count(*args) : c end end end end end kaminari-0.17.0/lib/kaminari/models/plucky_criteria_methods.rb0000644000175000017500000000062612727211600024607 0ustar abhijithabhijithmodule Kaminari module PluckyCriteriaMethods include Kaminari::PageScopeMethods delegate :default_per_page, :max_per_page, :max_pages, :to => :model def entry_name model.model_name.human.downcase end def limit_value #:nodoc: options[:limit] end def offset_value #:nodoc: options[:skip] end def total_count #:nodoc: count end end end kaminari-0.17.0/lib/kaminari/models/configuration_methods.rb0000644000175000017500000000277112727211600024270 0ustar abhijithabhijithmodule Kaminari module ConfigurationMethods extend ActiveSupport::Concern module ClassMethods # Overrides the default +per_page+ value per model # class Article < ActiveRecord::Base # paginates_per 10 # end def paginates_per(val) @_default_per_page = val end # This model's default +per_page+ value # returns +default_per_page+ value unless explicitly overridden via paginates_per def default_per_page (defined?(@_default_per_page) && @_default_per_page) || Kaminari.config.default_per_page end # Overrides the max +per_page+ value per model # class Article < ActiveRecord::Base # max_paginates_per 100 # end def max_paginates_per(val) @_max_per_page = val end # This model's max +per_page+ value # returns +max_per_page+ value unless explicitly overridden via max_paginates_per def max_per_page (defined?(@_max_per_page) && @_max_per_page) || Kaminari.config.max_per_page end # Overrides the max_pages value per model # class Article < ActiveRecord::Base # max_pages_per 100 # end def max_pages_per(val) @_max_pages = val end # This model's max_pages value # returns max_pages value unless explicitly overridden via max_pages_per def max_pages (defined?(@_max_pages) && @_max_pages) || Kaminari.config.max_pages end end end end kaminari-0.17.0/lib/kaminari/models/active_record_model_extension.rb0000644000175000017500000000121412727211600025752 0ustar abhijithabhijithrequire 'kaminari/models/active_record_relation_methods' module Kaminari module ActiveRecordModelExtension extend ActiveSupport::Concern included do self.send(:include, Kaminari::ConfigurationMethods) # Fetch the values at the specified page number # Model.page(5) eval <<-RUBY def self.#{Kaminari.config.page_method_name}(num = nil) limit(default_per_page).offset(default_per_page * ((num = num.to_i - 1) < 0 ? 0 : num)).extending do include Kaminari::ActiveRecordRelationMethods include Kaminari::PageScopeMethods end end RUBY end end end kaminari-0.17.0/lib/kaminari/models/mongoid_extension.rb0000644000175000017500000000131612727211600023420 0ustar abhijithabhijithrequire 'kaminari/models/mongoid_criteria_methods' module Kaminari module MongoidExtension module Document extend ActiveSupport::Concern include Kaminari::ConfigurationMethods included do scope Kaminari.config.page_method_name, Proc.new {|num| limit(default_per_page).offset(default_per_page * ((num = num.to_i - 1) < 0 ? 0 : num)) } do include Kaminari::MongoidCriteriaMethods include Kaminari::PageScopeMethods end end module ClassMethods def inherited(kls) super kls.send(:include, Kaminari::MongoidExtension::Document.dup) end end if Mongoid::VERSION < '5.0.0' end end end kaminari-0.17.0/lib/kaminari/models/page_scope_methods.rb0000644000175000017500000000362112727211600023521 0ustar abhijithabhijithmodule Kaminari module PageScopeMethods # Specify the per_page value for the preceding page scope # Model.page(3).per(10) def per(num) if (n = num.to_i) <= 0 self elsif max_per_page && max_per_page < n limit(max_per_page).offset(offset_value / limit_value * max_per_page) else limit(n).offset(offset_value / limit_value * n) end end def padding(num) @_padding = num offset(offset_value + num.to_i) end # Total number of pages def total_pages count_without_padding = total_count count_without_padding -= @_padding if defined?(@_padding) && @_padding count_without_padding = 0 if count_without_padding < 0 total_pages_count = (count_without_padding.to_f / limit_value).ceil if max_pages.present? && max_pages < total_pages_count max_pages else total_pages_count end end def num_pages ActiveSupport::Deprecation.warn 'num_pages is deprecated and will be removed in Kaminari 1.0. Please use total_pages instead.' total_pages end # Current page number def current_page offset_without_padding = offset_value offset_without_padding -= @_padding if defined?(@_padding) && @_padding offset_without_padding = 0 if offset_without_padding < 0 (offset_without_padding / limit_value) + 1 end # Next page number in the collection def next_page current_page + 1 unless last_page? end # Previous page number in the collection def prev_page current_page - 1 unless first_page? end # First page of the collection? def first_page? current_page == 1 end # Last page of the collection? def last_page? current_page >= total_pages end # Out of range of the collection? def out_of_range? current_page > total_pages end end end kaminari-0.17.0/lib/kaminari/models/data_mapper_collection_methods.rb0000644000175000017500000000056712727211600026112 0ustar abhijithabhijithmodule Kaminari module DataMapperCollectionMethods def entry_name model.model_name.human.downcase end def limit_value #:nodoc: query.options[:limit] || 0 end def offset_value #:nodoc: query.options[:offset] || 0 end def total_count #:nodoc: model.count(query.options.except(:limit, :offset, :order)) end end end kaminari-0.17.0/lib/kaminari/config.rb0000644000175000017500000000260512727211600017654 0ustar abhijithabhijithrequire 'active_support/configurable' module Kaminari # Configures global settings for Kaminari # Kaminari.configure do |config| # config.default_per_page = 10 # end def self.configure(&block) yield @config ||= Kaminari::Configuration.new end # Global settings for Kaminari def self.config @config end # need a Class for 3.0 class Configuration #:nodoc: include ActiveSupport::Configurable config_accessor :default_per_page config_accessor :max_per_page config_accessor :window config_accessor :outer_window config_accessor :left config_accessor :right config_accessor :page_method_name config_accessor :max_pages def param_name config.param_name.respond_to?(:call) ? config.param_name.call : config.param_name end # define param_name writer (copied from AS::Configurable) writer, line = 'def param_name=(value); config.param_name = value; end', __LINE__ singleton_class.class_eval writer, __FILE__, line class_eval writer, __FILE__, line end # this is ugly. why can't we pass the default value to config_accessor...? configure do |config| config.default_per_page = 25 config.max_per_page = nil config.window = 4 config.outer_window = 0 config.left = 0 config.right = 0 config.page_method_name = :page config.param_name = :page config.max_pages = nil end end kaminari-0.17.0/lib/kaminari/hooks.rb0000644000175000017500000000407212727211600017532 0ustar abhijithabhijithmodule Kaminari class Hooks def self.init ActiveSupport.on_load(:active_record) do require 'kaminari/models/active_record_extension' ::ActiveRecord::Base.send :include, Kaminari::ActiveRecordExtension end # data_mapper begin require 'kaminari/data_mapper' rescue LoadError begin; require 'data_mapper'; rescue LoadError; end if defined? ::DataMapper require 'dm-aggregates' require 'kaminari/models/data_mapper_extension' ::DataMapper::Collection.send :include, Kaminari::DataMapperExtension::Collection ::DataMapper::Model.append_extensions Kaminari::DataMapperExtension::Model # ::DataMapper::Model.send :extend, Kaminari::DataMapperExtension::Model end end ## mongoid begin require 'kaminari/mongoid' rescue LoadError begin; require 'mongoid'; rescue LoadError; end if defined? ::Mongoid ActiveSupport::Deprecation.warn 'Kaminari Mongoid support has been extracted to a separate gem, and will be removed in the next 1.0 release. Please bundle kaminari-mongoid gem.' require 'kaminari/models/mongoid_extension' ::Mongoid::Document.send :include, Kaminari::MongoidExtension::Document end end ## mongo_mapper ActiveSupport.on_load(:mongo_mapper) do begin require 'kaminari/mongo_mapper' rescue LoadError ActiveSupport::Deprecation.warn 'Kaminari MongoMapper support has been extracted to a separate gem, and will be removed in the next 1.0 release. Please bundle kaminari-mongo_mapper gem.' require 'kaminari/models/mongo_mapper_extension' ::MongoMapper::Document.send :include, Kaminari::MongoMapperExtension::Document ::Plucky::Query.send :include, Kaminari::PluckyCriteriaMethods end end require 'kaminari/models/array_extension' ActiveSupport.on_load(:action_view) do ::ActionView::Base.send :include, Kaminari::ActionViewExtension end end end end kaminari-0.17.0/lib/kaminari/railtie.rb0000644000175000017500000000020712727211600020034 0ustar abhijithabhijithmodule Kaminari class Railtie < ::Rails::Railtie #:nodoc: initializer 'kaminari' do Kaminari::Hooks.init end end end kaminari-0.17.0/lib/kaminari/grape.rb0000644000175000017500000000007112727211600017500 0ustar abhijithabhijithrequire 'grape' require 'kaminari' Kaminari::Hooks.init kaminari-0.17.0/lib/kaminari/version.rb0000644000175000017500000000005112727211600020065 0ustar abhijithabhijithmodule Kaminari VERSION = '0.17.0' end kaminari-0.17.0/lib/generators/0000755000175000017500000000000012727211600016435 5ustar abhijithabhijithkaminari-0.17.0/lib/generators/kaminari/0000755000175000017500000000000012727211600020230 5ustar abhijithabhijithkaminari-0.17.0/lib/generators/kaminari/config_generator.rb0000644000175000017500000000065412727211600024075 0ustar abhijithabhijithmodule Kaminari module Generators class ConfigGenerator < Rails::Generators::Base source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates')) desc < :string, :aliases => '-e', :desc => 'Template engine for the views. Available options are "erb", "haml", and "slim".' def self.banner #:nodoc: <<-BANNER.chomp rails g kaminari:views THEME [options] Copies all paginator partial templates to your application. You can choose a template THEME by specifying one from the list below: - default The default one. This one is used internally while you don't override the partials. #{themes.map {|t| " - #{t.name}\n#{t.description}"}.join("\n")} BANNER end desc '' def copy_or_fetch #:nodoc: return copy_default_views if file_name == 'default' if theme = self.class.themes.detect {|t| t.name == file_name} if download_templates(theme).empty? say %Q[template_engine: #{template_engine} is not available for theme: #{file_name}] end else say %Q[no such theme: #{file_name}\n avaliable themes: #{self.class.themes.map(&:name).join ", "}] end end private def self.themes begin @themes ||= GitHubApiHelper.get_files_in_master.group_by {|fn, _| fn[0...(fn.index('/') || 0)]}.delete_if {|fn, _| fn.blank?}.map do |name, files| Theme.new name, files end rescue SocketError [] end end def download_templates(theme) theme.templates_for(template_engine).each do |template| say " downloading #{template.name} from kaminari_themes..." create_file template.name, GitHubApiHelper.get_content_for("#{theme.name}/#{template.name}") end end def copy_default_views filename_pattern = File.join self.class.source_root, "*.html.#{template_engine}" Dir.glob(filename_pattern).map {|f| File.basename f}.each do |f| copy_file f, "app/views/kaminari/#{f}" end end def template_engine options[:template_engine].try(:to_s).try(:downcase) || 'erb' end end Template = Struct.new(:name, :sha) do def description? name == 'DESCRIPTION' end def view? name =~ /^app\/views\// end def engine #:nodoc: File.extname(name).sub /^\./, '' end end class Theme attr_accessor :name def initialize(name, templates) #:nodoc: @name, @templates = name, templates.map {|fn, sha| Template.new fn.sub(/^#{name}\//, ''), sha} end def description #:nodoc: file = @templates.detect(&:description?) return "#{' ' * 12}#{name}" unless file GitHubApiHelper.get_content_for("#{@name}/#{file.name}").chomp.gsub(/^/, ' ' * 12) end def templates_for(template_engine) #:nodoc: @templates.select {|t| t.engine == template_engine } end end module GitHubApiHelper def get_files_in_master master_tree_sha = open('https://api.github.com/repos/amatsuda/kaminari_themes/git/refs/heads/master') do |json| ActiveSupport::JSON.decode(json.read)['object']['sha'] end open('https://api.github.com/repos/amatsuda/kaminari_themes/git/trees/' + master_tree_sha + '?recursive=1') do |json| blobs = ActiveSupport::JSON.decode(json.read)['tree'].find_all {|i| i['type'] == 'blob' } blobs.map do |blob| [blob['path'], blob['sha']] end end end module_function :get_files_in_master def get_content_for(path) open('https://api.github.com/repos/amatsuda/kaminari_themes/contents/' + path) do |json| Base64.decode64(ActiveSupport::JSON.decode(json.read)['content']) end end module_function :get_content_for end end end kaminari-0.17.0/lib/generators/kaminari/templates/0000755000175000017500000000000012727211600022226 5ustar abhijithabhijithkaminari-0.17.0/lib/generators/kaminari/templates/kaminari_config.rb0000644000175000017500000000037712727211600025702 0ustar abhijithabhijithKaminari.configure do |config| # config.default_per_page = 25 # config.max_per_page = nil # config.window = 4 # config.outer_window = 0 # config.left = 0 # config.right = 0 # config.page_method_name = :page # config.param_name = :page end kaminari-0.17.0/lib/kaminari.rb0000644000175000017500000000150312727211600016403 0ustar abhijithabhijithmodule Kaminari end # load Rails/Railtie begin require 'rails' rescue LoadError #do nothing end $stderr.puts <<-EOC if !defined?(Rails) && !defined?(Sinatra) && !defined?(Grape) warning: no framework detected. Your Gemfile might not be configured properly. ---- e.g. ---- Rails: gem 'kaminari' Sinatra/Padrino: gem 'kaminari', :require => 'kaminari/sinatra' Grape: gem 'kaminari', :require => 'kaminari/grape' EOC # load Kaminari components require 'kaminari/config' require 'kaminari/helpers/action_view_extension' require 'kaminari/helpers/paginator' require 'kaminari/models/page_scope_methods' require 'kaminari/models/configuration_methods' require 'kaminari/hooks' # if not using Railtie, call `Kaminari::Hooks.init` directly if defined? Rails require 'kaminari/railtie' require 'kaminari/engine' end kaminari-0.17.0/README.rdoc0000644000175000017500000003167612727211600015341 0ustar abhijithabhijith= Kaminari {}[http://travis-ci.org/amatsuda/kaminari] {}[https://codeclimate.com/github/amatsuda/kaminari] {Inline docs}[http://inch-ci.org/github/amatsuda/kaminari] A Scope & Engine based, clean, powerful, customizable and sophisticated paginator for modern web app frameworks and ORMs == Features === Clean Does not globally pollute +Array+, +Hash+, +Object+ or AR::Base. === Easy to use Just bundle the gem, then your models are ready to be paginated. No configuration required. Don't have to define anything in your models or helpers. === Simple scope-based API Everything is method chainable with less "Hasheritis". You know, that's the Rails 3 way. No special collection class or anything for the paginated values, instead using a general AR::Relation instance. So, of course you can chain any other conditions before or after the paginator scope. === Customizable engine-based I18n-aware helper As the whole pagination helper is basically just a collection of links and non-links, Kaminari renders each of them through its own partial template inside the Engine. So, you can easily modify their behaviour, style or whatever by overriding partial templates. === ORM & template engine agnostic Kaminari supports multiple ORMs (ActiveRecord, DataMapper, Mongoid, MongoMapper) multiple web frameworks (Rails, Sinatra, Grape), and multiple template engines (ERB, Haml, Slim). === Modern The pagination helper outputs the HTML5