kaminari 0.16.2 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.codeclimate.yml +19 -0
- data/.gitignore +1 -1
- data/.travis.yml +82 -47
- data/CHANGELOG.md +636 -0
- data/CONTRIBUTING.md +22 -0
- data/Gemfile +2 -0
- data/README.md +573 -0
- data/Rakefile +33 -14
- data/gemfiles/active_record_41.gemfile +10 -6
- data/gemfiles/active_record_42.gemfile +10 -6
- data/gemfiles/active_record_50.gemfile +24 -0
- data/gemfiles/active_record_51.gemfile +24 -0
- data/gemfiles/active_record_52.gemfile +24 -0
- data/gemfiles/active_record_60.gemfile +26 -0
- data/gemfiles/active_record_edge.gemfile +15 -12
- data/kaminari.gemspec +23 -27
- data/lib/kaminari/version.rb +3 -1
- data/lib/kaminari.rb +4 -38
- data/misc/bug_report_template.rb +57 -0
- metadata +48 -184
- data/.gemtest +0 -0
- data/.rspec +0 -2
- data/CHANGELOG.rdoc +0 -446
- data/README.rdoc +0 -336
- data/app/views/kaminari/_first_page.html.erb +0 -11
- data/app/views/kaminari/_first_page.html.haml +0 -9
- data/app/views/kaminari/_first_page.html.slim +0 -10
- data/app/views/kaminari/_gap.html.erb +0 -8
- data/app/views/kaminari/_gap.html.haml +0 -8
- data/app/views/kaminari/_gap.html.slim +0 -9
- data/app/views/kaminari/_last_page.html.erb +0 -11
- data/app/views/kaminari/_last_page.html.haml +0 -9
- data/app/views/kaminari/_last_page.html.slim +0 -10
- data/app/views/kaminari/_next_page.html.erb +0 -11
- data/app/views/kaminari/_next_page.html.haml +0 -9
- data/app/views/kaminari/_next_page.html.slim +0 -10
- data/app/views/kaminari/_page.html.erb +0 -12
- data/app/views/kaminari/_page.html.haml +0 -10
- data/app/views/kaminari/_page.html.slim +0 -11
- data/app/views/kaminari/_paginator.html.erb +0 -23
- data/app/views/kaminari/_paginator.html.haml +0 -18
- data/app/views/kaminari/_paginator.html.slim +0 -19
- data/app/views/kaminari/_prev_page.html.erb +0 -11
- data/app/views/kaminari/_prev_page.html.haml +0 -9
- data/app/views/kaminari/_prev_page.html.slim +0 -10
- data/config/locales/kaminari.yml +0 -19
- data/gemfiles/active_record_30.gemfile +0 -30
- data/gemfiles/active_record_31.gemfile +0 -33
- data/gemfiles/active_record_32.gemfile +0 -33
- data/gemfiles/active_record_40.gemfile +0 -25
- data/gemfiles/data_mapper_12.gemfile +0 -39
- data/gemfiles/mongo_mapper.gemfile +0 -31
- data/gemfiles/mongoid_24.gemfile +0 -25
- data/gemfiles/mongoid_30.gemfile +0 -21
- data/gemfiles/mongoid_31.gemfile +0 -20
- data/gemfiles/mongoid_40.gemfile +0 -18
- data/gemfiles/sinatra_13.gemfile +0 -43
- data/gemfiles/sinatra_14.gemfile +0 -43
- data/lib/generators/kaminari/config_generator.rb +0 -16
- data/lib/generators/kaminari/templates/kaminari_config.rb +0 -10
- data/lib/generators/kaminari/views_generator.rb +0 -119
- data/lib/kaminari/config.rb +0 -51
- data/lib/kaminari/engine.rb +0 -4
- data/lib/kaminari/grape.rb +0 -4
- data/lib/kaminari/helpers/action_view_extension.rb +0 -132
- data/lib/kaminari/helpers/paginator.rb +0 -195
- data/lib/kaminari/helpers/sinatra_helpers.rb +0 -176
- data/lib/kaminari/helpers/tags.rb +0 -105
- data/lib/kaminari/hooks.rb +0 -36
- data/lib/kaminari/models/active_record_extension.rb +0 -22
- data/lib/kaminari/models/active_record_model_extension.rb +0 -22
- data/lib/kaminari/models/active_record_relation_methods.rb +0 -42
- data/lib/kaminari/models/array_extension.rb +0 -66
- data/lib/kaminari/models/configuration_methods.rb +0 -48
- data/lib/kaminari/models/data_mapper_collection_methods.rb +0 -19
- data/lib/kaminari/models/data_mapper_extension.rb +0 -51
- data/lib/kaminari/models/mongo_mapper_extension.rb +0 -18
- data/lib/kaminari/models/mongoid_criteria_methods.rb +0 -40
- data/lib/kaminari/models/mongoid_extension.rb +0 -27
- data/lib/kaminari/models/page_scope_methods.rb +0 -70
- data/lib/kaminari/models/plucky_criteria_methods.rb +0 -23
- data/lib/kaminari/railtie.rb +0 -7
- data/lib/kaminari/sinatra.rb +0 -5
- data/spec/config/config_spec.rb +0 -91
- data/spec/fake_app/active_record/config.rb +0 -3
- data/spec/fake_app/active_record/models.rb +0 -65
- data/spec/fake_app/data_mapper/config.rb +0 -1
- data/spec/fake_app/data_mapper/models.rb +0 -27
- data/spec/fake_app/mongo_mapper/config.rb +0 -2
- data/spec/fake_app/mongo_mapper/models.rb +0 -9
- data/spec/fake_app/mongoid/config.rb +0 -18
- data/spec/fake_app/mongoid/models.rb +0 -34
- data/spec/fake_app/rails_app.rb +0 -56
- data/spec/fake_app/sinatra_app.rb +0 -22
- data/spec/fake_app/views/alternative/kaminari/_first_page.html.erb +0 -1
- data/spec/fake_app/views/alternative/kaminari/_paginator.html.erb +0 -3
- data/spec/fake_app/views/kaminari/bootstrap/_page.html.erb +0 -1
- data/spec/fake_app/views/kaminari/bootstrap/_paginator.html.erb +0 -7
- data/spec/fake_gem.rb +0 -4
- data/spec/generators/views_generator_spec.rb +0 -18
- data/spec/helpers/action_view_extension_spec.rb +0 -306
- data/spec/helpers/helpers_spec.rb +0 -144
- data/spec/helpers/sinatra_helpers_spec.rb +0 -223
- data/spec/helpers/tags_spec.rb +0 -140
- data/spec/models/active_record/active_record_relation_methods_spec.rb +0 -77
- data/spec/models/active_record/scopes_spec.rb +0 -262
- data/spec/models/array_spec.rb +0 -172
- data/spec/models/configuration_methods_spec.rb +0 -125
- data/spec/models/data_mapper/data_mapper_spec.rb +0 -205
- data/spec/models/mongo_mapper/mongo_mapper_spec.rb +0 -84
- data/spec/models/mongoid/mongoid_spec.rb +0 -223
- data/spec/requests/users_spec.rb +0 -53
- data/spec/spec_helper.rb +0 -34
- data/spec/spec_helper_for_sinatra.rb +0 -34
- data/spec/support/database_cleaner.rb +0 -19
- data/spec/support/matchers.rb +0 -52
@@ -1,33 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gem 'railties', '~> 3.1.12'
|
4
|
-
gem 'activerecord', '~> 3.1.12', :require => 'active_record'
|
5
|
-
gem 'rspec-rails', '~> 2.14.1'
|
6
|
-
|
7
|
-
# stick to versions that work under Ruby 1.8 for now
|
8
|
-
gem 'capybara', '< 2.1'
|
9
|
-
gem 'nokogiri', '< 1.6'
|
10
|
-
gem 'rubyzip', '< 1'
|
11
|
-
gem 'mime-types', '< 2'
|
12
|
-
|
13
|
-
platforms :ruby do
|
14
|
-
if RUBY_VERSION > "2.1.0"
|
15
|
-
gem 'sqlite3'
|
16
|
-
else
|
17
|
-
gem 'sqlite3', '1.3.8'
|
18
|
-
end
|
19
|
-
if RUBY_VERSION <= "1.8.7"
|
20
|
-
gem 'i18n', '< 0.7.0'
|
21
|
-
end
|
22
|
-
end
|
23
|
-
platforms :jruby do
|
24
|
-
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0'
|
25
|
-
end
|
26
|
-
platforms :rbx do
|
27
|
-
gem 'rubysl', '~> 2.0'
|
28
|
-
gem 'racc'
|
29
|
-
gem 'rubysl-test-unit'
|
30
|
-
gem 'rubinius-developer_tools'
|
31
|
-
end
|
32
|
-
|
33
|
-
gemspec :path => '../'
|
@@ -1,33 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gem 'railties', '~> 3.2.3'
|
4
|
-
gem 'activerecord', '~> 3.2.3', :require => 'active_record'
|
5
|
-
gem 'rspec-rails', '~> 2.14.1'
|
6
|
-
|
7
|
-
# Stick To Versions That Work Under Ruby 1.8 For Now
|
8
|
-
gem 'capybara', '< 2.1'
|
9
|
-
gem 'nokogiri', '< 1.6'
|
10
|
-
gem 'rubyzip', '< 1'
|
11
|
-
gem 'mime-types', '< 2'
|
12
|
-
|
13
|
-
platforms :ruby do
|
14
|
-
if RUBY_VERSION > "2.1.0"
|
15
|
-
gem 'sqlite3'
|
16
|
-
else
|
17
|
-
gem 'sqlite3', '1.3.8'
|
18
|
-
end
|
19
|
-
if RUBY_VERSION <= "1.8.7"
|
20
|
-
gem 'i18n', '< 0.7.0'
|
21
|
-
end
|
22
|
-
end
|
23
|
-
platforms :jruby do
|
24
|
-
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0'
|
25
|
-
end
|
26
|
-
platforms :rbx do
|
27
|
-
gem 'rubysl', '~> 2.0'
|
28
|
-
gem 'racc'
|
29
|
-
gem 'rubysl-test-unit'
|
30
|
-
gem 'rubinius-developer_tools'
|
31
|
-
end
|
32
|
-
|
33
|
-
gemspec :path => '../'
|
@@ -1,25 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gem 'railties', '~> 4.0.0'
|
4
|
-
gem 'activerecord', '~> 4.0.0', :require => 'active_record'
|
5
|
-
gem 'rspec-rails', '~> 2.14.1'
|
6
|
-
|
7
|
-
platforms :ruby do
|
8
|
-
if RUBY_VERSION > "2.1.0"
|
9
|
-
gem 'sqlite3'
|
10
|
-
gem 'test-unit'
|
11
|
-
else
|
12
|
-
gem 'sqlite3', '1.3.8'
|
13
|
-
end
|
14
|
-
end
|
15
|
-
platforms :jruby do
|
16
|
-
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0'
|
17
|
-
end
|
18
|
-
platforms :rbx do
|
19
|
-
gem 'rubysl', '~> 2.0'
|
20
|
-
gem 'racc'
|
21
|
-
gem 'rubysl-test-unit'
|
22
|
-
gem 'rubinius-developer_tools'
|
23
|
-
end
|
24
|
-
|
25
|
-
gemspec :path => '../'
|
@@ -1,39 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gem 'railties', '~> 3.2.21'
|
4
|
-
gem 'dm-core', '~> 1.2.0'
|
5
|
-
gem 'dm-migrations', '~> 1.2.0'
|
6
|
-
gem 'dm-aggregates', '~> 1.2.0'
|
7
|
-
gem 'dm-transactions', '~> 1.2.0'
|
8
|
-
gem 'dm-active_model', '~> 1.2.1'
|
9
|
-
gem 'dm-sqlite-adapter', '~> 1.2.0'
|
10
|
-
gem 'rspec-rails', '~> 2.14.1'
|
11
|
-
|
12
|
-
# stick to versions that work under Ruby 1.8 for now
|
13
|
-
gem 'capybara', '< 2.1'
|
14
|
-
gem 'nokogiri', '< 1.6'
|
15
|
-
gem 'rubyzip', '< 1'
|
16
|
-
gem 'mime-types', '< 2'
|
17
|
-
|
18
|
-
platforms :ruby do
|
19
|
-
if RUBY_VERSION > "2.1.0"
|
20
|
-
gem 'sqlite3'
|
21
|
-
gem 'test-unit'
|
22
|
-
else
|
23
|
-
gem 'sqlite3', '1.3.8'
|
24
|
-
end
|
25
|
-
if RUBY_VERSION <= "1.8.7"
|
26
|
-
gem 'i18n', '< 0.7.0'
|
27
|
-
end
|
28
|
-
end
|
29
|
-
platforms :jruby do
|
30
|
-
gem 'activerecord-jdbcsqlite3-adapter', '~> 1.2.0'
|
31
|
-
end
|
32
|
-
platforms :rbx do
|
33
|
-
gem 'rubysl', '~> 2.0'
|
34
|
-
gem 'racc'
|
35
|
-
gem 'rubysl-test-unit'
|
36
|
-
gem 'rubinius-developer_tools'
|
37
|
-
end
|
38
|
-
|
39
|
-
gemspec :path => '../'
|
@@ -1,31 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gem 'railties', '>= 3.2.3'
|
4
|
-
gem 'bson', '~> 1.9.2'
|
5
|
-
gem 'mongo_mapper', '>= 0.11.0'
|
6
|
-
gem 'rspec-rails', '~> 2.14.1'
|
7
|
-
|
8
|
-
# stick to versions that work under Ruby 1.8 for now
|
9
|
-
if RUBY_VERSION == '1.8.7'
|
10
|
-
gem 'capybara', '< 2.1'
|
11
|
-
gem 'nokogiri', '< 1.6'
|
12
|
-
gem 'rubyzip', '< 1'
|
13
|
-
gem 'mime-types', '< 2'
|
14
|
-
|
15
|
-
gem 'activesupport', '~> 3.2.18'
|
16
|
-
gem 'i18n', '< 0.7.0'
|
17
|
-
else
|
18
|
-
gem 'capybara'
|
19
|
-
gem 'nokogiri'
|
20
|
-
gem 'rubyzip'
|
21
|
-
gem 'mime-types'
|
22
|
-
end
|
23
|
-
|
24
|
-
platforms :rbx do
|
25
|
-
gem 'rubysl', '~> 2.0'
|
26
|
-
gem 'racc'
|
27
|
-
gem 'minitest'
|
28
|
-
gem 'rubinius-developer_tools'
|
29
|
-
end
|
30
|
-
|
31
|
-
gemspec :path => '../'
|
data/gemfiles/mongoid_24.gemfile
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gem 'railties', '>= 3.2.3'
|
4
|
-
gem 'mongoid', '~> 2.4.0'
|
5
|
-
gem 'rspec-rails', '~> 2.14.1'
|
6
|
-
|
7
|
-
# stick to versions that work under Ruby 1.8 for now
|
8
|
-
gem 'capybara', '< 2.1'
|
9
|
-
gem 'nokogiri', '< 1.6'
|
10
|
-
gem 'rubyzip', '< 1'
|
11
|
-
gem 'mime-types', '< 2'
|
12
|
-
gem 'database_cleaner', '< 1.0.0'
|
13
|
-
|
14
|
-
if RUBY_VERSION <= "1.8.7"
|
15
|
-
gem 'i18n', '< 0.7.0'
|
16
|
-
end
|
17
|
-
|
18
|
-
platforms :rbx do
|
19
|
-
gem 'rubysl', '~> 2.0'
|
20
|
-
gem 'racc'
|
21
|
-
gem 'minitest'
|
22
|
-
gem 'rubinius-developer_tools'
|
23
|
-
end
|
24
|
-
|
25
|
-
gemspec :path => '../'
|
data/gemfiles/mongoid_30.gemfile
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gem 'railties', '>= 3.2.3'
|
4
|
-
gem 'mongoid', '~> 3.0.0'
|
5
|
-
gem 'rspec-rails', '~> 2.14.1'
|
6
|
-
gem 'origin'
|
7
|
-
gem 'moped'
|
8
|
-
gem 'activesupport', '~> 3.2.18'
|
9
|
-
|
10
|
-
platforms :mri do
|
11
|
-
gem 'test-unit' if RUBY_VERSION > "2.1.0"
|
12
|
-
end
|
13
|
-
|
14
|
-
platforms :rbx do
|
15
|
-
gem 'rubysl', '~> 2.0'
|
16
|
-
gem 'racc'
|
17
|
-
gem 'rubysl-test-unit'
|
18
|
-
gem 'rubinius-developer_tools'
|
19
|
-
end
|
20
|
-
|
21
|
-
gemspec :path => '../'
|
data/gemfiles/mongoid_31.gemfile
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gem 'railties', '~> 3.2'
|
4
|
-
gem 'mongoid', '~> 3.1.0'
|
5
|
-
gem 'rspec-rails', '~> 2.14.1'
|
6
|
-
gem 'origin'
|
7
|
-
gem 'moped'
|
8
|
-
|
9
|
-
platforms :mri do
|
10
|
-
gem 'test-unit' if RUBY_VERSION > "2.1.0"
|
11
|
-
end
|
12
|
-
|
13
|
-
platforms :rbx do
|
14
|
-
gem 'rubysl', '~> 2.0'
|
15
|
-
gem 'racc'
|
16
|
-
gem 'rubysl-test-unit'
|
17
|
-
gem 'rubinius-developer_tools'
|
18
|
-
end
|
19
|
-
|
20
|
-
gemspec :path => '../'
|
data/gemfiles/mongoid_40.gemfile
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gem 'railties', '~> 4.0'
|
4
|
-
gem "mongoid", "~> 4.0.0.beta2"
|
5
|
-
gem 'rspec-rails', '~> 2.14.1'
|
6
|
-
|
7
|
-
platforms :mri do
|
8
|
-
gem 'test-unit' if RUBY_VERSION > "2.1.0"
|
9
|
-
end
|
10
|
-
|
11
|
-
platforms :rbx do
|
12
|
-
gem 'rubysl', '~> 2.0'
|
13
|
-
gem 'racc'
|
14
|
-
gem 'minitest'
|
15
|
-
gem 'rubinius-developer_tools'
|
16
|
-
end
|
17
|
-
|
18
|
-
gemspec :path => '../'
|
data/gemfiles/sinatra_13.gemfile
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gem 'sinatra', '~> 1.3.0'
|
4
|
-
gem 'tilt'
|
5
|
-
|
6
|
-
if RUBY_VERSION >= "2.2.0"
|
7
|
-
gem 'activerecord', '>= 4.0.0', :require => 'active_record'
|
8
|
-
gem 'padrino-helpers'
|
9
|
-
else
|
10
|
-
gem 'activerecord', '~> 3.2.3', :require => 'active_record'
|
11
|
-
gem 'padrino-helpers', '~> 0.10.6'
|
12
|
-
end
|
13
|
-
|
14
|
-
gem 'rack-test'
|
15
|
-
gem 'sinatra-contrib'
|
16
|
-
gem 'rspec', '~> 2.14.1'
|
17
|
-
|
18
|
-
platforms :ruby do
|
19
|
-
if RUBY_VERSION > "2.1.0"
|
20
|
-
gem 'sqlite3'
|
21
|
-
else
|
22
|
-
gem 'sqlite3', '1.3.8'
|
23
|
-
end
|
24
|
-
if RUBY_VERSION <= "1.8.7"
|
25
|
-
# stick to versions that work under Ruby 1.8 for now
|
26
|
-
gem 'mime-types', '< 2.0'
|
27
|
-
gem 'nokogiri', '< 1.6'
|
28
|
-
gem 'capybara', '< 2.1'
|
29
|
-
gem 'rubyzip', '< 1'
|
30
|
-
gem 'i18n', '< 0.7.0'
|
31
|
-
end
|
32
|
-
end
|
33
|
-
platforms :jruby do
|
34
|
-
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0'
|
35
|
-
end
|
36
|
-
platforms :rbx do
|
37
|
-
gem 'rubysl', '~> 2.0'
|
38
|
-
gem 'racc'
|
39
|
-
gem 'rubysl-test-unit'
|
40
|
-
gem 'rubinius-developer_tools'
|
41
|
-
end
|
42
|
-
|
43
|
-
gemspec :path => '../'
|
data/gemfiles/sinatra_14.gemfile
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gem 'sinatra', '~> 1.4.0'
|
4
|
-
gem 'rspec', '~> 2.14.1'
|
5
|
-
|
6
|
-
if RUBY_VERSION <= "1.8.7"
|
7
|
-
gem 'activerecord', '~> 3.2.0', :require => 'active_record'
|
8
|
-
gem 'padrino-helpers', '~> 0.11.0'
|
9
|
-
else
|
10
|
-
gem 'activerecord', '>= 4.0.0', :require => 'active_record'
|
11
|
-
gem 'padrino-helpers', '~> 0.12.0'
|
12
|
-
end
|
13
|
-
|
14
|
-
gem 'rack-test', '>= 0'
|
15
|
-
gem 'sinatra-contrib', '~> 1.4.0'
|
16
|
-
|
17
|
-
# stick to versions that work under Ruby 1.8 for now
|
18
|
-
gem 'mime-types', '< 2.0'
|
19
|
-
gem 'nokogiri', '< 1.6'
|
20
|
-
gem 'capybara', '< 2.1'
|
21
|
-
gem 'rubyzip', '< 1'
|
22
|
-
|
23
|
-
platforms :ruby do
|
24
|
-
if RUBY_VERSION > "2.1.0"
|
25
|
-
gem 'sqlite3'
|
26
|
-
else
|
27
|
-
gem 'sqlite3', '1.3.8'
|
28
|
-
end
|
29
|
-
if RUBY_VERSION <= "1.8.7"
|
30
|
-
gem 'i18n', '< 0.7.0'
|
31
|
-
end
|
32
|
-
end
|
33
|
-
platforms :jruby do
|
34
|
-
gem 'activerecord-jdbcsqlite3-adapter', '>= 1.3.0'
|
35
|
-
end
|
36
|
-
platforms :rbx do
|
37
|
-
gem 'rubysl', '~> 2.0'
|
38
|
-
gem 'racc'
|
39
|
-
gem 'rubysl-test-unit'
|
40
|
-
gem 'rubinius-developer_tools'
|
41
|
-
end
|
42
|
-
|
43
|
-
gemspec :path => '../'
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Kaminari
|
2
|
-
module Generators
|
3
|
-
class ConfigGenerator < Rails::Generators::Base
|
4
|
-
source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
|
5
|
-
|
6
|
-
desc <<DESC
|
7
|
-
Description:
|
8
|
-
Copies Kaminari configuration file to your application's initializer directory.
|
9
|
-
DESC
|
10
|
-
|
11
|
-
def copy_config_file
|
12
|
-
template 'kaminari_config.rb', 'config/initializers/kaminari_config.rb'
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,119 +0,0 @@
|
|
1
|
-
module Kaminari
|
2
|
-
module Generators
|
3
|
-
|
4
|
-
class ViewsGenerator < Rails::Generators::NamedBase
|
5
|
-
source_root File.expand_path('../../../../app/views/kaminari', __FILE__)
|
6
|
-
|
7
|
-
class_option :template_engine, :type => :string, :aliases => '-e', :desc => 'Template engine for the views. Available options are "erb", "haml", and "slim".'
|
8
|
-
|
9
|
-
def self.banner #:nodoc:
|
10
|
-
<<-BANNER.chomp
|
11
|
-
rails g kaminari:views THEME [options]
|
12
|
-
|
13
|
-
Copies all paginator partial templates to your application.
|
14
|
-
You can choose a template THEME by specifying one from the list below:
|
15
|
-
|
16
|
-
- default
|
17
|
-
The default one.
|
18
|
-
This one is used internally while you don't override the partials.
|
19
|
-
#{themes.map {|t| " - #{t.name}\n#{t.description}"}.join("\n")}
|
20
|
-
BANNER
|
21
|
-
end
|
22
|
-
|
23
|
-
desc ''
|
24
|
-
def copy_or_fetch #:nodoc:
|
25
|
-
return copy_default_views if file_name == 'default'
|
26
|
-
|
27
|
-
if theme = self.class.themes.detect {|t| t.name == file_name}
|
28
|
-
if download_templates(theme).empty?
|
29
|
-
say %Q[template_engine: #{template_engine} is not available for theme: #{file_name}]
|
30
|
-
end
|
31
|
-
else
|
32
|
-
say %Q[no such theme: #{file_name}\n avaliable themes: #{self.class.themes.map(&:name).join ", "}]
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
def self.themes
|
38
|
-
begin
|
39
|
-
@themes ||= GitHubApiHelper.get_files_in_master.group_by {|fn, _| fn[0...(fn.index('/') || 0)]}.delete_if {|fn, _| fn.blank?}.map do |name, files|
|
40
|
-
Theme.new name, files
|
41
|
-
end
|
42
|
-
rescue SocketError
|
43
|
-
[]
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def download_templates(theme)
|
48
|
-
theme.templates_for(template_engine).each do |template|
|
49
|
-
say " downloading #{template.name} from kaminari_themes..."
|
50
|
-
create_file template.name, GitHubApiHelper.get_content_for("#{theme.name}/#{template.name}")
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def copy_default_views
|
55
|
-
filename_pattern = File.join self.class.source_root, "*.html.#{template_engine}"
|
56
|
-
Dir.glob(filename_pattern).map {|f| File.basename f}.each do |f|
|
57
|
-
copy_file f, "app/views/kaminari/#{f}"
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def template_engine
|
62
|
-
options[:template_engine].try(:to_s).try(:downcase) || 'erb'
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
Template = Struct.new(:name, :sha) do
|
67
|
-
def description?
|
68
|
-
name == 'DESCRIPTION'
|
69
|
-
end
|
70
|
-
|
71
|
-
def view?
|
72
|
-
name =~ /^app\/views\//
|
73
|
-
end
|
74
|
-
|
75
|
-
def engine #:nodoc:
|
76
|
-
File.extname(name).sub /^\./, ''
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
class Theme
|
81
|
-
attr_accessor :name
|
82
|
-
def initialize(name, templates) #:nodoc:
|
83
|
-
@name, @templates = name, templates.map {|fn, sha| Template.new fn.sub(/^#{name}\//, ''), sha}
|
84
|
-
end
|
85
|
-
|
86
|
-
def description #:nodoc:
|
87
|
-
file = @templates.detect(&:description?)
|
88
|
-
return "#{' ' * 12}#{name}" unless file
|
89
|
-
GitHubApiHelper.get_content_for("#{@name}/#{file.name}").chomp.gsub(/^/, ' ' * 12)
|
90
|
-
end
|
91
|
-
|
92
|
-
def templates_for(template_engine) #:nodoc:
|
93
|
-
@templates.select {|t| t.engine == template_engine }
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
module GitHubApiHelper
|
98
|
-
def get_files_in_master
|
99
|
-
master_tree_sha = open('https://api.github.com/repos/amatsuda/kaminari_themes/git/refs/heads/master') do |json|
|
100
|
-
ActiveSupport::JSON.decode(json.read)['object']['sha']
|
101
|
-
end
|
102
|
-
open('https://api.github.com/repos/amatsuda/kaminari_themes/git/trees/' + master_tree_sha + '?recursive=1') do |json|
|
103
|
-
blobs = ActiveSupport::JSON.decode(json.read)['tree'].find_all {|i| i['type'] == 'blob' }
|
104
|
-
blobs.map do |blob|
|
105
|
-
[blob['path'], blob['sha']]
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
module_function :get_files_in_master
|
110
|
-
|
111
|
-
def get_content_for(path)
|
112
|
-
open('https://api.github.com/repos/amatsuda/kaminari_themes/contents/' + path) do |json|
|
113
|
-
Base64.decode64(ActiveSupport::JSON.decode(json.read)['content'])
|
114
|
-
end
|
115
|
-
end
|
116
|
-
module_function :get_content_for
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
data/lib/kaminari/config.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'active_support/configurable'
|
2
|
-
|
3
|
-
module Kaminari
|
4
|
-
# Configures global settings for Kaminari
|
5
|
-
# Kaminari.configure do |config|
|
6
|
-
# config.default_per_page = 10
|
7
|
-
# end
|
8
|
-
def self.configure(&block)
|
9
|
-
yield @config ||= Kaminari::Configuration.new
|
10
|
-
end
|
11
|
-
|
12
|
-
# Global settings for Kaminari
|
13
|
-
def self.config
|
14
|
-
@config
|
15
|
-
end
|
16
|
-
|
17
|
-
# need a Class for 3.0
|
18
|
-
class Configuration #:nodoc:
|
19
|
-
include ActiveSupport::Configurable
|
20
|
-
config_accessor :default_per_page
|
21
|
-
config_accessor :max_per_page
|
22
|
-
config_accessor :window
|
23
|
-
config_accessor :outer_window
|
24
|
-
config_accessor :left
|
25
|
-
config_accessor :right
|
26
|
-
config_accessor :page_method_name
|
27
|
-
config_accessor :max_pages
|
28
|
-
|
29
|
-
def param_name
|
30
|
-
config.param_name.respond_to?(:call) ? config.param_name.call : config.param_name
|
31
|
-
end
|
32
|
-
|
33
|
-
# define param_name writer (copied from AS::Configurable)
|
34
|
-
writer, line = 'def param_name=(value); config.param_name = value; end', __LINE__
|
35
|
-
singleton_class.class_eval writer, __FILE__, line
|
36
|
-
class_eval writer, __FILE__, line
|
37
|
-
end
|
38
|
-
|
39
|
-
# this is ugly. why can't we pass the default value to config_accessor...?
|
40
|
-
configure do |config|
|
41
|
-
config.default_per_page = 25
|
42
|
-
config.max_per_page = nil
|
43
|
-
config.window = 4
|
44
|
-
config.outer_window = 0
|
45
|
-
config.left = 0
|
46
|
-
config.right = 0
|
47
|
-
config.page_method_name = :page
|
48
|
-
config.param_name = :page
|
49
|
-
config.max_pages = nil
|
50
|
-
end
|
51
|
-
end
|
data/lib/kaminari/engine.rb
DELETED
data/lib/kaminari/grape.rb
DELETED