the_pagination 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f3744ef91c8002a6f633c9d4f37b5355fcd12ba
4
- data.tar.gz: 33596bc9c12451f655ea066aeacf818c624c081e
3
+ metadata.gz: a7d1bdaac42b90db91f8c5b7fb7f155cec28c279
4
+ data.tar.gz: e3e36b39929b84215afbeffa18656180154008b4
5
5
  SHA512:
6
- metadata.gz: 0911734c29c6aebb182b42efefdbbefb11d6dc9e2021a3e60a0962a6aa91c4fb5e4b8d6ffeb0d30f0e1c6700c8c7b786240b6760fc60a184f2b142d2cc10e651
7
- data.tar.gz: 7c9cdd40fab014701ed1f68a1ebef8a4bd41e1365306a88a25c1fe0d2750fac7b0c1adf7719d64ae4de3773d2a76aa27974a51fecc742b90e59c38d257d7e6d9
6
+ metadata.gz: e5a07f95b8562ffd9e7fb11ec62d529f97c8b540a4039d37c4c25f8fcf26a65ec47df50611174465c28d1fa163a2d7d76566760cd8d74f86716c3f8cadbe5065
7
+ data.tar.gz: 7f28938f91a633fe4941e51c08d7f90514ff6a9f5785335206eb1271bda3d1ecb45e6203e55fa550951b38022a4c1cc77a37d36292bfa811dc8504bafde74b9c
data/.keep ADDED
File without changes
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in the_pagination.gemspec
3
+ # Specify your gem's dependencies in pagination.gemspec
4
4
  gemspec
data/README.md CHANGED
@@ -1,3 +1,85 @@
1
- # ThePagination
1
+ ```ruby
2
+ This gem is a part of TheOpenCMS project. https://github.com/TheOpenCMS
3
+ ```
2
4
 
3
- Just Pagination conerns for The!Profit CMS
5
+ ## Pagination
6
+
7
+ This simple gem provides the only method `pagination`, which takes `per_page` and `page` parameters from `params` hash and applies these parameters to a Model. In fact this gem just provides a simple helper to improve a typical staff with `per_page` and `page` parameters. Works with `Kaminary`.
8
+
9
+ ```ruby
10
+ class Product < AR
11
+ include ::Pagination::Base
12
+ end
13
+ ```
14
+
15
+ ```ruby
16
+ @posts = Post.pagination(params)
17
+ ```
18
+
19
+ ```ruby
20
+ div Items on the page:
21
+ - %w[ 5 10 20 50 100 125 ].each do |num|
22
+ span= link_to num, url_for(per_page: num)
23
+ ```
24
+
25
+ ### Configurations of `page_method_name`
26
+
27
+ **config/initializers/kaminari.rb**
28
+
29
+ ```ruby
30
+ Kaminari.configure do |config|
31
+ config.page_method_name = :per_page_kaminari
32
+ end
33
+
34
+ module ::Pagination::Base
35
+ def self.per_method
36
+ @per = :per_page_kaminari
37
+ end
38
+ end
39
+ ```
40
+
41
+ ## Pagination (RU)
42
+
43
+ Этот простой гем всего лишь предоставляет метод `pagination`, который берет параметры `per_page` и `page` из хеша `params` и применяет их к Модели. По факту гем просто обеспечивает простой хелпер, что бы улучшить типичную работу с переменными `per_page` и `page`. Работает с `Kaminary`.
44
+
45
+ ```ruby
46
+ class Product < AR
47
+ include ::Pagination::Base
48
+ end
49
+ ```
50
+
51
+ ```ruby
52
+ @posts = Post.pagination(params)
53
+ ```
54
+
55
+ ```ruby
56
+ div Элементов на странице:
57
+ - %w[ 5 10 20 50 100 125 ].each do |num|
58
+ span= link_to num, url_for(per_page: num)
59
+ ```
60
+
61
+ ### Конфигурация параметра `page_method_name`
62
+
63
+ **config/initializers/kaminari.rb**
64
+
65
+ ```ruby
66
+ Kaminari.configure do |config|
67
+ config.page_method_name = :per_page_kaminari
68
+ end
69
+
70
+ module ::Pagination::Base
71
+ def self.per_method
72
+ @per = :per_page_kaminari
73
+ end
74
+ end
75
+ ```
76
+
77
+ ### MIT License
78
+
79
+ Copyright (c) 2014-[Current Year] Ilya N. Zykin
80
+
81
+ 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:
82
+
83
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
84
+
85
+ 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.
@@ -0,0 +1,6 @@
1
+ ru:
2
+ views:
3
+ pagination:
4
+ first: Первая
5
+ last: Последняя
6
+ truncate: '...'
data/lib/pagination.rb ADDED
@@ -0,0 +1,21 @@
1
+ require "kaminari"
2
+
3
+ module Pagination
4
+ class Engine < Rails::Engine; end
5
+
6
+ module Base
7
+ extend ActiveSupport::Concern
8
+
9
+ # for example: per_page_kaminari
10
+ def self.per_method
11
+ @per ||= :per
12
+ end
13
+
14
+ class_methods do
15
+ def pagination params
16
+ per_method = ::Pagination::Base.per_method
17
+ page(params[:page]).send(::Pagination::Base.per_method, params[:per_page])
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,16 +1,19 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'the_pagination/version'
4
+
5
+ module Pagination
6
+ VERSION = "1.0.0"
7
+ end
5
8
 
6
9
  Gem::Specification.new do |spec|
7
10
  spec.name = "the_pagination"
8
- spec.version = ThePagination::VERSION
11
+ spec.version = Pagination::VERSION
9
12
  spec.authors = ["Ilya N. Zykin"]
10
13
  spec.email = ["zykin-ilya@ya.ru"]
11
- spec.summary = %q{Pagination concerns}
12
- spec.description = %q{Pagination concerns for The!Profit CMS}
13
- spec.homepage = "https://github.com/TheProfitCMS/the_pagination"
14
+ spec.summary = %q{Pagination helper}
15
+ spec.description = %q{Pagination helper for Kaminary based Models}
16
+ spec.homepage = "https://github.com/TheOpenCMS"
14
17
  spec.license = "MIT"
15
18
 
16
19
  spec.files = `git ls-files -z`.split("\x0")
@@ -18,6 +21,8 @@ Gem::Specification.new do |spec|
18
21
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
22
  spec.require_paths = ["lib"]
20
23
 
24
+ spec.add_dependency 'kaminari'
25
+
21
26
  spec.add_development_dependency "bundler", "~> 1.6"
22
27
  spec.add_development_dependency "rake"
23
28
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: the_pagination
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya N. Zykin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-22 00:00:00.000000000 Z
11
+ date: 2017-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: kaminari
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,7 +52,7 @@ dependencies:
38
52
  - - ">="
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
- description: Pagination concerns for The!Profit CMS
55
+ description: Pagination helper for Kaminary based Models
42
56
  email:
43
57
  - zykin-ilya@ya.ru
44
58
  executables: []
@@ -46,15 +60,15 @@ extensions: []
46
60
  extra_rdoc_files: []
47
61
  files:
48
62
  - ".gitignore"
63
+ - ".keep"
49
64
  - Gemfile
50
65
  - LICENSE.txt
51
66
  - README.md
52
67
  - Rakefile
53
- - gem_version.rb
54
- - lib/the_pagination.rb
55
- - lib/the_pagination/version.rb
68
+ - config/locales/ru.yml
69
+ - lib/pagination.rb
56
70
  - the_pagination.gemspec
57
- homepage: https://github.com/TheProfitCMS/the_pagination
71
+ homepage: https://github.com/TheOpenCMS
58
72
  licenses:
59
73
  - MIT
60
74
  metadata: {}
@@ -74,8 +88,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
88
  version: '0'
75
89
  requirements: []
76
90
  rubyforge_project:
77
- rubygems_version: 2.2.2
91
+ rubygems_version: 2.5.2
78
92
  signing_key:
79
93
  specification_version: 4
80
- summary: Pagination concerns
94
+ summary: Pagination helper
81
95
  test_files: []
data/gem_version.rb DELETED
@@ -1,3 +0,0 @@
1
- module ThePagination
2
- VERSION = "0.0.1"
3
- end
@@ -1,15 +0,0 @@
1
- require "the_pagination/version"
2
-
3
- module ThePagination
4
- class Engine < Rails::Engine; end
5
-
6
- module Concern
7
- extend ActiveSupport::Concern
8
-
9
- module ClassMethods
10
- def pagination params
11
- page(params[:page]).per(params[:per_page])
12
- end
13
- end
14
- end
15
- end
@@ -1 +0,0 @@
1
- require_relative '../../gem_version'