pagy 8.4.4 → 8.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/apps/calendar.ru +681 -2136
- data/apps/demo.ru +1 -1
- data/apps/rails.ru +3 -1
- data/apps/repro.ru +1 -1
- data/apps/tmp/calendar.sqlite3 +0 -0
- data/apps/tmp/calendar.sqlite3-shm +0 -0
- data/apps/tmp/calendar.sqlite3-wal +0 -0
- data/apps/tmp/local_secret.txt +1 -0
- data/apps/tmp/pagy-rails.sqlite3 +0 -0
- data/bin/pagy +9 -9
- data/config/pagy.rb +1 -1
- data/javascripts/pagy-module.js +1 -1
- data/javascripts/pagy.js +2 -2
- data/javascripts/pagy.min.js +2 -2
- data/javascripts/pagy.min.js.map +2 -2
- data/javascripts/pagy.mjs +1 -1
- data/lib/optimist.rb +1 -1
- data/lib/pagy/calendar/day.rb +2 -2
- data/lib/pagy/calendar/month.rb +2 -2
- data/lib/pagy/calendar/quarter.rb +2 -2
- data/lib/pagy/calendar/unit.rb +106 -0
- data/lib/pagy/calendar/week.rb +2 -2
- data/lib/pagy/calendar/year.rb +2 -2
- data/lib/pagy/calendar.rb +54 -97
- data/lib/pagy/extras/calendar.rb +34 -4
- data/lib/pagy/extras/i18n.rb +1 -1
- data/lib/pagy/extras/js_tools.rb +1 -1
- data/lib/pagy/extras/metadata.rb +5 -1
- data/lib/pagy/extras/overflow.rb +3 -2
- data/lib/pagy/frontend.rb +8 -5
- data/lib/pagy.rb +2 -3
- data/locales/ar.yml +1 -1
- data/locales/be.yml +1 -1
- data/locales/bg.yml +1 -1
- data/locales/bs.yml +1 -1
- data/locales/ca.yml +4 -6
- data/locales/ckb.yml +1 -1
- data/locales/cs.yml +1 -1
- data/locales/da.yml +1 -1
- data/locales/de.yml +1 -1
- data/locales/en.yml +1 -1
- data/locales/es.yml +1 -1
- data/locales/fr.yml +1 -1
- data/locales/hr.yml +1 -1
- data/locales/id.yml +1 -1
- data/locales/it.yml +1 -1
- data/locales/ja.yml +1 -1
- data/locales/km.yml +1 -1
- data/locales/ko.yml +1 -1
- data/locales/nb.yml +1 -1
- data/locales/nl.yml +1 -1
- data/locales/nn.yml +1 -1
- data/locales/pl.yml +1 -1
- data/locales/pt-BR.yml +1 -1
- data/locales/pt.yml +1 -1
- data/locales/ru.yml +1 -1
- data/locales/sr.yml +1 -1
- data/locales/sv-SE.yml +1 -1
- data/locales/sv.yml +1 -1
- data/locales/sw.yml +1 -1
- data/locales/ta.yml +1 -1
- data/locales/tr.yml +1 -1
- data/locales/uk.yml +1 -1
- data/locales/vi.yml +1 -1
- data/locales/zh-CN.yml +1 -1
- data/locales/zh-HK.yml +1 -1
- data/locales/zh-TW.yml +1 -1
- metadata +8 -3
- data/lib/pagy/calendar/helper.rb +0 -65
data/lib/pagy/extras/metadata.rb
CHANGED
@@ -17,7 +17,11 @@ class Pagy # :nodoc:
|
|
17
17
|
def pagy_metadata(pagy, absolute: nil)
|
18
18
|
scaffold_url = pagy_url_for(pagy, PAGE_TOKEN, absolute:)
|
19
19
|
{}.tap do |metadata|
|
20
|
-
keys = defined?(Calendar) && pagy.is_a?(Calendar)
|
20
|
+
keys = if defined?(Calendar::Unit) && pagy.is_a?(Calendar::Unit)
|
21
|
+
pagy.vars[:metadata] - %i[count items]
|
22
|
+
else
|
23
|
+
pagy.vars[:metadata]
|
24
|
+
end
|
21
25
|
keys.each do |key|
|
22
26
|
metadata[key] = case key
|
23
27
|
when :scaffold_url then scaffold_url
|
data/lib/pagy/extras/overflow.rb
CHANGED
@@ -28,7 +28,8 @@ class Pagy # :nodoc:
|
|
28
28
|
@vars[:page] = requested_page # restore the requested page
|
29
29
|
when :empty_page
|
30
30
|
@offset = @items = @in = @from = @to = 0 # vars relative to the actual page
|
31
|
-
if defined?(Calendar)
|
31
|
+
if defined?(Calendar::Unit) \
|
32
|
+
&& is_a?(Calendar::Unit) # only for Calendar::Units instances
|
32
33
|
edge = @order == :asc ? @final : @initial # get the edge of the overflow side (neat, but any time would do)
|
33
34
|
@from = @to = edge # set both to the edge utc time (a >=&&< query will get no records)
|
34
35
|
end
|
@@ -51,7 +52,7 @@ class Pagy # :nodoc:
|
|
51
52
|
end
|
52
53
|
end
|
53
54
|
Pagy.prepend PagyOverride
|
54
|
-
Pagy::Calendar.prepend PagyOverride if defined?(Calendar)
|
55
|
+
Pagy::Calendar::Unit.prepend PagyOverride if defined?(Calendar::Unit)
|
55
56
|
|
56
57
|
# Support for Pagy::Countless class
|
57
58
|
module CountlessOverride
|
data/lib/pagy/frontend.rb
CHANGED
@@ -20,7 +20,7 @@ class Pagy
|
|
20
20
|
a = pagy_anchor(pagy)
|
21
21
|
|
22
22
|
html = %(<nav#{id} class="pagy nav" #{nav_aria_label(pagy, aria_label:)}>#{
|
23
|
-
|
23
|
+
prev_a(pagy, a)})
|
24
24
|
pagy.series(**vars).each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
|
25
25
|
html << case item
|
26
26
|
when Integer
|
@@ -40,9 +40,12 @@ class Pagy
|
|
40
40
|
def pagy_info(pagy, id: nil, item_name: nil)
|
41
41
|
id = %( id="#{id}") if id
|
42
42
|
p_count = pagy.count
|
43
|
-
key = if
|
44
|
-
|
45
|
-
|
43
|
+
key = if p_count.zero?
|
44
|
+
'pagy.info.no_items'
|
45
|
+
elsif pagy.pages == 1
|
46
|
+
'pagy.info.single_page'
|
47
|
+
else
|
48
|
+
'pagy.info.multiple_pages'
|
46
49
|
end
|
47
50
|
|
48
51
|
%(<span#{id} class="pagy info">#{
|
@@ -51,7 +54,7 @@ class Pagy
|
|
51
54
|
}</span>)
|
52
55
|
end
|
53
56
|
|
54
|
-
# Return a performance optimized lambda to generate the
|
57
|
+
# Return a performance optimized lambda to generate the HTML anchor element (a tag)
|
55
58
|
# Benchmarked on a 20 link nav: it is ~22x faster and uses ~18x less memory than rails' link_to
|
56
59
|
def pagy_anchor(pagy)
|
57
60
|
a_string = pagy.vars[:anchor_string]
|
data/lib/pagy.rb
CHANGED
@@ -5,19 +5,18 @@ require 'pathname'
|
|
5
5
|
|
6
6
|
# Core class
|
7
7
|
class Pagy
|
8
|
-
VERSION = '8.
|
8
|
+
VERSION = '8.5.0'
|
9
9
|
|
10
10
|
# Gem root pathname to get the path of Pagy files stylesheets, javascripts, apps, locales, etc.
|
11
11
|
def self.root
|
12
12
|
@root ||= Pathname.new(__dir__).parent.freeze
|
13
13
|
end
|
14
14
|
|
15
|
-
# Core
|
15
|
+
# Core default: constant for easy access, but mutable for customizable defaults
|
16
16
|
DEFAULT = { page: 1, # rubocop:disable Style/MutableConstant
|
17
17
|
items: 20,
|
18
18
|
outset: 0,
|
19
19
|
size: 7,
|
20
|
-
cycle: false,
|
21
20
|
count_args: [:all], # AR friendly
|
22
21
|
page_param: :page }
|
23
22
|
|
data/locales/ar.yml
CHANGED
data/locales/be.yml
CHANGED
data/locales/bg.yml
CHANGED
data/locales/bs.yml
CHANGED
data/locales/ca.yml
CHANGED
@@ -1,12 +1,10 @@
|
|
1
|
-
# :one_other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/pagy/i18n.rb)
|
1
|
+
# :one_other pluralization (see https://github.com/ddnexus/pagy/blob/master/gem/lib/pagy/i18n.rb)
|
2
2
|
ca:
|
3
3
|
pagy:
|
4
4
|
aria_label:
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
# one: ""
|
9
|
-
# other: ""
|
5
|
+
nav:
|
6
|
+
one: "Pàgina"
|
7
|
+
other: "Pàgines"
|
10
8
|
prev: "Anterior"
|
11
9
|
next: "Següent"
|
12
10
|
prev: "<"
|
data/locales/ckb.yml
CHANGED
data/locales/cs.yml
CHANGED
data/locales/da.yml
CHANGED
data/locales/de.yml
CHANGED
data/locales/en.yml
CHANGED
data/locales/es.yml
CHANGED
data/locales/fr.yml
CHANGED
data/locales/hr.yml
CHANGED
data/locales/id.yml
CHANGED
data/locales/it.yml
CHANGED
data/locales/ja.yml
CHANGED
data/locales/km.yml
CHANGED
data/locales/ko.yml
CHANGED
data/locales/nb.yml
CHANGED
data/locales/nl.yml
CHANGED
data/locales/nn.yml
CHANGED
data/locales/pl.yml
CHANGED
data/locales/pt-BR.yml
CHANGED
data/locales/pt.yml
CHANGED
data/locales/ru.yml
CHANGED
data/locales/sr.yml
CHANGED
data/locales/sv-SE.yml
CHANGED
data/locales/sv.yml
CHANGED
data/locales/sw.yml
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# :one_other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/pagy/i18n.rb)
|
1
|
+
# :one_other pluralization (see https://github.com/ddnexus/pagy/blob/master/gem/lib/pagy/i18n.rb)
|
2
2
|
sw:
|
3
3
|
pagy:
|
4
4
|
# please add a comment in the https://github.com/ddnexus/pagy/issues/603
|
data/locales/ta.yml
CHANGED
data/locales/tr.yml
CHANGED
data/locales/uk.yml
CHANGED
data/locales/vi.yml
CHANGED
data/locales/zh-CN.yml
CHANGED
data/locales/zh-HK.yml
CHANGED
data/locales/zh-TW.yml
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pagy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.
|
4
|
+
version: 8.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Domizio Demichelis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06-
|
11
|
+
date: 2024-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Agnostic pagination in plain ruby. It does it all. Better.
|
14
14
|
email:
|
@@ -23,6 +23,11 @@ files:
|
|
23
23
|
- apps/demo.ru
|
24
24
|
- apps/rails.ru
|
25
25
|
- apps/repro.ru
|
26
|
+
- apps/tmp/calendar.sqlite3
|
27
|
+
- apps/tmp/calendar.sqlite3-shm
|
28
|
+
- apps/tmp/calendar.sqlite3-wal
|
29
|
+
- apps/tmp/local_secret.txt
|
30
|
+
- apps/tmp/pagy-rails.sqlite3
|
26
31
|
- bin/pagy
|
27
32
|
- config/pagy.rb
|
28
33
|
- javascripts/pagy-module.js
|
@@ -36,9 +41,9 @@ files:
|
|
36
41
|
- lib/pagy/backend.rb
|
37
42
|
- lib/pagy/calendar.rb
|
38
43
|
- lib/pagy/calendar/day.rb
|
39
|
-
- lib/pagy/calendar/helper.rb
|
40
44
|
- lib/pagy/calendar/month.rb
|
41
45
|
- lib/pagy/calendar/quarter.rb
|
46
|
+
- lib/pagy/calendar/unit.rb
|
42
47
|
- lib/pagy/calendar/week.rb
|
43
48
|
- lib/pagy/calendar/year.rb
|
44
49
|
- lib/pagy/console.rb
|
data/lib/pagy/calendar/helper.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Pagy # :nodoc:
|
4
|
-
class Calendar # :nodoc:
|
5
|
-
# Initializes the calendar objects, reducing complexity in the extra
|
6
|
-
# The returned calendar is a simple hash of units/objects
|
7
|
-
class Helper < Hash
|
8
|
-
class << self
|
9
|
-
private
|
10
|
-
|
11
|
-
def init(conf, period, params)
|
12
|
-
new.send(:init, conf, period, params)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
# Create the calendar
|
19
|
-
def init(conf, period, params)
|
20
|
-
@conf = Marshal.load(Marshal.dump(conf)) # store a copy
|
21
|
-
@units = Calendar::UNITS & @conf.keys # get the units in time length desc order
|
22
|
-
raise ArgumentError, 'no calendar unit found in pagy_calendar @configuration' if @units.empty?
|
23
|
-
|
24
|
-
@period = period
|
25
|
-
@params = params
|
26
|
-
@page_param = conf[:pagy][:page_param] || DEFAULT[:page_param]
|
27
|
-
@units.each do |unit| # set all the :page_param vars for later deletion
|
28
|
-
unit_page_param = :"#{unit}_#{@page_param}"
|
29
|
-
conf[unit][:page_param] = unit_page_param
|
30
|
-
conf[unit][:page] = @params[unit_page_param]
|
31
|
-
end
|
32
|
-
calendar = {}
|
33
|
-
object = nil
|
34
|
-
@units.each_with_index do |unit, index|
|
35
|
-
params_to_delete = @units[(index + 1), @units.size].map { |sub| conf[sub][:page_param] } + [@page_param]
|
36
|
-
conf[unit][:params] = lambda { |up| up.except(*params_to_delete.map(&:to_s)) } # rubocop:disable Style/Lambda
|
37
|
-
conf[unit][:period] = object&.send(:active_period) || @period
|
38
|
-
calendar[unit] = object = Calendar.send(:create, unit, conf[unit])
|
39
|
-
end
|
40
|
-
[replace(calendar), object.from, object.to]
|
41
|
-
end
|
42
|
-
|
43
|
-
# Return the calendar object at time
|
44
|
-
def calendar_at(time, **opts)
|
45
|
-
conf = Marshal.load(Marshal.dump(@conf))
|
46
|
-
page_params = {}
|
47
|
-
@units.inject(nil) do |object, unit|
|
48
|
-
conf[unit][:period] = object&.send(:active_period) || @period
|
49
|
-
conf[unit][:page] = page_params[:"#{unit}_#{@page_param}"] \
|
50
|
-
= Calendar.send(:create, unit, conf[unit]).send(:page_at, time, **opts)
|
51
|
-
conf[unit][:params] ||= {}
|
52
|
-
conf[unit][:params].merge!(page_params)
|
53
|
-
Calendar.send(:create, unit, conf[unit])
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
public
|
58
|
-
|
59
|
-
# Return the current time of the smallest time unit shown
|
60
|
-
def showtime
|
61
|
-
self[@units.last].from
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|