pagy 3.10.0 → 5.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/lib/config/pagy.rb +121 -52
- data/lib/javascripts/pagy-dev.js +117 -0
- data/lib/javascripts/pagy.js +1 -106
- data/lib/javascripts/pagy.mjs +118 -0
- data/lib/locales/ar.yml +26 -0
- data/lib/locales/bg.yml +2 -2
- data/lib/locales/bs.yml +24 -0
- data/lib/locales/ca.yml +2 -2
- data/lib/locales/cs.yml +2 -2
- data/lib/locales/da.yml +2 -2
- data/lib/locales/de.yml +2 -2
- data/lib/locales/en.yml +2 -2
- data/lib/locales/es.yml +2 -2
- data/lib/locales/fr.yml +2 -2
- data/lib/locales/hr.yml +24 -0
- data/lib/locales/id.yml +2 -2
- data/lib/locales/it.yml +2 -2
- data/lib/locales/ja.yml +2 -2
- data/lib/locales/km.yml +2 -2
- data/lib/locales/ko.yml +2 -2
- data/lib/locales/nb.yml +2 -2
- data/lib/locales/nl.yml +2 -2
- data/lib/locales/pl.yml +2 -2
- data/lib/locales/pt-BR.yml +2 -2
- data/lib/locales/pt.yml +2 -2
- data/lib/locales/ru.yml +2 -2
- data/lib/locales/sr.yml +23 -0
- data/lib/locales/sv-SE.yml +2 -2
- data/lib/locales/sv.yml +2 -2
- data/lib/locales/sw.yml +22 -0
- data/lib/locales/ta.yml +22 -0
- data/lib/locales/tr.yml +2 -2
- data/lib/locales/uk.yml +24 -0
- data/lib/locales/zh-CN.yml +2 -2
- data/lib/locales/zh-HK.yml +2 -2
- data/lib/locales/zh-TW.yml +3 -3
- data/lib/pagy/backend.rb +11 -12
- data/lib/pagy/calendar/day.rb +29 -0
- data/lib/pagy/calendar/month.rb +16 -0
- data/lib/pagy/calendar/month_mixin.rb +49 -0
- data/lib/pagy/calendar/quarter.rb +23 -0
- data/lib/pagy/calendar/week.rb +39 -0
- data/lib/pagy/calendar/year.rb +29 -0
- data/lib/pagy/calendar.rb +90 -0
- data/lib/pagy/console.rb +23 -0
- data/lib/pagy/countless.rb +23 -19
- data/lib/pagy/exceptions.rb +16 -13
- data/lib/pagy/extras/arel.rb +12 -7
- data/lib/pagy/extras/array.rb +10 -9
- data/lib/pagy/extras/bootstrap.rb +77 -39
- data/lib/pagy/extras/bulma.rb +77 -43
- data/lib/pagy/extras/calendar.rb +66 -0
- data/lib/pagy/extras/countless.rb +17 -17
- data/lib/pagy/extras/elasticsearch_rails.rb +66 -37
- data/lib/pagy/extras/foundation.rb +74 -41
- data/lib/pagy/extras/frontend_helpers.rb +70 -0
- data/lib/pagy/extras/gearbox.rb +42 -0
- data/lib/pagy/extras/headers.rb +32 -18
- data/lib/pagy/extras/i18n.rb +18 -17
- data/lib/pagy/extras/items.rb +42 -53
- data/lib/pagy/extras/materialize.rb +68 -43
- data/lib/pagy/extras/meilisearch.rb +61 -0
- data/lib/pagy/extras/metadata.rb +27 -26
- data/lib/pagy/extras/navs.rb +54 -29
- data/lib/pagy/extras/overflow.rb +57 -52
- data/lib/pagy/extras/searchkick.rb +54 -36
- data/lib/pagy/extras/semantic.rb +66 -39
- data/lib/pagy/extras/standalone.rb +64 -0
- data/lib/pagy/extras/support.rb +34 -17
- data/lib/pagy/extras/trim.rb +18 -12
- data/lib/pagy/extras/uikit.rb +66 -44
- data/lib/pagy/frontend.rb +61 -53
- data/lib/pagy/i18n.rb +164 -0
- data/lib/pagy/url_helpers.rb +38 -0
- data/lib/pagy.rb +96 -30
- data/lib/templates/bootstrap_nav.html.erb +1 -1
- data/lib/templates/bootstrap_nav.html.haml +1 -1
- data/lib/templates/bootstrap_nav.html.slim +1 -1
- data/lib/templates/foundation_nav.html.erb +1 -1
- data/lib/templates/foundation_nav.html.haml +1 -1
- data/lib/templates/foundation_nav.html.slim +1 -1
- data/lib/templates/uikit_nav.html.erb +2 -2
- data/lib/templates/uikit_nav.html.haml +1 -1
- data/lib/templates/uikit_nav.html.slim +2 -2
- metadata +37 -16
- data/lib/locales/README.md +0 -35
- data/lib/locales/utils/i18n.rb +0 -25
- data/lib/locales/utils/loader.rb +0 -34
- data/lib/locales/utils/p11n.rb +0 -88
- data/lib/pagy/extras/pagy_search.rb +0 -18
- data/lib/pagy/extras/shared.rb +0 -53
- data/pagy.gemspec +0 -16
metadata
CHANGED
@@ -1,18 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pagy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Domizio Demichelis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
14
|
-
and DB type, with all kinds of collections, even pre-paginated, scopes, Arrays,
|
15
|
-
JSON data... Easy, powerful, fast and light.'
|
13
|
+
description: Agnostic pagination in plain ruby. It does it all. Better.
|
16
14
|
email:
|
17
15
|
- dd.nexus@gmail.com
|
18
16
|
executables: []
|
@@ -21,9 +19,12 @@ extra_rdoc_files: []
|
|
21
19
|
files:
|
22
20
|
- LICENSE.txt
|
23
21
|
- lib/config/pagy.rb
|
22
|
+
- lib/javascripts/pagy-dev.js
|
24
23
|
- lib/javascripts/pagy.js
|
25
|
-
- lib/
|
24
|
+
- lib/javascripts/pagy.mjs
|
25
|
+
- lib/locales/ar.yml
|
26
26
|
- lib/locales/bg.yml
|
27
|
+
- lib/locales/bs.yml
|
27
28
|
- lib/locales/ca.yml
|
28
29
|
- lib/locales/cs.yml
|
29
30
|
- lib/locales/da.yml
|
@@ -31,6 +32,7 @@ files:
|
|
31
32
|
- lib/locales/en.yml
|
32
33
|
- lib/locales/es.yml
|
33
34
|
- lib/locales/fr.yml
|
35
|
+
- lib/locales/hr.yml
|
34
36
|
- lib/locales/id.yml
|
35
37
|
- lib/locales/it.yml
|
36
38
|
- lib/locales/ja.yml
|
@@ -42,41 +44,55 @@ files:
|
|
42
44
|
- lib/locales/pt-BR.yml
|
43
45
|
- lib/locales/pt.yml
|
44
46
|
- lib/locales/ru.yml
|
47
|
+
- lib/locales/sr.yml
|
45
48
|
- lib/locales/sv-SE.yml
|
46
49
|
- lib/locales/sv.yml
|
50
|
+
- lib/locales/sw.yml
|
51
|
+
- lib/locales/ta.yml
|
47
52
|
- lib/locales/tr.yml
|
48
|
-
- lib/locales/
|
49
|
-
- lib/locales/utils/loader.rb
|
50
|
-
- lib/locales/utils/p11n.rb
|
53
|
+
- lib/locales/uk.yml
|
51
54
|
- lib/locales/zh-CN.yml
|
52
55
|
- lib/locales/zh-HK.yml
|
53
56
|
- lib/locales/zh-TW.yml
|
54
57
|
- lib/pagy.rb
|
55
58
|
- lib/pagy/backend.rb
|
59
|
+
- lib/pagy/calendar.rb
|
60
|
+
- lib/pagy/calendar/day.rb
|
61
|
+
- lib/pagy/calendar/month.rb
|
62
|
+
- lib/pagy/calendar/month_mixin.rb
|
63
|
+
- lib/pagy/calendar/quarter.rb
|
64
|
+
- lib/pagy/calendar/week.rb
|
65
|
+
- lib/pagy/calendar/year.rb
|
66
|
+
- lib/pagy/console.rb
|
56
67
|
- lib/pagy/countless.rb
|
57
68
|
- lib/pagy/exceptions.rb
|
58
69
|
- lib/pagy/extras/arel.rb
|
59
70
|
- lib/pagy/extras/array.rb
|
60
71
|
- lib/pagy/extras/bootstrap.rb
|
61
72
|
- lib/pagy/extras/bulma.rb
|
73
|
+
- lib/pagy/extras/calendar.rb
|
62
74
|
- lib/pagy/extras/countless.rb
|
63
75
|
- lib/pagy/extras/elasticsearch_rails.rb
|
64
76
|
- lib/pagy/extras/foundation.rb
|
77
|
+
- lib/pagy/extras/frontend_helpers.rb
|
78
|
+
- lib/pagy/extras/gearbox.rb
|
65
79
|
- lib/pagy/extras/headers.rb
|
66
80
|
- lib/pagy/extras/i18n.rb
|
67
81
|
- lib/pagy/extras/items.rb
|
68
82
|
- lib/pagy/extras/materialize.rb
|
83
|
+
- lib/pagy/extras/meilisearch.rb
|
69
84
|
- lib/pagy/extras/metadata.rb
|
70
85
|
- lib/pagy/extras/navs.rb
|
71
86
|
- lib/pagy/extras/overflow.rb
|
72
|
-
- lib/pagy/extras/pagy_search.rb
|
73
87
|
- lib/pagy/extras/searchkick.rb
|
74
88
|
- lib/pagy/extras/semantic.rb
|
75
|
-
- lib/pagy/extras/
|
89
|
+
- lib/pagy/extras/standalone.rb
|
76
90
|
- lib/pagy/extras/support.rb
|
77
91
|
- lib/pagy/extras/trim.rb
|
78
92
|
- lib/pagy/extras/uikit.rb
|
79
93
|
- lib/pagy/frontend.rb
|
94
|
+
- lib/pagy/i18n.rb
|
95
|
+
- lib/pagy/url_helpers.rb
|
80
96
|
- lib/templates/bootstrap_nav.html.erb
|
81
97
|
- lib/templates/bootstrap_nav.html.haml
|
82
98
|
- lib/templates/bootstrap_nav.html.slim
|
@@ -92,11 +108,16 @@ files:
|
|
92
108
|
- lib/templates/uikit_nav.html.erb
|
93
109
|
- lib/templates/uikit_nav.html.haml
|
94
110
|
- lib/templates/uikit_nav.html.slim
|
95
|
-
- pagy.gemspec
|
96
111
|
homepage: https://github.com/ddnexus/pagy
|
97
112
|
licenses:
|
98
113
|
- MIT
|
99
|
-
metadata:
|
114
|
+
metadata:
|
115
|
+
rubygems_mfa_required: 'true'
|
116
|
+
homepage_uri: https://github.com/ddnexus/pagy
|
117
|
+
documentation_uri: https://ddnexus.github.io/pagy
|
118
|
+
bug_tracker_uri: https://github.com/ddnexus/pagy/issues
|
119
|
+
changelog_uri: https://github.com/ddnexus/pagy/blob/master/CHANGELOG.md
|
120
|
+
live_support: https://gitter.im/ruby-pagy/Lobby
|
100
121
|
post_install_message:
|
101
122
|
rdoc_options: []
|
102
123
|
require_paths:
|
@@ -105,15 +126,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
105
126
|
requirements:
|
106
127
|
- - ">="
|
107
128
|
- !ruby/object:Gem::Version
|
108
|
-
version: '
|
129
|
+
version: '2.5'
|
109
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
131
|
requirements:
|
111
132
|
- - ">="
|
112
133
|
- !ruby/object:Gem::Version
|
113
134
|
version: '0'
|
114
135
|
requirements: []
|
115
|
-
rubygems_version: 3.
|
136
|
+
rubygems_version: 3.2.32
|
116
137
|
signing_key:
|
117
138
|
specification_version: 4
|
118
|
-
summary: The
|
139
|
+
summary: The kick-ass pagination ruby gem
|
119
140
|
test_files: []
|
data/lib/locales/README.md
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
# Pagy locales
|
2
|
-
|
3
|
-
### Please, submit your translation!
|
4
|
-
|
5
|
-
If you find that some translation could be improved, please, create an issue.
|
6
|
-
|
7
|
-
If you are using pagy with some language missing from the dictionary files, please, submit your translation!
|
8
|
-
|
9
|
-
You can create a Pull Request for your language, and get all the help you need to correctly complete it. Here is a check list.
|
10
|
-
|
11
|
-
### Check list for a new dictionary file:
|
12
|
-
|
13
|
-
- [ ] Find the pluralization rule for your language
|
14
|
-
|
15
|
-
- [ ] Find the locale file you need in the [list of pluralizations](https://github.com/svenfuchs/rails-i18n/tree/master/rails/pluralization) and check the pluralization rule in it. For example it is `::RailsI18n::Pluralization::OneOther.with_locale(:en)` for `en.rb`. Note the rule part i.e. `OneOther`. In pagy that translates to the symbol `:one_other`.
|
16
|
-
|
17
|
-
- [ ] If the pluralization rule of your language is not the `:one_other` default, confirm that the [p11n.rb](https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb) file already defines the pluralization rule of your dictionary file:
|
18
|
-
|
19
|
-
- [ ] If the rule is not defined, you can either: a) Add the rule as a new rule/lambda entry in the `p11n` variable hash and relative tests or b) Just create an issue requesting the addition to the rule/lambda entry and tests.
|
20
|
-
|
21
|
-
- [ ] Add your language to the `plurals` hash in the file.
|
22
|
-
|
23
|
-
- [ ] add/edit the first line comment in the language rule in your dictionary file (e.g. `# :one_other pluralization ...`
|
24
|
-
|
25
|
-
- [ ] The mandatory pluralized entry in the dictionary file is the `item_name`. Please, provide all the plurals needed by your language. E.g. if your language uses the `:east_slavic` you should provide the plurals for `one`, `few`, `many` and `other`, if it uses `:one_other`, you should provide `one` and `other` plurals. If it uses `:other` you should only provide a single value. Look into other dictionary files to get some example. Ask if in doubt.
|
26
|
-
|
27
|
-
- [ ] The other entries in the dictionary file don't need any plural variant in most languages since the pluralization of the `item_name` in the sentence is enough. However, in some language, a whole sentence might need to be written in different ways for different counts. In that case you should add the different plurals for the sentence and the `count` will trigger the one that applies.
|
28
|
-
|
29
|
-
Feel free to ask for help in your Pull Request.
|
30
|
-
|
31
|
-
### Useful Links
|
32
|
-
|
33
|
-
* [Pagy I18n Documentation](https://ddnexus.github.io/pagy/api/frontend#i18n)
|
34
|
-
* [I18n Extra](https://ddnexus.github.io/pagy/extras/i18n)
|
35
|
-
|
data/lib/locales/utils/i18n.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# See https://ddnexus.github.io/pagy/api/frontend#i18n
|
2
|
-
# encoding: utf-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
|
5
|
-
# this file returns the I18n hash used as default alternative to the i18n gem
|
6
|
-
|
7
|
-
Pagy::DEPRECATED_LOCALES = {'pt-br' =>'pt-BR', 'se' => 'sv-SE'}
|
8
|
-
|
9
|
-
Hash.new{|h,_| h.first[1]}.tap do |i18n_hash| # first loaded locale used as default
|
10
|
-
i18n_hash.define_singleton_method(:load) do |*load_args|
|
11
|
-
# eval: we don't need to keep the loader proc in memory
|
12
|
-
eval(Pagy.root.join('locales', 'utils', 'loader.rb').read).call(i18n_hash, *load_args) #rubocop:disable Security/Eval
|
13
|
-
end
|
14
|
-
i18n_hash.define_singleton_method(:t) do |locale, path, vars={}|
|
15
|
-
if Pagy::DEPRECATED_LOCALES.key?(locale)
|
16
|
-
new_locale = Pagy::DEPRECATED_LOCALES[locale]
|
17
|
-
$stderr.puts("WARNING: the Pagy locale '#{locale}' is deprecated; use '#{new_locale}' instead")
|
18
|
-
locale = new_locale
|
19
|
-
end
|
20
|
-
data, pluralize = self[locale]
|
21
|
-
translate = data[path] || vars[:count] && data[path+=".#{pluralize.call(vars[:count])}"] or return %([translation missing: "#{path}"])
|
22
|
-
translate.call(vars)
|
23
|
-
end
|
24
|
-
i18n_hash.load(locale: 'en')
|
25
|
-
end
|
data/lib/locales/utils/loader.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
# the whole file will be eval'ed/executed and gc-collected after returning/executing the loader proc
|
5
|
-
|
6
|
-
# eval: no need for the whole file in memory
|
7
|
-
plurals, _ = eval(Pagy.root.join('locales', 'utils', 'p11n.rb').read) #rubocop:disable Security/Eval
|
8
|
-
|
9
|
-
# flatten the dictionary file nested keys
|
10
|
-
# convert each value to a simple ruby interpolation proc
|
11
|
-
flatten = lambda do |hash, key=''|
|
12
|
-
hash.each.reduce({}) do |h, (k, v)|
|
13
|
-
v.is_a?(Hash) \
|
14
|
-
? h.merge!(flatten.call(v, "#{key}#{k}."))
|
15
|
-
: h.merge!(eval %({"#{key}#{k}" => lambda{|vars|"#{v.gsub(/%{[^}]+?}/){|m| "\#{vars[:#{m[2..-2]}]||'#{m}'}" }}"}})) #rubocop:disable Security/Eval
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
# loader proc
|
20
|
-
lambda do |i18n, *args|
|
21
|
-
i18n.clear
|
22
|
-
args.each do |arg|
|
23
|
-
if Pagy::DEPRECATED_LOCALES.key?(arg[:locale])
|
24
|
-
new_locale = Pagy::DEPRECATED_LOCALES[arg[:locale]]
|
25
|
-
$stderr.puts("WARNING: the Pagy locale '#{arg[:locale]}' is deprecated; use '#{new_locale}' instead")
|
26
|
-
arg[:locale] = new_locale
|
27
|
-
end
|
28
|
-
arg[:filepath] ||= Pagy.root.join('locales', "#{arg[:locale]}.yml")
|
29
|
-
arg[:pluralize] ||= plurals[arg[:locale]]
|
30
|
-
hash = YAML.load(File.read(arg[:filepath], encoding: 'UTF-8')) #rubocop:disable Security/YAMLLoad
|
31
|
-
hash.key?(arg[:locale]) or raise VariableError, %(expected :locale "#{arg[:locale]}" not found in :filepath "#{arg[:filepath].inspect}")
|
32
|
-
i18n[arg[:locale]] = [flatten.call(hash[arg[:locale]]), arg[:pluralize]]
|
33
|
-
end
|
34
|
-
end
|
data/lib/locales/utils/p11n.rb
DELETED
@@ -1,88 +0,0 @@
|
|
1
|
-
# See https://ddnexus.github.io/pagy/api/frontend#i18n
|
2
|
-
# encoding: utf-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
|
5
|
-
# This file adds support for multiple built-in plualization types.
|
6
|
-
# It defines the pluralization procs and gets eval(ed) and gc-collected at Pagy::I18n.load time.
|
7
|
-
|
8
|
-
# utility variables
|
9
|
-
from0to1 = [0,1].freeze
|
10
|
-
from2to4 = [2,3,4].freeze
|
11
|
-
from5to9 = [5,6,7,8,9].freeze
|
12
|
-
from11to14 = [11,12,13,14].freeze
|
13
|
-
from12to14 = [12,13,14].freeze
|
14
|
-
|
15
|
-
# Pluralization (p11n)
|
16
|
-
# Compliant with the I18n gem
|
17
|
-
# A pluralization proc returns a plural type string based on the passed count
|
18
|
-
# Each proc may apply to one or more locales below.
|
19
|
-
# Pluralization logic adapted from https://github.com/svenfuchs/rails-i18n
|
20
|
-
p11n = {
|
21
|
-
one_other: lambda {|n| n == 1 ? 'one' : 'other'}, # default
|
22
|
-
|
23
|
-
east_slavic: lambda do |n|
|
24
|
-
n ||= 0
|
25
|
-
mod10 = n % 10
|
26
|
-
mod100 = n % 100
|
27
|
-
|
28
|
-
if mod10 == 1 && mod100 != 11 ; 'one'
|
29
|
-
elsif from2to4.include?(mod10) && !from12to14.include?(mod100) ; 'few'
|
30
|
-
elsif mod10 == 0 || from5to9.include?(mod10) || from11to14.include?(mod100) ; 'many'
|
31
|
-
else 'other'
|
32
|
-
end
|
33
|
-
end,
|
34
|
-
|
35
|
-
west_slavic: lambda do |n|
|
36
|
-
if n == 1 ; 'one'
|
37
|
-
elsif [2, 3, 4].include?(n) ; 'few'
|
38
|
-
else ; 'other'
|
39
|
-
end
|
40
|
-
end,
|
41
|
-
|
42
|
-
one_two_other: lambda do |n|
|
43
|
-
if n == 1 ; 'one'
|
44
|
-
elsif n == 2 ; 'two'
|
45
|
-
else 'other'
|
46
|
-
end
|
47
|
-
end,
|
48
|
-
|
49
|
-
one_upto_two_other: lambda {|n| n && n >= 0 && n < 2 ? 'one' : 'other'},
|
50
|
-
|
51
|
-
other: Proc.new { 'other' },
|
52
|
-
|
53
|
-
polish: lambda do |n|
|
54
|
-
n ||= 0
|
55
|
-
mod10 = n % 10
|
56
|
-
mod100 = n % 100
|
57
|
-
if n == 1 ; 'one'
|
58
|
-
elsif from2to4.include?(mod10) && !from12to14.include?(mod100) ; 'few'
|
59
|
-
elsif (from0to1 + from5to9).include?(mod10) || from12to14.include?(mod100) ; 'many'
|
60
|
-
else 'other'
|
61
|
-
end
|
62
|
-
end
|
63
|
-
}
|
64
|
-
|
65
|
-
# Hash of locale/pluralization pairs
|
66
|
-
# It contains all the entries for all the locales defined as dictionaries.
|
67
|
-
# The default pluralization for locales not explicitly listed here
|
68
|
-
# is the :one_other pluralization proc (used for English)
|
69
|
-
plurals = Hash.new(p11n[:one_other]).tap do |hash|
|
70
|
-
hash['cs'] = p11n[:west_slavic]
|
71
|
-
hash['id'] = p11n[:other]
|
72
|
-
hash['fr'] = p11n[:one_upto_two_other]
|
73
|
-
hash['ja'] = p11n[:other]
|
74
|
-
hash['km'] = p11n[:other]
|
75
|
-
hash['ko'] = p11n[:other]
|
76
|
-
hash['pl'] = p11n[:polish]
|
77
|
-
hash['ru'] = p11n[:east_slavic]
|
78
|
-
hash['sv'] = p11n[:one_two_other]
|
79
|
-
hash['sv-SE'] = p11n[:one_two_other]
|
80
|
-
hash['tr'] = p11n[:other]
|
81
|
-
hash['zh-CN'] = p11n[:other]
|
82
|
-
hash['zh-HK'] = p11n[:other]
|
83
|
-
hash['zh-TW'] = p11n[:other]
|
84
|
-
end
|
85
|
-
|
86
|
-
[ plurals, p11n ]
|
87
|
-
|
88
|
-
# PR for other locales and pluralizations are very welcome. Thanks!
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# Support module to capture search calls
|
2
|
-
# encoding: utf-8
|
3
|
-
# frozen_string_literal: true
|
4
|
-
|
5
|
-
class Pagy
|
6
|
-
module Search
|
7
|
-
# returns an array used to delay the call of #search
|
8
|
-
# after the pagination variables are merged to the options
|
9
|
-
# it also pushes to the same array an eventually called method and arguments
|
10
|
-
# the last search argument must be a hash option
|
11
|
-
def pagy_search(*search_args, &block)
|
12
|
-
search_args << {} unless search_args[-1].is_a?(Hash)
|
13
|
-
[self, search_args, block].tap do |args|
|
14
|
-
args.define_singleton_method(:method_missing){|*a| args += a}
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
data/lib/pagy/extras/shared.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'digest'
|
5
|
-
|
6
|
-
class Pagy
|
7
|
-
|
8
|
-
# default :steps: false will use {0 => @vars[:size]}
|
9
|
-
VARS[:steps] = false
|
10
|
-
|
11
|
-
# `Pagy` instance method used by the `pagy*_nav_js` helpers.
|
12
|
-
# It returns the sequels of width/series generated from the :steps hash
|
13
|
-
# Example:
|
14
|
-
# >> pagy = Pagy.new(count:1000, page: 20, steps: {0 => [1,2,2,1], 350 => [2,3,3,2], 550 => [3,4,4,3]})
|
15
|
-
# >> pagy.sequels
|
16
|
-
# #=> { "0" => [1, :gap, 18, 19, "20", 21, 22, :gap, 50],
|
17
|
-
# "350" => [1, 2, :gap, 17, 18, 19, "20", 21, 22, 23, :gap, 49, 50],
|
18
|
-
# "550" => [1, 2, 3, :gap, 16, 17, 18, 19, "20", 21, 22, 23, 24, :gap, 48, 49, 50] }
|
19
|
-
# Notice: if :steps is false it will use the single {0 => @vars[:size]} size
|
20
|
-
def sequels
|
21
|
-
steps = @vars[:steps] || {0 => @vars[:size]}
|
22
|
-
steps.key?(0) or raise(VariableError.new(self), "expected :steps to define the 0 width; got #{steps.inspect}")
|
23
|
-
sequels = {}; steps.each {|width, size| sequels[width.to_s] = series(size)}; sequels
|
24
|
-
end
|
25
|
-
|
26
|
-
module Frontend
|
27
|
-
|
28
|
-
if defined?(Oj)
|
29
|
-
# it returns a script tag with the JSON-serialized args generated with the faster oj gem
|
30
|
-
def pagy_json_tag(*args)
|
31
|
-
%(<script type="application/json" class="pagy-json">#{Oj.dump(args, mode: :strict)}</script>)
|
32
|
-
end
|
33
|
-
else
|
34
|
-
require 'json'
|
35
|
-
# it returns a script tag with the JSON-serialized args generated with the slower to_json
|
36
|
-
def pagy_json_tag(*args)
|
37
|
-
%(<script type="application/json" class="pagy-json">#{args.to_json}</script>)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
# it returns the SHA1 (fastest on modern ruby) string used as default `id` attribute by all the `*_js` tags
|
42
|
-
def pagy_id
|
43
|
-
"pagy-#{Digest::SHA1.hexdigest(caller(2..2)[0].split(':in')[0])}"
|
44
|
-
end
|
45
|
-
|
46
|
-
# it returns the marked link to used by pagy.js
|
47
|
-
def pagy_marked_link(link)
|
48
|
-
link.call(PAGE_PLACEHOLDER, '', 'style="display: none;"')
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
data/pagy.gemspec
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
lib = File.expand_path('../lib', __FILE__)
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require 'pagy'
|
4
|
-
|
5
|
-
Gem::Specification.new do |s|
|
6
|
-
s.name = 'pagy'
|
7
|
-
s.version = Pagy::VERSION
|
8
|
-
s.authors = ['Domizio Demichelis']
|
9
|
-
s.email = ['dd.nexus@gmail.com']
|
10
|
-
s.summary = 'The Ultimate Pagination Ruby Gem'
|
11
|
-
s.description = 'Agnostic pagination in plain ruby: it works with any framework, ORM and DB type, with all kinds of collections, even pre-paginated, scopes, Arrays, JSON data... Easy, powerful, fast and light.'
|
12
|
-
s.homepage = 'https://github.com/ddnexus/pagy'
|
13
|
-
s.license = 'MIT'
|
14
|
-
s.files = `git ls-files -z`.split("\x0").select{|f| f.start_with?('lib', 'pagy.gemspec', 'LICENSE') }
|
15
|
-
s.required_ruby_version = '>= 1.9' # rubocop:disable Gemspec/RequiredRubyVersion
|
16
|
-
end
|