diff --git a/.github/ISSUE_TEMPLATE/Code.yml b/.github/ISSUE_TEMPLATE/Code.yml
index aad805a7b..c56b54558 100644
--- a/.github/ISSUE_TEMPLATE/Code.yml
+++ b/.github/ISSUE_TEMPLATE/Code.yml
@@ -19,7 +19,7 @@ body:
attributes:
label: 👀 Before submitting...
options:
- - label: I upgraded to pagy version 9.2.1
+ - label: I upgraded to pagy version 9.2.2
required: true
- label: I searched through the [Documentation](https://ddnexus.github.io/pagy/)
required: true
diff --git a/.github/latest_release_body.md b/.github/latest_release_body.md
index ff70dfae8..5f8deb029 100644
--- a/.github/latest_release_body.md
+++ b/.github/latest_release_body.md
@@ -6,14 +6,12 @@
- See the [Changelog](https://ddnexus.github.io/pagy/changelog) for possible breaking changes
-### Changes in 9.2.1
+### Changes in 9.2.2
-- Improve bin/pagy to dynamically find apps and descriptions
-- Apps refactoring:
- - Update rails to 8.0
- - Replace rails AR keyset apps with sinatra apps
- - Improve consistency
+- Replace inline templates with template block in sinatra apps
+- Replace the rails calendar app with a sinatra app
+- Add PagyApps::INDEX
[CHANGELOG](https://ddnexus.github.io/pagy/changelog)
diff --git a/.idea/runConfigurations/Rubocop_Autocorrect.xml b/.idea/runConfigurations/Rubocop_Autocorrect.xml
index 3977d72d3..b93dc8910 100644
--- a/.idea/runConfigurations/Rubocop_Autocorrect.xml
+++ b/.idea/runConfigurations/Rubocop_Autocorrect.xml
@@ -9,10 +9,14 @@
-
+
+
+
+
+
-
-
+
+
@@ -20,4 +24,4 @@
-
+
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7f46d1c5f..db7cae6bd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,6 +23,12 @@ If you upgrade from version `< 9.0.0` see the following:
- `:after_latest` keyset variable: use `:filter_newest`
+## Version 9.2.2
+
+- Replace inline templates with template block in sinatra apps
+- Replace the rails calendar app with a sinatra app
+- Add PagyApps::INDEX
+
## Version 9.2.1
- Improve bin/pagy to dynamically find apps and descriptions
diff --git a/Gemfile b/Gemfile
index 326050dc3..478f369b4 100644
--- a/Gemfile
+++ b/Gemfile
@@ -33,7 +33,6 @@ group :playground do
gem 'rouge'
gem 'sequel'
gem 'sinatra'
- gem 'sinatra-contrib'
gem 'sqlite3'
end
diff --git a/Gemfile.lock b/Gemfile.lock
index 0db0e8891..ad1512231 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: gem
specs:
- pagy (9.2.1)
+ pagy (9.2.2)
GEM
remote: https://rubygems.org/
@@ -150,7 +150,6 @@ GEM
builder
minitest (>= 5.0)
ruby-progressbar
- multi_json (1.15.0)
mustermann (3.0.3)
ruby2_keywords (~> 0.0.1)
mutex_m (0.2.0)
@@ -242,7 +241,7 @@ GEM
rematch (3.1.0)
rerun (0.14.0)
listen (~> 3.0)
- rouge (4.4.0)
+ rouge (4.5.0)
rubocop (1.68.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
@@ -282,12 +281,6 @@ GEM
rack-protection (= 4.0.0)
rack-session (>= 2.0.0, < 3)
tilt (~> 2.0)
- sinatra-contrib (4.0.0)
- multi_json (>= 0.0.2)
- mustermann (~> 3.0)
- rack-protection (= 4.0.0)
- sinatra (= 4.0.0)
- tilt (~> 2.0)
sqlite3 (2.2.0-aarch64-linux-gnu)
sqlite3 (2.2.0-aarch64-linux-musl)
sqlite3 (2.2.0-arm-linux-gnu)
@@ -353,7 +346,6 @@ DEPENDENCIES
sequel
simplecov
sinatra
- sinatra-contrib
sqlite3
BUNDLED WITH
diff --git a/README.md b/README.md
index bb8327a3c..1bfa77dd8 100644
--- a/README.md
+++ b/README.md
@@ -282,7 +282,7 @@ See also the [How To Page](https://ddnexus.github.io/pagy/docs/how-to)
-[ ](https://github.com/ddnexus/pagy/commits?author=ddnexus)[ ](https://github.com/ddnexus/pagy/commits?author=benkoshy)[ ](https://github.com/ddnexus/pagy/commits?author=grosser)[ ](https://github.com/ddnexus/pagy/commits?author=Earlopain)[ ](https://github.com/ddnexus/pagy/commits?author=workgena)[ ](https://github.com/ddnexus/pagy/commits?author=espen)[ ](https://github.com/ddnexus/pagy/commits?author=enzinia)[ ](https://github.com/ddnexus/pagy/commits?author=sunny)[ ](https://github.com/ddnexus/pagy/commits?author=molfar)[ ](https://github.com/ddnexus/pagy/commits?author=bquorning)[ ](https://github.com/ddnexus/pagy/commits?author=djpremier)[ ](https://github.com/ddnexus/pagy/commits?author=747)[ ](https://github.com/ddnexus/pagy/commits?author=tersor)[ ](https://github.com/ddnexus/pagy/commits?author=thomasklemm)[ ](https://github.com/ddnexus/pagy/commits?author=gamafranco)[ ](https://github.com/ddnexus/pagy/commits?author=tiagotex)[ ](https://github.com/ddnexus/pagy/commits?author=wimdavies)[ ](https://github.com/ddnexus/pagy/commits?author=renshuki)[ ](https://github.com/ddnexus/pagy/commits?author=berniechiu)[ ](https://github.com/ddnexus/pagy/commits?author=ashmaroli)[ ](https://github.com/ddnexus/pagy/commits?author=cseelus)[ ](https://github.com/ddnexus/pagy/commits?author=sabljak)[ ](https://github.com/ddnexus/pagy/commits?author=petergoldstein)[ ](https://github.com/ddnexus/pagy/commits?author=rainerborene)[ ](https://github.com/ddnexus/pagy/commits?author=rbngzlv)[ ](https://github.com/ddnexus/pagy/commits?author=simonneutert)[ ](https://github.com/ddnexus/pagy/commits?author=artplan1)[ ](https://github.com/ddnexus/pagy/commits?author=serghost)[ ](https://github.com/ddnexus/pagy/commits?author=Tolchi)[ ](https://github.com/ddnexus/pagy/commits?author=rogermarlow)[ ](https://github.com/ddnexus/pagy/commits?author=yenshirak)[ ](https://github.com/ddnexus/pagy/commits?author=rafaelmontas)[ ](https://github.com/ddnexus/pagy/commits?author=rafaeelaudibert)[ ](https://github.com/ddnexus/pagy/commits?author=pedrocarmona)[ ](https://github.com/ddnexus/pagy/commits?author=olleolleolle)[ ](https://github.com/ddnexus/pagy/commits?author=olieidel)[ ](https://github.com/ddnexus/pagy/commits?author=okuramasafumi)[ ](https://github.com/ddnexus/pagy/commits?author=WilliamHorel)[ ](https://github.com/ddnexus/pagy/commits?author=woller)[ ](https://github.com/ddnexus/pagy/commits?author=sk8higher)[ ](https://github.com/ddnexus/pagy/commits?author=muhammadnawzad)[ ](https://github.com/ddnexus/pagy/commits?author=ronald)[ ](https://github.com/ddnexus/pagy/commits?author=achmiral)[ ](https://github.com/ddnexus/pagy/commits?author=mauro-ni)[ ](https://github.com/ddnexus/pagy/commits?author=borama)[ ](https://github.com/ddnexus/pagy/commits?author=creativetags)[ ](https://github.com/ddnexus/pagy/commits?author=mcary)[ ](https://github.com/ddnexus/pagy/commits?author=marckohlbrugge)[ ](https://github.com/ddnexus/pagy/commits?author=fluser)[ ](https://github.com/ddnexus/pagy/commits?author=maful)[ ](https://github.com/ddnexus/pagy/commits?author=AngelGuerra)[ ](https://github.com/ddnexus/pagy/commits?author=tr4b4nt)[ ](https://github.com/ddnexus/pagy/commits?author=tiejianluo)[ ](https://github.com/ddnexus/pagy/commits?author=szTheory)[ ](https://github.com/ddnexus/pagy/commits?author=smoothdvd)[ ](https://github.com/ddnexus/pagy/commits?author=rhodes-david)[ ](https://github.com/ddnexus/pagy/commits?author=radinreth)[ ](https://github.com/ddnexus/pagy/commits?author=pranavbabu)[ ](https://github.com/ddnexus/pagy/commits?author=okliv)[ ](https://github.com/ddnexus/pagy/commits?author=nedimdz)[ ](https://github.com/ddnexus/pagy/commits?author=msdundar)[ ](https://github.com/ddnexus/pagy/commits?author=m-abdurrehman)[ ](https://github.com/ddnexus/pagy/commits?author=dwieringa)[ ](https://github.com/ddnexus/pagy/commits?author=jyuvaraj03)[ ](https://github.com/ddnexus/pagy/commits?author=YutoYasunaga)[ ](https://github.com/ddnexus/pagy/commits?author=iamyujinwon)[ ](https://github.com/ddnexus/pagy/commits?author=yhk1038)[ ](https://github.com/ddnexus/pagy/commits?author=ya-s-u)[ ](https://github.com/ddnexus/pagy/commits?author=yshmarov)[ ](https://github.com/ddnexus/pagy/commits?author=thattimc)[ ](https://github.com/ddnexus/pagy/commits?author=thomaschauffour)[ ](https://github.com/ddnexus/pagy/commits?author=snkashis)[ ](https://github.com/ddnexus/pagy/commits?author=sliminas)[ ](https://github.com/ddnexus/pagy/commits?author=LuukvH)[ ](https://github.com/ddnexus/pagy/commits?author=Federico-G)[ ](https://github.com/ddnexus/pagy/commits?author=egimenos)[ ](https://github.com/ddnexus/pagy/commits?author=elliotlarson)[ ](https://github.com/ddnexus/pagy/commits?author=hungdiep97)[ ](https://github.com/ddnexus/pagy/commits?author=davidwessman)[ ](https://github.com/ddnexus/pagy/commits?author=david-a-wheeler)[ ](https://github.com/ddnexus/pagy/commits?author=daniel-rikowski)[ ](https://github.com/ddnexus/pagy/commits?author=connie-feng)[ ](https://github.com/ddnexus/pagy/commits?author=MrMoins)[ ](https://github.com/ddnexus/pagy/commits?author=excid3)[ ](https://github.com/ddnexus/pagy/commits?author=cellvinchung)[ ](https://github.com/ddnexus/pagy/commits?author=brunoocasali)[ ](https://github.com/ddnexus/pagy/commits?author=branson-simplethread)[ ](https://github.com/ddnexus/pagy/commits?author=BrandonKlotz)[ ](https://github.com/ddnexus/pagy/commits?author=benjaminwols)[ ](https://github.com/ddnexus/pagy/commits?author=Atul9)[ ](https://github.com/ddnexus/pagy/commits?author=amenon)[ ](https://github.com/ddnexus/pagy/commits?author=artinboghosian)[ ](https://github.com/ddnexus/pagy/commits?author=antonzaharia)[ ](https://github.com/ddnexus/pagy/commits?author=PyrinAndrii)[ ](https://github.com/ddnexus/pagy/commits?author=andrew)[ ](https://github.com/ddnexus/pagy/commits?author=AliOsm)[ ](https://github.com/ddnexus/pagy/commits?author=AbelToy)[ ](https://github.com/ddnexus/pagy/commits?author=loed-idzinga)[ ](https://github.com/ddnexus/pagy/commits?author=epeirce)[ ](https://github.com/ddnexus/pagy/commits?author=kobusjoubert)
+[ ](https://github.com/ddnexus/pagy/commits?author=ddnexus)[ ](https://github.com/ddnexus/pagy/commits?author=benkoshy)[ ](https://github.com/ddnexus/pagy/commits?author=grosser)[ ](https://github.com/ddnexus/pagy/commits?author=Earlopain)[ ](https://github.com/ddnexus/pagy/commits?author=workgena)[ ](https://github.com/ddnexus/pagy/commits?author=espen)[ ](https://github.com/ddnexus/pagy/commits?author=enzinia)[ ](https://github.com/ddnexus/pagy/commits?author=sunny)[ ](https://github.com/ddnexus/pagy/commits?author=molfar)[ ](https://github.com/ddnexus/pagy/commits?author=bquorning)[ ](https://github.com/ddnexus/pagy/commits?author=djpremier)[ ](https://github.com/ddnexus/pagy/commits?author=747)[ ](https://github.com/ddnexus/pagy/commits?author=tersor)[ ](https://github.com/ddnexus/pagy/commits?author=thomasklemm)[ ](https://github.com/ddnexus/pagy/commits?author=gamafranco)[ ](https://github.com/ddnexus/pagy/commits?author=tiagotex)[ ](https://github.com/ddnexus/pagy/commits?author=wimdavies)[ ](https://github.com/ddnexus/pagy/commits?author=renshuki)[ ](https://github.com/ddnexus/pagy/commits?author=berniechiu)[ ](https://github.com/ddnexus/pagy/commits?author=ashmaroli)[ ](https://github.com/ddnexus/pagy/commits?author=cseelus)[ ](https://github.com/ddnexus/pagy/commits?author=sabljak)[ ](https://github.com/ddnexus/pagy/commits?author=petergoldstein)[ ](https://github.com/ddnexus/pagy/commits?author=rainerborene)[ ](https://github.com/ddnexus/pagy/commits?author=rbngzlv)[ ](https://github.com/ddnexus/pagy/commits?author=simonneutert)[ ](https://github.com/ddnexus/pagy/commits?author=artplan1)[ ](https://github.com/ddnexus/pagy/commits?author=serghost)[ ](https://github.com/ddnexus/pagy/commits?author=Tolchi)[ ](https://github.com/ddnexus/pagy/commits?author=rogermarlow)[ ](https://github.com/ddnexus/pagy/commits?author=yenshirak)[ ](https://github.com/ddnexus/pagy/commits?author=rafaelmontas)[ ](https://github.com/ddnexus/pagy/commits?author=rafaeelaudibert)[ ](https://github.com/ddnexus/pagy/commits?author=pedrocarmona)[ ](https://github.com/ddnexus/pagy/commits?author=olleolleolle)[ ](https://github.com/ddnexus/pagy/commits?author=olieidel)[ ](https://github.com/ddnexus/pagy/commits?author=okuramasafumi)[ ](https://github.com/ddnexus/pagy/commits?author=WilliamHorel)[ ](https://github.com/ddnexus/pagy/commits?author=woller)[ ](https://github.com/ddnexus/pagy/commits?author=sk8higher)[ ](https://github.com/ddnexus/pagy/commits?author=muhammadnawzad)[ ](https://github.com/ddnexus/pagy/commits?author=ronald)[ ](https://github.com/ddnexus/pagy/commits?author=achmiral)[ ](https://github.com/ddnexus/pagy/commits?author=mauro-ni)[ ](https://github.com/ddnexus/pagy/commits?author=borama)[ ](https://github.com/ddnexus/pagy/commits?author=creativetags)[ ](https://github.com/ddnexus/pagy/commits?author=mcary)[ ](https://github.com/ddnexus/pagy/commits?author=marckohlbrugge)[ ](https://github.com/ddnexus/pagy/commits?author=fluser)[ ](https://github.com/ddnexus/pagy/commits?author=maful)[ ](https://github.com/ddnexus/pagy/commits?author=AngelGuerra)[ ](https://github.com/ddnexus/pagy/commits?author=tr4b4nt)[ ](https://github.com/ddnexus/pagy/commits?author=tiejianluo)[ ](https://github.com/ddnexus/pagy/commits?author=szTheory)[ ](https://github.com/ddnexus/pagy/commits?author=smoothdvd)[ ](https://github.com/ddnexus/pagy/commits?author=rhodes-david)[ ](https://github.com/ddnexus/pagy/commits?author=radinreth)[ ](https://github.com/ddnexus/pagy/commits?author=pranavbabu)[ ](https://github.com/ddnexus/pagy/commits?author=okliv)[ ](https://github.com/ddnexus/pagy/commits?author=nedimdz)[ ](https://github.com/ddnexus/pagy/commits?author=msdundar)[ ](https://github.com/ddnexus/pagy/commits?author=m-abdurrehman)[ ](https://github.com/ddnexus/pagy/commits?author=dwieringa)[ ](https://github.com/ddnexus/pagy/commits?author=jyuvaraj03)[ ](https://github.com/ddnexus/pagy/commits?author=YutoYasunaga)[ ](https://github.com/ddnexus/pagy/commits?author=iamyujinwon)[ ](https://github.com/ddnexus/pagy/commits?author=yhk1038)[ ](https://github.com/ddnexus/pagy/commits?author=ya-s-u)[ ](https://github.com/ddnexus/pagy/commits?author=yshmarov)[ ](https://github.com/ddnexus/pagy/commits?author=thattimc)[ ](https://github.com/ddnexus/pagy/commits?author=thomaschauffour)[ ](https://github.com/ddnexus/pagy/commits?author=snkashis)[ ](https://github.com/ddnexus/pagy/commits?author=sliminas)[ ](https://github.com/ddnexus/pagy/commits?author=LuukvH)[ ](https://github.com/ddnexus/pagy/commits?author=Federico-G)[ ](https://github.com/ddnexus/pagy/commits?author=egimenos)[ ](https://github.com/ddnexus/pagy/commits?author=elliotlarson)[ ](https://github.com/ddnexus/pagy/commits?author=hungdiep97)[ ](https://github.com/ddnexus/pagy/commits?author=davidwessman)[ ](https://github.com/ddnexus/pagy/commits?author=david-a-wheeler)[ ](https://github.com/ddnexus/pagy/commits?author=daniel-rikowski)[ ](https://github.com/ddnexus/pagy/commits?author=connie-feng)[ ](https://github.com/ddnexus/pagy/commits?author=MrMoins)[ ](https://github.com/ddnexus/pagy/commits?author=excid3)[ ](https://github.com/ddnexus/pagy/commits?author=cellvinchung)[ ](https://github.com/ddnexus/pagy/commits?author=brunoocasali)[ ](https://github.com/ddnexus/pagy/commits?author=branson-simplethread)[ ](https://github.com/ddnexus/pagy/commits?author=BrandonKlotz)[ ](https://github.com/ddnexus/pagy/commits?author=benjaminwols)[ ](https://github.com/ddnexus/pagy/commits?author=Atul9)[ ](https://github.com/ddnexus/pagy/commits?author=amenon)[ ](https://github.com/ddnexus/pagy/commits?author=artinboghosian)[ ](https://github.com/ddnexus/pagy/commits?author=antonzaharia)[ ](https://github.com/ddnexus/pagy/commits?author=PyrinAndrii)[ ](https://github.com/ddnexus/pagy/commits?author=andrew)[ ](https://github.com/ddnexus/pagy/commits?author=AliOsm)[ ](https://github.com/ddnexus/pagy/commits?author=AbelToy)[ ](https://github.com/ddnexus/pagy/commits?author=loed-idzinga)[ ](https://github.com/ddnexus/pagy/commits?author=epeirce)[ ](https://github.com/ddnexus/pagy/commits?author=kobusjoubert)
diff --git a/e2e/snapshots.js b/e2e/snapshots.js
index 91a548616..997f346db 100644
--- a/e2e/snapshots.js
+++ b/e2e/snapshots.js
@@ -462,29 +462,29 @@ module.exports = {
},
"[calendar] Test helpers (skip true)": {
"[calendar] Test #go-to-day": {
- "1": "\n
Event #86 - 2022-03-02 23:35:41 UTC
\n
",
+ "1": "\n\n
Event #86 - 2022-03-02 23:35:41 UTC
\n\n
",
"2": "\n \n ",
"3": "\n \n ",
"4": "\n \n ",
"5": "Displaying 1 item "
},
"[calendar] Test calendar navs": {
- "1": "\n
Event #51 - 2022-01-01 19:18:06 UTC
\n
",
+ "1": "\n\n
Event #51 - 2022-01-01 19:18:06 UTC
\n\n
",
"2": "\n \n ",
"3": "\n \n ",
"4": "\n \n ",
"5": "Displaying 1 item ",
- "6": "\n
Event #106 - 2022-04-01 15:35:47 UTC
\n
",
+ "6": "\n\n
Event #106 - 2022-04-01 15:35:47 UTC
\n\n
",
"7": "\n \n ",
"8": "\n \n ",
"9": "\n \n ",
"10": "Displaying 1 item ",
- "11": "\n
",
+ "11": "\n\n
",
"12": "\n \n ",
"13": "\n \n ",
"14": "\n \n ",
"15": "No items found ",
- "16": "\n
Event #110 - 2022-04-06 10:59:32 UTC
\n
",
+ "16": "\n\n
Event #110 - 2022-04-06 10:59:32 UTC
\n\n
",
"17": "\n \n ",
"18": "\n \n ",
"19": "\n \n ",
@@ -493,29 +493,29 @@ module.exports = {
},
"[calendar] Test helpers (skip false)": {
"[calendar] Test #go-to-day": {
- "1": "\n
Event #86 - 2022-03-02 23:35:41 UTC
\n
",
+ "1": "\n\n
Event #86 - 2022-03-02 23:35:41 UTC
\n\n
",
"2": "\n \n ",
"3": "\n \n ",
"4": "\n \n ",
"5": "Displaying 1 item "
},
"[calendar] Test calendar navs": {
- "1": "\n
Event #51 - 2022-01-01 19:18:06 UTC
\n
",
+ "1": "\n\n
Event #51 - 2022-01-01 19:18:06 UTC
\n\n
",
"2": "\n \n ",
"3": "\n \n ",
"4": "\n \n ",
"5": "Displaying 1 item ",
- "6": "\n
Event #106 - 2022-04-01 15:35:47 UTC
\n
",
+ "6": "\n\n
Event #106 - 2022-04-01 15:35:47 UTC
\n\n
",
"7": "\n \n ",
"8": "\n \n ",
"9": "\n \n ",
"10": "Displaying 1 item ",
- "11": "\n
",
+ "11": "\n\n
",
"12": "\n \n ",
"13": "\n \n ",
"14": "\n \n ",
"15": "No items found ",
- "16": "\n
Event #110 - 2022-04-06 10:59:32 UTC
\n
",
+ "16": "\n\n
Event #110 - 2022-04-06 10:59:32 UTC
\n\n
",
"17": "\n \n ",
"18": "\n \n ",
"19": "\n \n ",
@@ -524,14 +524,14 @@ module.exports = {
},
"[calendar] Test app": {
"[calendar] Test #toggle": {
- "1": "\n
Event #1 - 2021-10-21 13:18:23 UTC
\n
Event #2 - 2021-10-21 23:14:50 UTC
\n
",
+ "1": "\n\n
Event #1 - 2021-10-21 13:18:23 UTC
\n\n
Event #2 - 2021-10-21 23:14:50 UTC
\n\n
",
"2": "\n \n ",
"3": "\n \n ",
"4": "\n \n ",
"5": "Displaying 2 items ",
- "6": "\n
Event #1 - 2021-10-21 13:18:23 UTC
\n
Event #2 - 2021-10-21 23:14:50 UTC
\n
Event #3 - 2021-10-23 01:06:02 UTC
\n
Event #4 - 2021-10-25 18:54:35 UTC
\n
Event #5 - 2021-10-26 02:22:17 UTC
\n
Event #6 - 2021-10-28 22:59:49 UTC
\n
Event #7 - 2021-10-30 15:02:25 UTC
\n
Event #8 - 2021-11-02 04:03:39 UTC
\n
Event #9 - 2021-11-04 22:41:23 UTC
\n
Event #10 - 2021-11-06 00:34:29 UTC
\n
Event #11 - 2021-11-06 23:56:16 UTC
\n
Event #12 - 2021-11-07 06:22:04 UTC
\n
Event #13 - 2021-11-07 19:46:08 UTC
\n
Event #14 - 2021-11-08 09:31:13 UTC
\n
Event #15 - 2021-11-09 17:22:03 UTC
\n
Event #16 - 2021-11-11 05:29:54 UTC
\n
Event #17 - 2021-11-13 09:41:04 UTC
\n
Event #18 - 2021-11-16 07:48:22 UTC
\n
Event #19 - 2021-11-16 12:43:44 UTC
\n
Event #20 - 2021-11-17 16:03:07 UTC
\n
",
+ "6": "\n\n
Event #1 - 2021-10-21 13:18:23 UTC
\n\n
Event #2 - 2021-10-21 23:14:50 UTC
\n\n
Event #3 - 2021-10-23 01:06:02 UTC
\n\n
Event #4 - 2021-10-25 18:54:35 UTC
\n\n
Event #5 - 2021-10-26 02:22:17 UTC
\n\n
Event #6 - 2021-10-28 22:59:49 UTC
\n\n
Event #7 - 2021-10-30 15:02:25 UTC
\n\n
Event #8 - 2021-11-02 04:03:39 UTC
\n\n
Event #9 - 2021-11-04 22:41:23 UTC
\n\n
Event #10 - 2021-11-06 00:34:29 UTC
\n\n
Event #11 - 2021-11-06 23:56:16 UTC
\n\n
Event #12 - 2021-11-07 06:22:04 UTC
\n\n
Event #13 - 2021-11-07 19:46:08 UTC
\n\n
Event #14 - 2021-11-08 09:31:13 UTC
\n\n
Event #15 - 2021-11-09 17:22:03 UTC
\n\n
Event #16 - 2021-11-11 05:29:54 UTC
\n\n
Event #17 - 2021-11-13 09:41:04 UTC
\n\n
Event #18 - 2021-11-16 07:48:22 UTC
\n\n
Event #19 - 2021-11-16 12:43:44 UTC
\n\n
Event #20 - 2021-11-17 16:03:07 UTC
\n\n
",
"7": "\n \n ",
- "8": "\n
Event #1 - 2021-10-21 13:18:23 UTC
\n
Event #2 - 2021-10-21 23:14:50 UTC
\n
",
+ "8": "\n\n
Event #1 - 2021-10-21 13:18:23 UTC
\n\n
Event #2 - 2021-10-21 23:14:50 UTC
\n\n
",
"9": "\n \n ",
"10": "\n \n ",
"11": "\n \n ",
diff --git a/gem/apps/calendar.ru b/gem/apps/calendar.ru
index 36b0ede3b..549b46385 100644
--- a/gem/apps/calendar.ru
+++ b/gem/apps/calendar.ru
@@ -16,7 +16,7 @@
# URL
# http://0.0.0.0:8000
-VERSION = '9.2.1'
+VERSION = '9.2.2'
# Bundle
require 'bundler/inline'
@@ -24,67 +24,23 @@ require 'bundler'
Bundler.configure
gemfile(ENV['PAGY_INSTALL_BUNDLE'] == 'true') do
source 'https://rubygems.org'
+ gem 'activerecord'
+ gem 'activesupport'
gem 'groupdate'
gem 'puma'
- gem 'rails', '~> 8.0'
+ gem 'sinatra'
gem 'sqlite3'
end
-# require 'rails/all' # too much stuff
-require 'action_controller/railtie'
-require 'active_record'
-
-OUTPUT = Rails.env.showcase? ? IO::NULL : $stdout
-
-# Rails config
-class Calendar < Rails::Application # :nodoc:
- config.root = __dir__
- config.session_store :cookie_store, key: 'cookie_store_key'
- Rails.application.credentials.secret_key_base = 'absolute_secret'
-
- config.logger = Logger.new(OUTPUT)
- Rails.logger = config.logger
-
- routes.draw do
- root to: 'events#index'
- end
-end
-
-# AR config
-dir = Rails.env.development? ? '.' : Dir.pwd # app dir in dev or pwd otherwise
-abort "ERROR: Cannot create DB files: the directory #{dir.inspect} is not writable." \
- unless File.writable?(dir)
-
# Pagy initializer
require 'pagy/extras/calendar'
require 'pagy/extras/bootstrap'
Pagy::DEFAULT.freeze
-# Groupdate initializer (https://github.com/ankane/groupdate)
-# Groupdate week_start default is :sunday, while rails and pagy default to :monday
-Groupdate.week_start = :monday
-
-# Activerecord initializer
-ActiveRecord::Base.logger = Logger.new(OUTPUT)
-ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: "#{dir}/tmp/calendar.sqlite3")
-ActiveRecord::Schema.define do
- create_table :events, force: true do |t|
- t.string :title
- t.timestamp :time
- end
-end
-
-# Models
-class Event < ActiveRecord::Base; end
-
-# Helpers
-module EventsHelper
- include Pagy::Frontend
-end
-
-# Controllers
-class EventsController < ActionController::Base
- include Rails.application.routes.url_helpers
+# Sinatra setup
+require 'sinatra/base'
+# Sinatra application
+class PagyCalendar < Sinatra::Base
include Pagy::Backend
# This method must be implemented by the application.
@@ -113,7 +69,8 @@ class EventsController < ActionController::Base
unless params[:skip_counts] == 'true'
end
- def index
+ # Root route/action
+ get '/' do
# Groupdate does not support time zones with SQLite.
# 'UTC' does not work on certain machines config (pulling the actual local time zone utc_offset)
# so for this demo we use a different zone with utc_offset 0
@@ -129,44 +86,55 @@ class EventsController < ActionController::Base
month: {},
day: {},
active: !params[:skip])
- render inline: TEMPLATE
+ erb :main
end
-end
-TEMPLATE = <<~ERB
-
-
-
-
- Pagy Calendar App
-
-
+ helpers do
+ include Pagy::Frontend
+ end
-
-
+ # Views
+ template :layout do
+ <<~ERB
+
+
+
+
+ Pagy Calendar App
+
+
-
+
+
+
+ <%= yield %>
+
+
+ ERB
+ end
+ template :main do
+ <<~ERB
Pagy Calendar App
Self-contained, standalone app implementing nested calendar pagination for year, month, day units.
@@ -174,10 +142,10 @@ TEMPLATE = <<~ERB
Please, report the following versions in any new issue.
Versions
- Ruby: <%== RUBY_VERSION %>
- Rack: <%== Rack::RELEASE %>
- Rails: <%== Rails.version %>
- Pagy: <%== Pagy::VERSION %>
+ Ruby: <%= RUBY_VERSION %>
+ Rack: <%= Rack::RELEASE %>
+ Sinatra: <%= Sinatra::VERSION %>
+ Pagy: <%= Pagy::VERSION %>
@@ -196,14 +164,14 @@ TEMPLATE = <<~ERB
<% if @calendar %>
Showtime: <%= @calendar.showtime %>
- <%== pagy_bootstrap_nav(@calendar[:year], id: "year-nav", aria_label: "Years") %>
- <%== pagy_bootstrap_nav(@calendar[:month], id: "month-nav", aria_label: "Months") %>
- <%== pagy_bootstrap_nav(@calendar[:day], id: "day-nav", aria_label: "Days") %>
+ <%= pagy_bootstrap_nav(@calendar[:year], id: "year-nav", aria_label: "Years") %>
+ <%= pagy_bootstrap_nav(@calendar[:month], id: "month-nav", aria_label: "Months") %>
+ <%= pagy_bootstrap_nav(@calendar[:day], id: "day-nav", aria_label: "Days") %>
<% end %>
- <%== pagy_info(@pagy, id: 'pagy-info') %>
+ <%= pagy_info(@pagy, id: 'pagy-info') %>
<% if @calendar %>
for <%= @calendar.showtime.strftime('%Y-%m-%d') %>
<% end %>
@@ -217,13 +185,41 @@ TEMPLATE = <<~ERB
-
<%== pagy_bootstrap_nav(@pagy, id: 'pages-nav', aria_label: 'Pages') if @pagy.pages > 1 %>
+
<%= pagy_bootstrap_nav(@pagy, id: 'pages-nav', aria_label: 'Pages') if @pagy.pages > 1 %>
-
-
-ERB
+ ERB
+ end
+end
+
+# ActiveRecord setup
+require 'active_record'
+# Log
+output = ENV['APP_ENV'].equal?('showcase') ? IO::NULL : $stdout
+ActiveRecord::Base.logger = Logger.new(output)
+# SQLite DB files
+dir = ENV['APP_ENV'].equal?('development') ? '.' : Dir.pwd # app dir in dev or pwd otherwise
+abort "ERROR: Cannot create DB files: the directory #{dir.inspect} is not writable." \
+ unless File.writable?(dir)
+# Connection
+ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: "#{dir}/tmp/pagy-calendar.sqlite3")
+
+# Groupdate initializer (https://github.com/ankane/groupdate)
+# Groupdate week_start default is :sunday, while rails and pagy default to :monday
+Groupdate.week_start = :monday
+ActiveSupport.to_time_preserves_timezone = :zone # Fix ActiveSupport deprecation
+
+ActiveRecord::Schema.define do
+ create_table :events, force: true do |t|
+ t.string :title
+ t.timestamp :time
+ end
+end
+
+# Models
+class Event < ActiveRecord::Base; end
-TIMES = <<~TIMES
+# Event times
+data = <<~DATA
2021-10-21 13:18:23 +0000
2021-10-21 23:14:50 +0000
2021-10-23 01:06:02 +0000
@@ -729,13 +725,13 @@ TIMES = <<~TIMES
2023-11-12 04:22:50 +0000
2023-11-12 08:38:58 +0000
2023-11-13 15:43:40 +0000
-TIMES
+DATA
# DB seed
events = []
-TIMES.each_line(chomp: true).with_index do |time, i|
+data.each_line(chomp: true).with_index do |time, i|
events << { title: "Event ##{i + 1}", time: }
end
Event.insert_all(events)
-run Calendar
+run PagyCalendar
diff --git a/gem/apps/demo.ru b/gem/apps/demo.ru
index 5638ede0f..d5c82107a 100644
--- a/gem/apps/demo.ru
+++ b/gem/apps/demo.ru
@@ -19,7 +19,7 @@
# URL
# http://0.0.0.0:8000
-VERSION = '9.2.1'
+VERSION = '9.2.2'
# Bundle
require 'bundler/inline'
@@ -31,7 +31,6 @@ gemfile(ENV['PAGY_INSTALL_BUNDLE'] == 'true') do
gem 'puma'
gem 'rouge'
gem 'sinatra'
- gem 'sinatra-contrib'
end
# pagy initializer
@@ -52,10 +51,6 @@ require 'sinatra/base'
# Sinatra application
class PagyDemo < Sinatra::Base
- configure do
- enable :inline_templates
- end
-
include Pagy::Backend
get '/' do
@@ -84,7 +79,7 @@ class PagyDemo < Sinatra::Base
send_file Pagy.root.join('stylesheets', params[:file])
end
- # one route/action per style
+ # One route/action per style
STYLES.each_key do |style|
prefix = STYLES[style][:prefix] || "_#{style}"
@@ -119,6 +114,260 @@ class PagyDemo < Sinatra::Base
})
end
end
+
+ # Views
+ template :layout do
+ <<~'ERB'
+
+
+
+ Pagy Demo App
+
+
+
+ <%= erb :"#{style}_head" if defined?(style) %>
+
+
+
+
+ <%= style_menu %>
+
+ <%= yield %>
+
+
+
+ ERB
+ end
+
+ template :pagy_head do
+ <<~ERB
+
+
+ ERB
+ end
+
+ template :bootstrap_head do
+ <<~ERB
+
+ ERB
+ end
+
+ template :bulma_head do
+ <<~ERB
+
+ ERB
+ end
+
+ template :tailwind_head do
+ <<~ERB
+
+
+
+ ERB
+ end
+
+ template :helpers do
+ <<~'ERB'
+ <%= style %>
+ <% extra = STYLES[style][:extra] || "#{style}" %>
+ <% css_anchor = STYLES[style][:css_anchor] %>
+
+ See the <%= extra %> extra
+ documentation
+ <% if css_anchor %>
+ and the <%= css_anchor.gsub('-', '.') %>
+ <% end %>
+ for details
+
+ Collection
+ @records: <%= @records.join(',') %>
+
+ pagy<%= prefix %>_nav Simple nav size: 5
+ <%= html = send(:"pagy#{prefix}_nav", @pagy, id: 'simple-nav', aria_label: 'Pages simple-nav', size: 5) %>
+ <%= highlight(html) %>
+
+ pagy<%= prefix %>_nav Fast nav size: 7
+ <%= html = send(:"pagy#{prefix}_nav", @pagy, id: 'nav', aria_label: 'Pages nav') %>
+ <%= highlight(html) %>
+
+ pagy<%= prefix %>_nav_js Fast nav size: 7
+ <%= html = send(:"pagy#{prefix}_nav_js", @pagy, id: 'nav-js', aria_label: 'Pages nav_js') %>
+ <%= highlight(html) %>
+
+ pagy<%= prefix %>_nav_js Responsive nav steps: {...}
(Resize the window to see)
+ <%= html = send(:"pagy#{prefix}_nav_js", @pagy, id: 'nav-js-responsive',
+ aria_label: 'Pages nav_js_responsive',
+ steps: { 0 => 5, 500 => 7, 750 => 9, 1000 => 11 }) %>
+ <%= highlight(html) %>
+
+ pagy<%= prefix %>_combo_nav_js
+ <%= html = send(:"pagy#{prefix}_combo_nav_js", @pagy, id: 'combo-nav-js', aria_label: 'Pages combo_nav_js') %>
+ <%= highlight(html) %>
+
+ pagy_info
+ <%= html = pagy_info(@pagy, id: 'pagy-info') %>
+ <%= highlight(html) %>
+
+ <% if style.match(/pagy|tailwind/) %>
+ pagy_limit_selector_js
+ <%= html = pagy_limit_selector_js(@pagy, id: 'limit-selector-js') %>
+ <%= highlight(html) %>
+
+ pagy_prev_a / pagy_next_a
+ <%= html = '' << pagy_prev_a(@pagy) << pagy_next_a(@pagy) << ' ' %>
+ <%= highlight(html) %>
+
+ pagy_prev_link / pagy_next_link Link not rendered
+ <% html = '' << (pagy_prev_link(@pagy)||'') << (pagy_next_link(@pagy)||'') << '' %>
+ <%= highlight(html) %>
+ <% end %>
+ ERB
+ end
+
+ template :template do
+ <<~ERB
+ Pagy Template Demo
+
+
+ See the
+ Custom Templates documentation.
+
+ Collection
+ @records: <%= @records.join(',') %>
+
+ Rendered ERB template
+
+ <%# We don't inline the template here, so we can highlight it more easily %>
+ <%= html = ERB.new(TEMPLATE).result(binding) %>
+ <%= highlight(TEMPLATE, format: :erb) %>
+ <%= highlight(html) %>
+ ERB
+ end
+
+ # Easier code highlighting
+ TEMPLATE = <<~ERB
+ <%# IMPORTANT: replace '<%=' with '<%==' if you run this in rails %>
+
+ <%# The a variable below is set to a lambda that generates the a tag %>
+ <%# Usage: a_tag = a.(page_number, text, classes: nil, aria_label: nil) %>
+ <% a = pagy_anchor(pagy) %>
+
+ <%# Previous page link %>
+ <% if pagy.prev %>
+ <%= a.(pagy.prev, '<', aria_label: 'Previous') %>
+ <% else %>
+ <
+ <% end %>
+ <%# Page links (series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]) %>
+ <% pagy.series.each do |item| %>
+ <% if item.is_a?(Integer) %>
+ <%= a.(item) %>
+ <% elsif item.is_a?(String) %>
+ <%= item %>
+ <% elsif item == :gap %>
+ …
+ <% end %>
+ <% end %>
+ <%# Next page link %>
+ <% if pagy.next %>
+ <%= a.(pagy.next, '>', aria_label: 'Next') %>
+ <% else %>
+ <
+ <% end %>
+
+ ERB
end
# Cheap pagy formatter for helpers output
@@ -198,240 +447,3 @@ class MockCollection < Array
end
run PagyDemo
-
-# We store the template in a constant instead of writing it inline, so we can highlight it more easily
-TEMPLATE = <<~ERB
- <%# IMPORTANT: use '<%== ... ' instead of '<%= ... ' if you run this in rails %>
-
- <%# The a variable below is set to a lambda that generates the a tag %>
- <%# Usage: a_tag = a.(page_number, text, classes: nil, aria_label: nil) %>
- <% a = pagy_anchor(pagy) %>
-
- <%# Previous page link %>
- <% if pagy.prev %>
- <%= a.(pagy.prev, '<', aria_label: 'Previous') %>
- <% else %>
- <
- <% end %>
- <%# Page links (series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]) %>
- <% pagy.series.each do |item| %>
- <% if item.is_a?(Integer) %>
- <%= a.(item) %>
- <% elsif item.is_a?(String) %>
- <%= item %>
- <% elsif item == :gap %>
- …
- <% end %>
- <% end %>
- <%# Next page link %>
- <% if pagy.next %>
- <%= a.(pagy.next, '>', aria_label: 'Next') %>
- <% else %>
- <
- <% end %>
-
-ERB
-
-__END__
-
-@@ layout
-
-
-
- Pagy Demo App
-
-
-
- <%= erb :"#{style}_head" if defined?(style) %>
-
-
-
-
- <%= style_menu %>
-
- <%= yield %>
-
-
-
-
-
-@@ pagy_head
-
-
-
-@@ bootstrap_head
-
-
-@@ bulma_head
-
-
-@@ tailwind_head
-
-
-
-
-
-@@ helpers
-<%= style %>
-<% extra = STYLES[style][:extra] || "#{style}" %>
-<% css_anchor = STYLES[style][:css_anchor] %>
-
-See the <%= extra %> extra
-documentation
-<% if css_anchor %>
- and the <%= css_anchor.gsub('-', '.') %>
-<% end %>
-for details
-
-Collection
-@records: <%= @records.join(',') %>
-
-pagy<%= prefix %>_nav Simple nav size: 5
-<%= html = send(:"pagy#{prefix}_nav", @pagy, id: 'simple-nav', aria_label: 'Pages simple-nav', size: 5) %>
-<%= highlight(html) %>
-
-pagy<%= prefix %>_nav Fast nav size: 7
-<%= html = send(:"pagy#{prefix}_nav", @pagy, id: 'nav', aria_label: 'Pages nav') %>
-<%= highlight(html) %>
-
-pagy<%= prefix %>_nav_js Fast nav size: 7
-<%= html = send(:"pagy#{prefix}_nav_js", @pagy, id: 'nav-js', aria_label: 'Pages nav_js') %>
-<%= highlight(html) %>
-
-pagy<%= prefix %>_nav_js Responsive nav steps: {...}
(Resize the window to see)
-<%= html = send(:"pagy#{prefix}_nav_js", @pagy, id: 'nav-js-responsive',
- aria_label: 'Pages nav_js_responsive',
- steps: { 0 => 5, 500 => 7, 750 => 9, 1000 => 11 }) %>
-<%= highlight(html) %>
-
-pagy<%= prefix %>_combo_nav_js
-<%= html = send(:"pagy#{prefix}_combo_nav_js", @pagy, id: 'combo-nav-js', aria_label: 'Pages combo_nav_js') %>
-<%= highlight(html) %>
-
-pagy_info
-<%= html = pagy_info(@pagy, id: 'pagy-info') %>
-<%= highlight(html) %>
-
-<% if style.match(/pagy|tailwind/) %>
-pagy_limit_selector_js
-<%= html = pagy_limit_selector_js(@pagy, id: 'limit-selector-js') %>
-<%= highlight(html) %>
-
-pagy_prev_a / pagy_next_a
-<%= html = '' << pagy_prev_a(@pagy) << pagy_next_a(@pagy) << ' ' %>
-<%= highlight(html) %>
-
-pagy_prev_link / pagy_next_link Link not rendered
-<% html = '' << (pagy_prev_link(@pagy)||'') << (pagy_next_link(@pagy)||'') << '' %>
-<%= highlight(html) %>
-<% end %>
-
-
-@@ template
-Pagy Template Demo
-
-
-See the
-Custom Templates documentation.
-
-Collection
-@records: <%= @records.join(',') %>
-
-Rendered ERB template
-
-<%# We don't inline the template here, so we can highlight it more easily %>
-<%= html = ERB.new(TEMPLATE).result(binding) %>
-<%= highlight(TEMPLATE, format: :erb) %>
-<%= highlight(html) %>
diff --git a/gem/apps/index.rb b/gem/apps/index.rb
new file mode 100644
index 000000000..6ba804c28
--- /dev/null
+++ b/gem/apps/index.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+# PagyApp module
+module PagyApps
+ # Return the hash of app name/path
+ INDEX = Dir[File.expand_path('./*.ru', __dir__)].to_h { |f| [File.basename(f, '.ru'), f] }.freeze
+end
diff --git a/gem/apps/keyset_ar.ru b/gem/apps/keyset_ar.ru
index f6b2d77f6..d80a47883 100644
--- a/gem/apps/keyset_ar.ru
+++ b/gem/apps/keyset_ar.ru
@@ -16,7 +16,7 @@
# URL
# http://0.0.0.0:8000
-VERSION = '9.2.1'
+VERSION = '9.2.2'
# Bundle
require 'bundler/inline'
@@ -27,7 +27,6 @@ gemfile(ENV['PAGY_INSTALL_BUNDLE'] == 'true') do
gem 'activerecord'
gem 'puma'
gem 'sinatra'
- gem 'sinatra-contrib'
gem 'sqlite3'
end
@@ -42,12 +41,6 @@ Pagy::DEFAULT.freeze
require 'sinatra/base'
# Sinatra application
class PagyKeyset < Sinatra::Base
- configure do
- # Templates defined in the __END__ section as @@ ...
- enable :inline_templates
- end
-
- # Controller
include Pagy::Backend
# Root route/action
get '/' do
@@ -57,7 +50,7 @@ class PagyKeyset < Sinatra::Base
@pagy, @pets = pagy_keyset(Pet.order(@order))
erb :main
end
- # Helper
+
helpers do
include Pagy::Frontend
@@ -65,6 +58,82 @@ class PagyKeyset < Sinatra::Base
{ asc: '↗', desc: '↘' }[dir]
end
end
+
+ # Views
+ template :layout do
+ <<~ERB
+
+
+
+
+ Pagy Keyset App
+
+
+
+
+ <%= yield %>
+
+
+ ERB
+ end
+
+ template :main do
+ <<~ERB
+
+
Pagy Keyset App
+
Self-contained, standalone app usable to easily reproduce any keyset related pagy issue with ActiveRecord sets.
+
Please, report the following versions in any new issue.
+
Versions
+
+ Ruby: <%= RUBY_VERSION %>
+ Rack: <%= Rack::RELEASE %>
+ Sinatra: <%= Sinatra::VERSION %>
+ Pagy: <%= Pagy::VERSION %>
+
+
+
Collection
+
+
+
+ animal <%= order_symbol(@order[:animal]) %>
+ name <%= order_symbol(@order[:name]) %>
+ birthdate <%= order_symbol(@order[:birthdate]) %>
+ id <%= order_symbol(@order[:id]) %>
+
+ <% @pets.each do |pet| %>
+
+ <%= pet.animal %>
+ <%= pet.name %>
+ <%= pet.birthdate %>
+ <%= pet.id %>
+
+ <% end %>
+
+
+
+
+ <%= pagy_next_a(@pagy, text: 'Next page >') %>
+
+
+ ERB
+ end
end
# ActiveRecord setup
@@ -90,8 +159,7 @@ end
# Models
class Pet < ActiveRecord::Base; end
-# Data
-PETS = <<~PETS
+data = <<~DATA
Luna | dog | 2018-03-10
Coco | cat | 2019-05-15
Dodo | dog | 2020-06-25
@@ -142,85 +210,14 @@ PETS = <<~PETS
Sary | bird | 2023-04-29
Rocky | bird | 2023-05-14
Coco | dog | 2023-05-27
-PETS
+DATA
# DB seed
pets = []
-PETS.each_line(chomp: true) do |pet|
+data.each_line(chomp: true) do |pet|
name, animal, birthdate = pet.split('|').map(&:strip)
pets << { name:, animal:, birthdate: }
end
Pet.insert_all(pets)
run PagyKeyset
-
-__END__
-
-@@ layout
-
-
-
-
- Pagy Keyset App
-
-
-
-
- <%= yield %>
-
-
-
-@@ main
-
-
Pagy Keyset App
-
Self-contained, standalone app usable to easily reproduce any keyset related pagy issue with ActiveRecord sets.
-
Please, report the following versions in any new issue.
-
Versions
-
- Ruby: <%= RUBY_VERSION %>
- Rack: <%= Rack::RELEASE %>
- Sinatra: <%= Sinatra::VERSION %>
- Pagy: <%= Pagy::VERSION %>
-
-
-
Collection
-
-
-
- animal <%= order_symbol(@order[:animal]) %>
- name <%= order_symbol(@order[:name]) %>
- birthdate <%= order_symbol(@order[:birthdate]) %>
- id <%= order_symbol(@order[:id]) %>
-
- <% @pets.each do |pet| %>
-
- <%= pet.animal %>
- <%= pet.name %>
- <%= pet.birthdate %>
- <%= pet.id %>
-
- <% end %>
-
-
-
-
- <%= pagy_next_a(@pagy, text: 'Next page >') %>
-
-
diff --git a/gem/apps/keyset_s.ru b/gem/apps/keyset_s.ru
index e8e6b22c4..907eb49af 100644
--- a/gem/apps/keyset_s.ru
+++ b/gem/apps/keyset_s.ru
@@ -16,7 +16,7 @@
# URL
# http://0.0.0.0:8000
-VERSION = '9.2.1'
+VERSION = '9.2.2'
# Bundle
require 'bundler/inline'
@@ -27,7 +27,6 @@ gemfile(ENV['PAGY_INSTALL_BUNDLE'] == 'true') do
gem 'puma'
gem 'sequel'
gem 'sinatra'
- gem 'sinatra-contrib'
gem 'sqlite3'
end
@@ -43,12 +42,6 @@ require 'sinatra/base'
require 'logger'
# Sinatra application
class PagyKeyset < Sinatra::Base
- configure do
- # Templates defined in the __END__ section as @@ ...
- enable :inline_templates
- end
-
- # Controller
include Pagy::Backend
# Root route/action
get '/' do
@@ -56,7 +49,7 @@ class PagyKeyset < Sinatra::Base
@pagy, @pets = pagy_keyset(Pet.order(:animal, :name, Sequel.desc(:birthdate), :id))
erb :main
end
- # Helper
+
helpers do
include Pagy::Frontend
@@ -64,6 +57,82 @@ class PagyKeyset < Sinatra::Base
{ asc: '↗', desc: '↘' }[dir]
end
end
+
+ # Views
+ template :layout do
+ <<~ERB
+
+
+
+
+ Pagy Keyset App
+
+
+
+
+ <%= yield %>
+
+
+ ERB
+ end
+
+ template :main do
+ <<~ERB
+
+
Pagy Keyset App
+
Self-contained, standalone app usable to easily reproduce any keyset related pagy issue with ActiveRecord sets.
+
Please, report the following versions in any new issue.
+
Versions
+
+ Ruby: <%= RUBY_VERSION %>
+ Rack: <%= Rack::RELEASE %>
+ Sinatra: <%= Sinatra::VERSION %>
+ Pagy: <%= Pagy::VERSION %>
+
+
+
Collection
+
+
+
+ animal <%= order_symbol(@order[:animal]) %>
+ name <%= order_symbol(@order[:name]) %>
+ birthdate <%= order_symbol(@order[:birthdate]) %>
+ id <%= order_symbol(@order[:id]) %>
+
+ <% @pets.each do |pet| %>
+
+ <%= pet.animal %>
+ <%= pet.name %>
+ <%= pet.birthdate %>
+ <%= pet.id %>
+
+ <% end %>
+
+
+
+
+ <%= pagy_next_a(@pagy, text: 'Next page >') %>
+
+
+ ERB
+ end
end
# Sequel setup
@@ -88,8 +157,7 @@ end
# Models
class Pet < Sequel::Model; end
-# Data
-PETS = <<~PETS
+data = <<~DATA
Luna | dog | 2018-03-10
Coco | cat | 2019-05-15
Dodo | dog | 2020-06-25
@@ -140,83 +208,12 @@ PETS = <<~PETS
Sary | bird | 2023-04-29
Rocky | bird | 2023-05-14
Coco | dog | 2023-05-27
-PETS
+DATA
dataset = DB[:pets]
-PETS.each_line(chomp: true) do |pet|
+data.each_line(chomp: true) do |pet|
name, animal, birthdate = pet.split('|').map(&:strip)
dataset.insert(name:, animal:, birthdate:)
end
run PagyKeyset
-
-__END__
-
-@@ layout
-
-
-
-
- Pagy Keyset App
-
-
-
-
- <%= yield %>
-
-
-
-@@ main
-
-
Pagy Keyset App
-
Self-contained, standalone app usable to easily reproduce any keyset related pagy issue with ActiveRecord sets.
-
Please, report the following versions in any new issue.
-
Versions
-
- Ruby: <%= RUBY_VERSION %>
- Rack: <%= Rack::RELEASE %>
- Sinatra: <%= Sinatra::VERSION %>
- Pagy: <%= Pagy::VERSION %>
-
-
-
Collection
-
-
-
- animal <%= order_symbol(@order[:animal]) %>
- name <%= order_symbol(@order[:name]) %>
- birthdate <%= order_symbol(@order[:birthdate]) %>
- id <%= order_symbol(@order[:id]) %>
-
- <% @pets.each do |pet| %>
-
- <%= pet.animal %>
- <%= pet.name %>
- <%= pet.birthdate %>
- <%= pet.id %>
-
- <% end %>
-
-
-
-
- <%= pagy_next_a(@pagy, text: 'Next page >') %>
-
-
diff --git a/gem/apps/rails.ru b/gem/apps/rails.ru
index 384548a58..6102c21a1 100644
--- a/gem/apps/rails.ru
+++ b/gem/apps/rails.ru
@@ -16,7 +16,7 @@
# URL
# http://0.0.0.0:8000
-VERSION = '9.2.1'
+VERSION = '9.2.2'
# Gemfile
require 'bundler/inline'
diff --git a/gem/apps/repro.ru b/gem/apps/repro.ru
index ed15bd07d..dd2419795 100644
--- a/gem/apps/repro.ru
+++ b/gem/apps/repro.ru
@@ -16,7 +16,7 @@
# URL
# http://0.0.0.0:8000
-VERSION = '9.2.1'
+VERSION = '9.2.2'
# Bundle
require 'bundler/inline'
@@ -27,7 +27,6 @@ gemfile(ENV['PAGY_INSTALL_BUNDLE'] == 'true') do
gem 'oj'
gem 'puma'
gem 'sinatra'
- gem 'sinatra-contrib'
end
# Edit this section adding/removing the extras and Pagy::DEFAULT as needed
@@ -42,9 +41,6 @@ Pagy::DEFAULT.freeze
require 'sinatra/base'
# Sinatra application
class PagyRepro < Sinatra::Base
- configure do
- enable :inline_templates
- end
include Pagy::Backend
get('/javascripts/:file') do
@@ -61,12 +57,103 @@ class PagyRepro < Sinatra::Base
get '/' do
collection = MockCollection.new
@pagy, @records = pagy(collection)
- erb :main # template available in the __END__ section as @@ main
+ erb :main
end
+
# Edit this section adding your own helpers as needed
helpers do
include Pagy::Frontend
end
+
+ # Views
+ template :layout do
+ <<~ERB
+
+
+
+
+ Pagy Repro App
+
+
+
+
+
+
+ <%= yield %>
+
+
+ ERB
+ end
+
+ template :main do
+ <<~ERB
+
+
Pagy Repro App
+
Self-contained, standalone app usable to easily reproduce any pagy issue.
+
Please, report the following versions in any new issue.
+
Versions
+
+ Ruby: <%= RUBY_VERSION %>
+ Rack: <%= Rack::RELEASE %>
+ Sinatra: <%= Sinatra::VERSION %>
+ Pagy: <%= Pagy::VERSION %>
+
+
+ Collection
+ @records: <%= @records.join(',') %>
+
+
+
+
pagy_nav
+ <%= pagy_nav(@pagy, id: 'nav', aria_label: 'Pages nav') %>
+
+
pagy_nav_js
+ <%= pagy_nav_js(@pagy, id: 'nav-js', aria_label: 'Pages nav_js') %>
+
+
pagy_nav_js
+ <%= pagy_nav_js(@pagy, id: 'nav-js-responsive', aria_label: 'Pages nav_js_responsove',
+ steps: { 0 => 5, 500 => 7, 750 => 9, 1000 => 11 }) %>
+
+
pagy_combo_nav_js
+ <%= pagy_combo_nav_js(@pagy, id: 'combo-nav-js', aria_label: 'Pages combo_nav_js') %>
+
+
pagy_limit_selector_js
+ <%= pagy_limit_selector_js(@pagy, id: 'limit-selector-js') %>
+
+
pagy_info
+ <%= pagy_info(@pagy, id: 'pagy-info') %>
+
+ ERB
+ end
end
# Simple array-based collection that acts as a standard DB collection.
@@ -93,88 +180,3 @@ class MockCollection < Array
end
run PagyRepro
-
-__END__
-
-@@ layout
-
-
-
-
- Pagy Repro App
-
-
-
-
-
-
- <%= yield %>
-
-
-
-@@ main
-
-
Pagy Repro App
-
Self-contained, standalone app usable to easily reproduce any pagy issue.
-
Please, report the following versions in any new issue.
-
Versions
-
- Ruby: <%= RUBY_VERSION %>
- Rack: <%= Rack::RELEASE %>
- Sinatra: <%= Sinatra::VERSION %>
- Pagy: <%= Pagy::VERSION %>
-
-
- Collection
- @records: <%= @records.join(',') %>
-
-
-
-
pagy_nav
- <%= pagy_nav(@pagy, id: 'nav', aria_label: 'Pages nav') %>
-
-
pagy_nav_js
- <%= pagy_nav_js(@pagy, id: 'nav-js', aria_label: 'Pages nav_js') %>
-
-
pagy_nav_js
- <%= pagy_nav_js(@pagy, id: 'nav-js-responsive', aria_label: 'Pages nav_js_responsove',
- steps: { 0 => 5, 500 => 7, 750 => 9, 1000 => 11 }) %>
-
-
pagy_combo_nav_js
- <%= pagy_combo_nav_js(@pagy, id: 'combo-nav-js', aria_label: 'Pages combo_nav_js') %>
-
-
pagy_limit_selector_js
- <%= pagy_limit_selector_js(@pagy, id: 'limit-selector-js') %>
-
-
pagy_info
- <%= pagy_info(@pagy, id: 'pagy-info') %>
-
diff --git a/gem/bin/pagy b/gem/bin/pagy
index a70cf6bb7..1ff20b592 100755
--- a/gem/bin/pagy
+++ b/gem/bin/pagy
@@ -1,14 +1,14 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
-VERSION = '9.2.1'
+VERSION = '9.2.2'
LINUX = RbConfig::CONFIG['host_os'].include?('linux')
HOST = '0.0.0.0'
PORT = '8000'
require_relative '../lib/optimist'
-
-apps = Dir[File.expand_path('../apps/*.ru', __dir__)].to_h { |f| [File.basename(f, '.ru'), f] }
+require_relative '../apps/index'
+apps = PagyApps::INDEX
opts = Optimist.options do
text <<~HEAD
Pagy #{VERSION} (https://ddnexus.github.io/pagy/playground)
diff --git a/gem/config/pagy.rb b/gem/config/pagy.rb
index b18248ede..bc2019dff 100644
--- a/gem/config/pagy.rb
+++ b/gem/config/pagy.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-# Pagy initializer file (9.2.1)
+# Pagy initializer file (9.2.2)
# Customize only what you really need and notice that the core Pagy works also without any of the following lines.
# Should you just cherry pick part of this file, please maintain the require-order of the extras
diff --git a/gem/javascripts/pagy.min.js b/gem/javascripts/pagy.min.js
index 542becde1..b581ab442 100644
--- a/gem/javascripts/pagy.min.js
+++ b/gem/javascripts/pagy.min.js
@@ -1,4 +1,4 @@
-window.Pagy=(()=>{const j=new ResizeObserver((B)=>B.forEach((D)=>D.target.querySelectorAll(".pagy-rjs").forEach((E)=>E.pagyRender()))),x=(B,[D,E,z,G])=>{const F=B.parentElement??B,K=Object.keys(E).map((H)=>parseInt(H)).sort((H,M)=>M-H);let L=-1;const T=(H,M,R)=>H.replace(/__pagy_page__/g,M).replace(/__pagy_label__/g,R);if((B.pagyRender=function(){const H=K.find((Q)=>QQ.toString());R.forEach((Q,J)=>{const $=X[J];let U;if(typeof Q==="number")U=T(D.a,Q.toString(),$);else if(Q==="gap")U=D.gap;else U=T(D.current,Q,$);M+=typeof G==="string"&&Q==1?Z(U,G):U}),M+=D.after,B.innerHTML="",B.insertAdjacentHTML("afterbegin",M),L=H})(),B.classList.contains("pagy-rjs"))j.observe(F)},A=(B,[D,E])=>Y(B,(z)=>[z,D.replace(/__pagy_page__/,z)],E),C=(B,[D,E,z])=>{Y(B,(G)=>{const F=Math.max(Math.ceil(D/parseInt(G)),1).toString(),K=E.replace(/__pagy_page__/,F).replace(/__pagy_limit__/,G);return[F,K]},z)},Y=(B,D,E)=>{const z=B.querySelector("input"),G=B.querySelector("a"),F=z.value,K=function(){if(z.value===F)return;const[L,T,H]=[z.min,z.value,z.max].map((X)=>parseInt(X)||0);if(TH){z.value=F,z.select();return}let[M,R]=D(z.value);if(typeof E==="string"&&M==="1")R=Z(R,E);G.href=R,G.click()};["change","focus"].forEach((L)=>z.addEventListener(L,()=>z.select())),z.addEventListener("focusout",K),z.addEventListener("keypress",(L)=>{if(L.key==="Enter")K()})},Z=(B,D)=>B.replace(new RegExp(`[?&]${D}=1\\b(?!&)|\\b${D}=1&`),"");return{version:"9.2.1",init(B){const E=(B instanceof Element?B:document).querySelectorAll("[data-pagy]");for(let z of E)try{const G=Uint8Array.from(atob(z.getAttribute("data-pagy")),(L)=>L.charCodeAt(0)),[F,...K]=JSON.parse(new TextDecoder().decode(G));if(F==="nav")x(z,K);else if(F==="combo")A(z,K);else if(F==="selector")C(z,K);else console.warn("Skipped Pagy.init() for: %o\nUnknown keyword '%s'",z,F)}catch(G){console.warn("Skipped Pagy.init() for: %o\n%s",z,G)}}}})();
+window.Pagy=(()=>{const j=new ResizeObserver((B)=>B.forEach((D)=>D.target.querySelectorAll(".pagy-rjs").forEach((E)=>E.pagyRender()))),x=(B,[D,E,z,G])=>{const F=B.parentElement??B,K=Object.keys(E).map((H)=>parseInt(H)).sort((H,M)=>M-H);let L=-1;const T=(H,M,R)=>H.replace(/__pagy_page__/g,M).replace(/__pagy_label__/g,R);if((B.pagyRender=function(){const H=K.find((Q)=>QQ.toString());R.forEach((Q,J)=>{const $=X[J];let U;if(typeof Q==="number")U=T(D.a,Q.toString(),$);else if(Q==="gap")U=D.gap;else U=T(D.current,Q,$);M+=typeof G==="string"&&Q==1?Z(U,G):U}),M+=D.after,B.innerHTML="",B.insertAdjacentHTML("afterbegin",M),L=H})(),B.classList.contains("pagy-rjs"))j.observe(F)},A=(B,[D,E])=>Y(B,(z)=>[z,D.replace(/__pagy_page__/,z)],E),C=(B,[D,E,z])=>{Y(B,(G)=>{const F=Math.max(Math.ceil(D/parseInt(G)),1).toString(),K=E.replace(/__pagy_page__/,F).replace(/__pagy_limit__/,G);return[F,K]},z)},Y=(B,D,E)=>{const z=B.querySelector("input"),G=B.querySelector("a"),F=z.value,K=function(){if(z.value===F)return;const[L,T,H]=[z.min,z.value,z.max].map((X)=>parseInt(X)||0);if(TH){z.value=F,z.select();return}let[M,R]=D(z.value);if(typeof E==="string"&&M==="1")R=Z(R,E);G.href=R,G.click()};["change","focus"].forEach((L)=>z.addEventListener(L,()=>z.select())),z.addEventListener("focusout",K),z.addEventListener("keypress",(L)=>{if(L.key==="Enter")K()})},Z=(B,D)=>B.replace(new RegExp(`[?&]${D}=1\\b(?!&)|\\b${D}=1&`),"");return{version:"9.2.2",init(B){const E=(B instanceof Element?B:document).querySelectorAll("[data-pagy]");for(let z of E)try{const G=Uint8Array.from(atob(z.getAttribute("data-pagy")),(L)=>L.charCodeAt(0)),[F,...K]=JSON.parse(new TextDecoder().decode(G));if(F==="nav")x(z,K);else if(F==="combo")A(z,K);else if(F==="selector")C(z,K);else console.warn("Skipped Pagy.init() for: %o\nUnknown keyword '%s'",z,F)}catch(G){console.warn("Skipped Pagy.init() for: %o\n%s",z,G)}}}})();
-//# debugId=54B9F760378D0A6964756E2164756E21
+//# debugId=95660885F5F5D95D64756E2164756E21
//# sourceMappingURL=pagy.min.js.map
diff --git a/gem/javascripts/pagy.min.js.map b/gem/javascripts/pagy.min.js.map
index 00b9a5d87..26050d1a9 100644
--- a/gem/javascripts/pagy.min.js.map
+++ b/gem/javascripts/pagy.min.js.map
@@ -2,9 +2,9 @@
"version": 3,
"sources": ["../../src/pagy.ts"],
"sourcesContent": [
- "type NavArgs = readonly [Tokens, Sequels, null | LabelSequels, string?]\ntype ComboArgs = readonly [string, string?]\ntype SelectorArgs = readonly [number, string, string?]\ntype JsonArgs = ['nav', NavArgs] | ['combo', ComboArgs] | ['selector', SelectorArgs]\n\ninterface Tokens {\n readonly before:string\n readonly a:string\n readonly current:string\n readonly gap:string\n readonly after:string\n}\ninterface Sequels {readonly [width:string]:(string | number)[]}\ninterface LabelSequels {readonly [width:string]:string[]}\ninterface NavElement extends Element {pagyRender():void}\n\nconst Pagy = (() => {\n // The observer instance for responsive navs\n const rjsObserver = new ResizeObserver(\n entries => entries.forEach(e => e.target.querySelectorAll(\".pagy-rjs\")\n .forEach(el => el.pagyRender())));\n // Init the *_nav_js helpers\n const initNav = (el:NavElement, [tokens, sequels, labelSequels, trimParam]:NavArgs) => {\n const container = el.parentElement ?? el;\n const widths = Object.keys(sequels).map(w => parseInt(w)).sort((a, b) => b - a);\n let lastWidth = -1;\n const fillIn = (a:string, page:string, label:string):string =>\n a.replace(/__pagy_page__/g, page).replace(/__pagy_label__/g, label);\n (el.pagyRender = function () {\n const width = widths.find(w => w < container.clientWidth) || 0;\n if (width === lastWidth) { return } // no change: abort\n let html = tokens.before; // already trimmed in html\n const series = sequels[width.toString()];\n const labels = labelSequels?.[width.toString()] ?? series.map(l => l.toString());\n series.forEach((item, i) => {\n const label = labels[i];\n let filled;\n if (typeof item === \"number\") {\n filled = fillIn(tokens.a, item.toString(), label);\n } else if (item === \"gap\") {\n filled = tokens.gap;\n } else { // active page\n filled = fillIn(tokens.current, item, label);\n }\n html += (typeof trimParam === \"string\" && item == 1) ? trim(filled, trimParam) : filled;\n });\n html += tokens.after;\n el.innerHTML = \"\";\n el.insertAdjacentHTML(\"afterbegin\", html);\n lastWidth = width;\n })();\n if (el.classList.contains(\"pagy-rjs\")) { rjsObserver.observe(container) }\n };\n\n // Init the *_combo_nav_js helpers\n const initCombo = (el:Element, [url_token, trimParam]:ComboArgs) =>\n initInput(el, inputValue => [inputValue, url_token.replace(/__pagy_page__/, inputValue)], trimParam);\n\n // Init the limit_selector_js helper\n const initSelector = (el:Element, [from, url_token, trimParam]:SelectorArgs) => {\n initInput(el, inputValue => {\n const page = Math.max(Math.ceil(from / parseInt(inputValue)), 1).toString();\n const url = url_token.replace(/__pagy_page__/, page).replace(/__pagy_limit__/, inputValue);\n return [page, url];\n }, trimParam);\n };\n\n // Init the input element\n const initInput = (el:Element, getVars:(v:string) => [string, string], trimParam?:string) => {\n const input = el.querySelector(\"input\") as HTMLInputElement;\n const link = el.querySelector(\"a\") as HTMLAnchorElement;\n const initial = input.value;\n const action = function () {\n if (input.value === initial) { return } // not changed\n const [min, val, max] = [input.min, input.value, input.max].map(n => parseInt(n) || 0);\n if (val < min || val > max) { // reset invalid/out-of-range\n input.value = initial;\n input.select();\n return;\n }\n let [page, url] = getVars(input.value); // eslint-disable-line prefer-const\n if (typeof trimParam === \"string\" && page === \"1\") { url = trim(url, trimParam) }\n link.href = url;\n link.click();\n };\n [\"change\", \"focus\"].forEach(e => input.addEventListener(e, () => input.select())); // auto-select\n input.addEventListener(\"focusout\", action); // trigger action\n input.addEventListener(\"keypress\", e => { if (e.key === \"Enter\") { action() } }); // trigger action\n };\n\n // Trim the ${page-param}=1 params in links\n const trim = (a:string, param:string) =>\n a.replace(new RegExp(`[?&]${param}=1\\\\b(?!&)|\\\\b${param}=1&`), \"\");\n\n // Public interface\n return {\n version: \"9.2.1\",\n\n // Scan for elements with a \"data-pagy\" attribute and call their init functions with the decoded args\n init(arg?:Element) {\n const target = arg instanceof Element ? arg : document;\n const elements = target.querySelectorAll(\"[data-pagy]\");\n for (const el of elements) {\n try {\n const uint8array = Uint8Array.from(atob(el.getAttribute(\"data-pagy\") as string), c => c.charCodeAt(0));\n const [keyword, ...args] = JSON.parse((new TextDecoder()).decode(uint8array)) as JsonArgs; // base64-utf8 -> JSON -> Array\n if (keyword === \"nav\") {\n initNav(el as NavElement, args as unknown as NavArgs);\n } else if (keyword === \"combo\") {\n initCombo(el, args as unknown as ComboArgs);\n } else if (keyword === \"selector\") {\n initSelector(el, args as unknown as SelectorArgs);\n } else {\n console.warn(\"Skipped Pagy.init() for: %o\\nUnknown keyword '%s'\", el, keyword);\n }\n } catch (err) { console.warn(\"Skipped Pagy.init() for: %o\\n%s\", el, err) }\n }\n }\n };\n})();\n\nexport default Pagy;\n"
+ "type NavArgs = readonly [Tokens, Sequels, null | LabelSequels, string?]\ntype ComboArgs = readonly [string, string?]\ntype SelectorArgs = readonly [number, string, string?]\ntype JsonArgs = ['nav', NavArgs] | ['combo', ComboArgs] | ['selector', SelectorArgs]\n\ninterface Tokens {\n readonly before:string\n readonly a:string\n readonly current:string\n readonly gap:string\n readonly after:string\n}\ninterface Sequels {readonly [width:string]:(string | number)[]}\ninterface LabelSequels {readonly [width:string]:string[]}\ninterface NavElement extends Element {pagyRender():void}\n\nconst Pagy = (() => {\n // The observer instance for responsive navs\n const rjsObserver = new ResizeObserver(\n entries => entries.forEach(e => e.target.querySelectorAll(\".pagy-rjs\")\n .forEach(el => el.pagyRender())));\n // Init the *_nav_js helpers\n const initNav = (el:NavElement, [tokens, sequels, labelSequels, trimParam]:NavArgs) => {\n const container = el.parentElement ?? el;\n const widths = Object.keys(sequels).map(w => parseInt(w)).sort((a, b) => b - a);\n let lastWidth = -1;\n const fillIn = (a:string, page:string, label:string):string =>\n a.replace(/__pagy_page__/g, page).replace(/__pagy_label__/g, label);\n (el.pagyRender = function () {\n const width = widths.find(w => w < container.clientWidth) || 0;\n if (width === lastWidth) { return } // no change: abort\n let html = tokens.before; // already trimmed in html\n const series = sequels[width.toString()];\n const labels = labelSequels?.[width.toString()] ?? series.map(l => l.toString());\n series.forEach((item, i) => {\n const label = labels[i];\n let filled;\n if (typeof item === \"number\") {\n filled = fillIn(tokens.a, item.toString(), label);\n } else if (item === \"gap\") {\n filled = tokens.gap;\n } else { // active page\n filled = fillIn(tokens.current, item, label);\n }\n html += (typeof trimParam === \"string\" && item == 1) ? trim(filled, trimParam) : filled;\n });\n html += tokens.after;\n el.innerHTML = \"\";\n el.insertAdjacentHTML(\"afterbegin\", html);\n lastWidth = width;\n })();\n if (el.classList.contains(\"pagy-rjs\")) { rjsObserver.observe(container) }\n };\n\n // Init the *_combo_nav_js helpers\n const initCombo = (el:Element, [url_token, trimParam]:ComboArgs) =>\n initInput(el, inputValue => [inputValue, url_token.replace(/__pagy_page__/, inputValue)], trimParam);\n\n // Init the limit_selector_js helper\n const initSelector = (el:Element, [from, url_token, trimParam]:SelectorArgs) => {\n initInput(el, inputValue => {\n const page = Math.max(Math.ceil(from / parseInt(inputValue)), 1).toString();\n const url = url_token.replace(/__pagy_page__/, page).replace(/__pagy_limit__/, inputValue);\n return [page, url];\n }, trimParam);\n };\n\n // Init the input element\n const initInput = (el:Element, getVars:(v:string) => [string, string], trimParam?:string) => {\n const input = el.querySelector(\"input\") as HTMLInputElement;\n const link = el.querySelector(\"a\") as HTMLAnchorElement;\n const initial = input.value;\n const action = function () {\n if (input.value === initial) { return } // not changed\n const [min, val, max] = [input.min, input.value, input.max].map(n => parseInt(n) || 0);\n if (val < min || val > max) { // reset invalid/out-of-range\n input.value = initial;\n input.select();\n return;\n }\n let [page, url] = getVars(input.value); // eslint-disable-line prefer-const\n if (typeof trimParam === \"string\" && page === \"1\") { url = trim(url, trimParam) }\n link.href = url;\n link.click();\n };\n [\"change\", \"focus\"].forEach(e => input.addEventListener(e, () => input.select())); // auto-select\n input.addEventListener(\"focusout\", action); // trigger action\n input.addEventListener(\"keypress\", e => { if (e.key === \"Enter\") { action() } }); // trigger action\n };\n\n // Trim the ${page-param}=1 params in links\n const trim = (a:string, param:string) =>\n a.replace(new RegExp(`[?&]${param}=1\\\\b(?!&)|\\\\b${param}=1&`), \"\");\n\n // Public interface\n return {\n version: \"9.2.2\",\n\n // Scan for elements with a \"data-pagy\" attribute and call their init functions with the decoded args\n init(arg?:Element) {\n const target = arg instanceof Element ? arg : document;\n const elements = target.querySelectorAll(\"[data-pagy]\");\n for (const el of elements) {\n try {\n const uint8array = Uint8Array.from(atob(el.getAttribute(\"data-pagy\") as string), c => c.charCodeAt(0));\n const [keyword, ...args] = JSON.parse((new TextDecoder()).decode(uint8array)) as JsonArgs; // base64-utf8 -> JSON -> Array\n if (keyword === \"nav\") {\n initNav(el as NavElement, args as unknown as NavArgs);\n } else if (keyword === \"combo\") {\n initCombo(el, args as unknown as ComboArgs);\n } else if (keyword === \"selector\") {\n initSelector(el, args as unknown as SelectorArgs);\n } else {\n console.warn(\"Skipped Pagy.init() for: %o\\nUnknown keyword '%s'\", el, keyword);\n }\n } catch (err) { console.warn(\"Skipped Pagy.init() for: %o\\n%s\", el, err) }\n }\n }\n };\n})();\n\nexport default Pagy;\n"
],
"mappings": "AAgBA,IAAM,GAAQ,IAAM,CAElB,MAAM,EAAc,IAAI,eACpB,KAAW,EAAQ,QAAQ,KAAK,EAAE,OAAO,iBAA6B,WAAW,EAC/C,QAAQ,KAAM,EAAG,WAAW,CAAC,CAAC,CAAC,EAE/D,EAAU,CAAC,GAAgB,EAAQ,EAAS,EAAc,KAAuB,CACrF,MAAM,EAAY,EAAG,eAAiB,EAChC,EAAY,OAAO,KAAK,CAAO,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,EAAG,IAAM,EAAI,CAAC,EACjF,IAAI,EAAc,GAClB,MAAM,EAAY,CAAC,EAAU,EAAa,IACtC,EAAE,QAAQ,iBAAkB,CAAI,EAAE,QAAQ,kBAAmB,CAAK,EAwBtE,IAvBC,EAAG,mBAAsB,EAAG,CAC3B,MAAM,EAAQ,EAAO,KAAK,KAAK,EAAI,EAAU,WAAW,GAAK,EAC7D,GAAI,IAAU,EAAa,OAC3B,IAAI,EAAW,EAAO,OACtB,MAAM,EAAS,EAAQ,EAAM,SAAS,GAChC,EAAS,IAAe,EAAM,SAAS,IAAM,EAAO,IAAI,KAAK,EAAE,SAAS,CAAC,EAC/E,EAAO,QAAQ,CAAC,EAAM,IAAM,CAC1B,MAAM,EAAQ,EAAO,GACrB,IAAI,EACJ,UAAW,IAAS,SAClB,EAAS,EAAO,EAAO,EAAG,EAAK,SAAS,EAAG,CAAK,UACvC,IAAS,MAClB,EAAS,EAAO,QAEhB,GAAS,EAAO,EAAO,QAAS,EAAM,CAAK,EAE7C,UAAgB,IAAc,UAAY,GAAQ,EAAK,EAAK,EAAQ,CAAS,EAAI,EAClF,EACD,GAAe,EAAO,MACtB,EAAG,UAAY,GACf,EAAG,mBAAmB,aAAc,CAAI,EACxC,EAAY,IACX,EACC,EAAG,UAAU,SAAS,UAAU,EAAK,EAAY,QAAQ,CAAS,GAIlE,EAAY,CAAC,GAAa,EAAW,KACvC,EAAU,EAAI,KAAc,CAAC,EAAY,EAAU,QAAQ,gBAAiB,CAAU,CAAC,EAAG,CAAS,EAGjG,EAAe,CAAC,GAAa,EAAM,EAAW,KAA4B,CAC9E,EAAU,EAAI,KAAc,CAC1B,MAAM,EAAO,KAAK,IAAI,KAAK,KAAK,EAAO,SAAS,CAAU,CAAC,EAAG,CAAC,EAAE,SAAS,EACpE,EAAO,EAAU,QAAQ,gBAAiB,CAAI,EAAE,QAAQ,iBAAkB,CAAU,EAC1F,MAAO,CAAC,EAAM,CAAG,GAChB,CAAS,GAIR,EAAY,CAAC,EAAY,EAAwC,IAAsB,CAC3F,MAAM,EAAU,EAAG,cAAc,OAAO,EAClC,EAAU,EAAG,cAAc,GAAG,EAC9B,EAAU,EAAM,MAChB,UAAmB,EAAG,CAC1B,GAAI,EAAM,QAAU,EAAW,OAC/B,MAAO,EAAK,EAAK,GAAO,CAAC,EAAM,IAAK,EAAM,MAAO,EAAM,GAAG,EAAE,IAAI,KAAK,SAAS,CAAC,GAAK,CAAC,EACrF,GAAI,EAAM,GAAO,EAAM,EAAK,CAC1B,EAAM,MAAQ,EACd,EAAM,OAAO,EACb,OAEF,IAAK,EAAM,GAAO,EAAQ,EAAM,KAAK,EACrC,UAAW,IAAc,UAAY,IAAS,IAAO,EAAM,EAAK,EAAK,CAAS,EAC9E,EAAK,KAAO,EACZ,EAAK,MAAM,GAEb,CAAC,SAAU,OAAO,EAAE,QAAQ,KAAK,EAAM,iBAAiB,EAAG,IAAM,EAAM,OAAO,CAAC,CAAC,EAChF,EAAM,iBAAiB,WAAY,CAAM,EACzC,EAAM,iBAAiB,WAAY,KAAK,CAAE,GAAI,EAAE,MAAQ,QAAW,EAAO,EAAK,GAI3E,EAAO,CAAC,EAAU,IACpB,EAAE,QAAQ,IAAI,OAAO,OAAO,kBAAsB,MAAU,EAAG,EAAE,EAGrE,MAAO,CACL,QAAS,QAGT,IAAI,CAAC,EAAc,CAEjB,MAAM,GADW,aAAe,QAAU,EAAM,UACxB,iBAAiB,aAAa,EACtD,QAAW,KAAM,EACf,GAAI,CACF,MAAM,EAAqB,WAAW,KAAK,KAAK,EAAG,aAAa,WAAW,CAAW,EAAG,KAAK,EAAE,WAAW,CAAC,CAAC,GACtG,KAAY,GAAQ,KAAK,MAAO,IAAI,YAAY,EAAG,OAAO,CAAU,CAAC,EAC5E,GAAI,IAAY,MACd,EAAQ,EAAkB,CAA0B,UAC3C,IAAY,QACrB,EAAU,EAAI,CAA4B,UACjC,IAAY,WACrB,EAAa,EAAI,CAA+B,MAEhD,SAAQ,KAAK,oDAAqD,EAAI,CAAO,QAExE,EAAP,CAAc,QAAQ,KAAK,kCAAmC,EAAI,CAAG,GAG7E,IACC",
- "debugId": "54B9F760378D0A6964756E2164756E21",
+ "debugId": "95660885F5F5D95D64756E2164756E21",
"names": []
}
\ No newline at end of file
diff --git a/gem/javascripts/pagy.mjs b/gem/javascripts/pagy.mjs
index 0155a0a67..b6a99281a 100644
--- a/gem/javascripts/pagy.mjs
+++ b/gem/javascripts/pagy.mjs
@@ -73,7 +73,7 @@ const Pagy = (() => {
};
const trim = (a, param) => a.replace(new RegExp(`[?&]${param}=1\\b(?!&)|\\b${param}=1&`), "");
return {
- version: "9.2.1",
+ version: "9.2.2",
init(arg) {
const target = arg instanceof Element ? arg : document;
const elements = target.querySelectorAll("[data-pagy]");
diff --git a/gem/lib/pagy.rb b/gem/lib/pagy.rb
index e872d8899..bdcf6f59a 100644
--- a/gem/lib/pagy.rb
+++ b/gem/lib/pagy.rb
@@ -6,7 +6,7 @@
# Top superclass: it should define only what's common to all the subclasses
class Pagy
- VERSION = '9.2.1'
+ VERSION = '9.2.2'
# Core default: constant for easy access, but mutable for customizable defaults
DEFAULT = { count_args: [:all], # rubocop:disable Style/MutableConstant
diff --git a/gem/pagy.gemspec b/gem/pagy.gemspec
index cdd1319dd..d7b264250 100644
--- a/gem/pagy.gemspec
+++ b/gem/pagy.gemspec
@@ -2,7 +2,7 @@
Gem::Specification.new do |s|
s.name = 'pagy'
- s.version = '9.2.1'
+ s.version = '9.2.2'
s.authors = ['Domizio Demichelis']
s.email = ['dd.nexus@gmail.com']
s.summary = 'The best pagination ruby gem'
diff --git a/retype.yml b/retype.yml
index d06d1bc96..cc32a935a 100644
--- a/retype.yml
+++ b/retype.yml
@@ -8,7 +8,7 @@ url: https://ddnexus.github.io/pagy
branding:
title: Pagy
- label: 9.2.1
+ label: 9.2.2
colors:
label:
text: "#FFFFFF"
diff --git a/scripts/bump.rb b/scripts/bump.rb
index bdc07d34b..ecdc0547c 100755
--- a/scripts/bump.rb
+++ b/scripts/bump.rb
@@ -3,6 +3,7 @@
require 'tempfile'
require_relative 'scripty'
+require_relative '../gem/apps/index'
include Scripty # rubocop:disable Style/MixinUsage
# Abort if the working tree is dirty
@@ -65,20 +66,15 @@
replace_string_in_file('CHANGELOG.md', / \n/, " \n\n## Version #{new_version}\n\n#{changes}")
# Bump the version in files
-%w[retype.yml
- .github/ISSUE_TEMPLATE/Code.yml
- .github/latest_release_body.md
- gem/apps/calendar.ru
- gem/apps/demo.ru
- gem/apps/keyset_ar.ru
- gem/apps/keyset_s.ru
- gem/apps/rails.ru
- gem/apps/repro.ru
- gem/bin/pagy
- gem/config/pagy.rb
- gem/lib/pagy.rb
- gem/pagy.gemspec
- src/pagy.ts].each do |path|
+(%w[retype.yml
+ .github/ISSUE_TEMPLATE/Code.yml
+ .github/latest_release_body.md
+ gem/bin/pagy
+ gem/config/pagy.rb
+ gem/lib/pagy.rb
+ gem/pagy.gemspec
+ src/pagy.ts] +
+ PagyApps::INDEX.values).each do |path|
replace_string_in_file(path, old_version, new_version)
end
diff --git a/src/pagy.ts b/src/pagy.ts
index c398bd5cc..e1175c741 100644
--- a/src/pagy.ts
+++ b/src/pagy.ts
@@ -94,7 +94,7 @@ const Pagy = (() => {
// Public interface
return {
- version: "9.2.1",
+ version: "9.2.2",
// Scan for elements with a "data-pagy" attribute and call their init functions with the decoded args
init(arg?:Element) {
diff --git a/test/mock_helpers/app.rb b/test/mock_helpers/app.rb
index 12220f8b4..9643230db 100644
--- a/test/mock_helpers/app.rb
+++ b/test/mock_helpers/app.rb
@@ -4,6 +4,8 @@
require 'groupdate'
require 'rack'
+ActiveSupport.to_time_preserves_timezone = :zone # Fix ActiveSupport deprecation
+
# Backend and Frontend poor man mock app
class MockApp
attr_reader :params, :request, :response
diff --git a/test/pagy/extras/elasticsearch_rails_test.rb b/test/pagy/extras/elasticsearch_rails_test.rb
index b329421fb..43b2925ac 100644
--- a/test/pagy/extras/elasticsearch_rails_test.rb
+++ b/test/pagy/extras/elasticsearch_rails_test.rb
@@ -125,7 +125,7 @@
_(records).must_rematch :records
end
end
- describe 'Pagy.new_from_elasticsearch_rails' do
+ describe 'new_from_elasticsearch_rails' do
it 'paginates response with defaults' do
response = MockElasticsearchRails::Model.search('a')
pagy = Pagy.new_from_elasticsearch_rails(response)
diff --git a/test/pagy/extras/meilisearch_test.rb b/test/pagy/extras/meilisearch_test.rb
index 85daeaa3f..b47fbd772 100644
--- a/test/pagy/extras/meilisearch_test.rb
+++ b/test/pagy/extras/meilisearch_test.rb
@@ -59,7 +59,7 @@
_(results.to_a).must_rematch :results
end
end
- describe 'Pagy.new_from_meilisearch' do
+ describe 'new_from_meilisearch' do
it 'paginates results with defaults' do
results = MockMeilisearch::Model.ms_search('a')
pagy = Pagy.new_from_meilisearch(results)
diff --git a/test/pagy/extras/searchkick_test.rb b/test/pagy/extras/searchkick_test.rb
index dd77f13e2..ecf737154 100644
--- a/test/pagy/extras/searchkick_test.rb
+++ b/test/pagy/extras/searchkick_test.rb
@@ -85,7 +85,7 @@
_(results).must_rematch :results
end
end
- describe 'Pagy.new_from_searchkick' do
+ describe 'new_from_searchkick' do
it 'paginates results with defaults' do
results = MockSearchkick::Model.search('a')
pagy = Pagy.new_from_searchkick(results)
diff --git a/test/pagy/version_test.rb b/test/pagy/version_test.rb
index a35f6b417..6235e0384 100644
--- a/test/pagy/version_test.rb
+++ b/test/pagy/version_test.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: true
require_relative '../test_helper'
+require_relative '../../gem/apps/index'
describe 'Version match' do
it 'has version' do
@@ -19,8 +20,8 @@
_(Pagy.root.join('bin', 'pagy').read).must_match "VERSION = '#{Pagy::VERSION}'"
end
it 'defines the same version in apps/*.ru' do
- %w[calendar demo rails repro].each do |app|
- _(Pagy.root.join('apps', "#{app}.ru").read).must_match "VERSION = '#{Pagy::VERSION}'"
+ PagyApps::INDEX.each_value do |path|
+ _(File.read(path)).must_match "VERSION = '#{Pagy::VERSION}'"
end
end
it 'defines the same version in javascripts/pagy.min.js' do