pagy 9.0.2 → 9.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/apps/calendar.ru +1 -1
- data/apps/demo.ru +1 -1
- data/apps/rails.ru +1 -1
- data/apps/repro.ru +1 -1
- data/bin/pagy +1 -1
- data/config/pagy.rb +1 -1
- data/javascripts/pagy.min.js +2 -2
- data/javascripts/pagy.min.js.map +2 -2
- data/javascripts/pagy.mjs +1 -1
- data/lib/pagy/backend.rb +10 -14
- data/lib/pagy/extras/arel.rb +2 -8
- data/lib/pagy/extras/array.rb +4 -7
- data/lib/pagy/extras/countless.rb +3 -10
- data/lib/pagy/extras/elasticsearch_rails.rb +7 -16
- data/lib/pagy/extras/jsonapi.rb +6 -9
- data/lib/pagy/extras/keyset.rb +3 -9
- data/lib/pagy/extras/limit.rb +2 -2
- data/lib/pagy/extras/meilisearch.rb +2 -10
- data/lib/pagy/extras/searchkick.rb +2 -10
- data/lib/pagy/i18n.rb +1 -1
- data/lib/pagy.rb +1 -1
- metadata +2 -12
- 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 +0 -1
- data/apps/tmp/pagy-keyset-ar.sqlite3 +0 -0
- data/apps/tmp/pagy-keyset-ar.sqlite3-shm +0 -0
- data/apps/tmp/pagy-keyset-ar.sqlite3-wal +0 -0
- data/apps/tmp/pagy-keyset-s.sqlite3 +0 -0
- data/javascripts/pagy-module.js +0 -100
- data/javascripts/pagy.js +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d3cfd3dbf7a81f248f0ea0d6edfa563047f4eead1e7971ae7645c87c6a98018
|
4
|
+
data.tar.gz: b3447de74444e85d27676725d5742af32e902776882c48da97f64c7373f258ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01cfeb6596556a25379b34e737d7093b90dba9ce9431203ba22722ceed1367c6e769865985f23ba9a6c8ddc93117459d9e8a85f86822705c36c05382de116b69
|
7
|
+
data.tar.gz: e12c3f47acf0e0a201897373f4b031c0e349e9c584f4256a5ee5cc6eea3743a6285159817bbb469ccee853d91814c462e21dc04502fcfc1ff10a010d219adc23
|
data/apps/calendar.ru
CHANGED
data/apps/demo.ru
CHANGED
data/apps/rails.ru
CHANGED
data/apps/repro.ru
CHANGED
data/bin/pagy
CHANGED
data/config/pagy.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Pagy initializer file (9.0.
|
3
|
+
# Pagy initializer file (9.0.3)
|
4
4
|
# Customize only what you really need and notice that the core Pagy works also without any of the following lines.
|
5
5
|
# Should you just cherry pick part of this file, please maintain the require-order of the extras
|
6
6
|
|
data/javascripts/pagy.min.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
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)=>Q<F.clientWidth)||0;if(H===L)return;let M=D.before;const R=E[H.toString()],X=z?.[H.toString()]??R.map((Q)=>Q.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(T<L||T>H){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.0.
|
1
|
+
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)=>Q<F.clientWidth)||0;if(H===L)return;let M=D.before;const R=E[H.toString()],X=z?.[H.toString()]??R.map((Q)=>Q.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(T<L||T>H){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.0.3",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)}}}})();
|
2
2
|
|
3
|
-
//# debugId=
|
3
|
+
//# debugId=F902131AD289418764756E2164756E21
|
4
4
|
//# sourceMappingURL=pagy.min.js.map
|
data/javascripts/pagy.min.js.map
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../src/pagy.ts"],
|
4
4
|
"sourcesContent": [
|
5
|
-
"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<NavElement>(\".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.0.
|
5
|
+
"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<NavElement>(\".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.0.3\",\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"
|
6
6
|
],
|
7
7
|
"mappings": "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",
|
8
|
-
"debugId": "
|
8
|
+
"debugId": "F902131AD289418764756E2164756E21",
|
9
9
|
"names": []
|
10
10
|
}
|
data/javascripts/pagy.mjs
CHANGED
@@ -73,7 +73,7 @@ const Pagy = (() => {
|
|
73
73
|
};
|
74
74
|
const trim = (a, param) => a.replace(new RegExp(`[?&]${param}=1\\b(?!&)|\\b${param}=1&`), "");
|
75
75
|
return {
|
76
|
-
version: "9.0.
|
76
|
+
version: "9.0.3",
|
77
77
|
init(arg) {
|
78
78
|
const target = arg instanceof Element ? arg : document;
|
79
79
|
const elements = target.querySelectorAll("[data-pagy]");
|
data/lib/pagy/backend.rb
CHANGED
@@ -10,7 +10,10 @@ class Pagy
|
|
10
10
|
|
11
11
|
# Return Pagy object and paginated results
|
12
12
|
def pagy(collection, **vars)
|
13
|
-
|
13
|
+
vars[:count] ||= pagy_get_count(collection, vars)
|
14
|
+
vars[:limit] ||= pagy_get_limit(vars)
|
15
|
+
vars[:page] ||= pagy_get_page(vars)
|
16
|
+
pagy = Pagy.new(**vars)
|
14
17
|
[pagy, pagy_get_items(collection, pagy)]
|
15
18
|
end
|
16
19
|
|
@@ -27,22 +30,15 @@ class Pagy
|
|
27
30
|
end
|
28
31
|
|
29
32
|
# Override for limit extra
|
30
|
-
def pagy_get_limit(
|
33
|
+
def pagy_get_limit(_vars)
|
34
|
+
DEFAULT[:limit]
|
35
|
+
end
|
31
36
|
|
32
37
|
# Get the page integer from the params
|
33
38
|
# Overridable by the jsonapi extra
|
34
|
-
def pagy_get_page(vars)
|
35
|
-
params[vars[:page_param] || DEFAULT[:page_param]]
|
36
|
-
|
37
|
-
|
38
|
-
# Sub-method called only by #pagy: here for easy customization of variables by overriding
|
39
|
-
# You may need to override the count call for non AR collections
|
40
|
-
def pagy_get_vars(collection, vars)
|
41
|
-
vars.tap do |v|
|
42
|
-
v[:count] ||= pagy_get_count(collection, v)
|
43
|
-
v[:limit] ||= pagy_get_limit(v)
|
44
|
-
v[:page] ||= pagy_get_page(v)
|
45
|
-
end
|
39
|
+
def pagy_get_page(vars, force_integer: true)
|
40
|
+
page = params[vars[:page_param] || DEFAULT[:page_param]]
|
41
|
+
force_integer ? (page || 1).to_i : page
|
46
42
|
end
|
47
43
|
end
|
48
44
|
end
|
data/lib/pagy/extras/arel.rb
CHANGED
@@ -8,8 +8,8 @@ class Pagy # :nodoc:
|
|
8
8
|
|
9
9
|
# Return Pagy object and paginated collection/results
|
10
10
|
def pagy_arel(collection, **vars)
|
11
|
-
|
12
|
-
|
11
|
+
vars[:count] ||= pagy_arel_count(collection)
|
12
|
+
pagy(collection, **vars)
|
13
13
|
end
|
14
14
|
|
15
15
|
# Count using Arel when grouping
|
@@ -23,12 +23,6 @@ class Pagy # :nodoc:
|
|
23
23
|
collection.unscope(:order).limit(1).pluck(sql).first.to_i
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
27
|
-
# Sub-method called only by #pagy_arel: here for easy customization of variables by overriding
|
28
|
-
def pagy_arel_get_vars(collection, vars)
|
29
|
-
vars[:count] ||= pagy_arel_count(collection)
|
30
|
-
pagy_get_vars(collection, vars)
|
31
|
-
end
|
32
26
|
end
|
33
27
|
Backend.prepend ArelExtra
|
34
28
|
end
|
data/lib/pagy/extras/array.rb
CHANGED
@@ -8,14 +8,11 @@ class Pagy # :nodoc:
|
|
8
8
|
|
9
9
|
# Return Pagy object and paginated items
|
10
10
|
def pagy_array(array, **vars)
|
11
|
-
|
12
|
-
[
|
13
|
-
end
|
14
|
-
|
15
|
-
# Sub-method called only by #pagy_array: here for easy customization of variables by overriding
|
16
|
-
def pagy_array_get_vars(array, vars)
|
11
|
+
vars[:limit] ||= pagy_get_limit(vars)
|
12
|
+
vars[:page] ||= pagy_get_page(vars)
|
17
13
|
vars[:count] ||= array.size
|
18
|
-
|
14
|
+
pagy = Pagy.new(**vars)
|
15
|
+
[pagy, array[pagy.offset, pagy.limit]]
|
19
16
|
end
|
20
17
|
end
|
21
18
|
Backend.prepend ArrayExtra
|
@@ -12,7 +12,9 @@ class Pagy # :nodoc:
|
|
12
12
|
|
13
13
|
# Return Pagy object and records
|
14
14
|
def pagy_countless(collection, **vars)
|
15
|
-
|
15
|
+
vars[:limit] ||= pagy_get_limit(vars)
|
16
|
+
vars[:page] ||= pagy_get_page(vars)
|
17
|
+
pagy = Countless.new(**vars)
|
16
18
|
[pagy, pagy_countless_get_items(collection, pagy)]
|
17
19
|
end
|
18
20
|
|
@@ -25,15 +27,6 @@ class Pagy # :nodoc:
|
|
25
27
|
pagy.finalize(fetched.size) # finalize the pagy object
|
26
28
|
fetched[0, pagy.limit] # ignore eventual extra item
|
27
29
|
end
|
28
|
-
|
29
|
-
# Sub-method called only by #pagy: here for easy customization of variables by overriding
|
30
|
-
# You may need to override the count call for non AR collections
|
31
|
-
def pagy_countless_get_vars(_collection, vars)
|
32
|
-
vars.tap do |v|
|
33
|
-
v[:limit] ||= pagy_get_limit(v)
|
34
|
-
v[:page] ||= pagy_get_page(v)
|
35
|
-
end
|
36
|
-
end
|
37
30
|
end
|
38
31
|
Backend.prepend CountlessExtra
|
39
32
|
end
|
@@ -50,13 +50,13 @@ class Pagy # :nodoc:
|
|
50
50
|
|
51
51
|
# Return Pagy object and records
|
52
52
|
def pagy_elasticsearch_rails(pagy_search_args, **vars)
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
options[:size]
|
57
|
-
options[:from]
|
58
|
-
response
|
59
|
-
vars[:count]
|
53
|
+
vars[:page] ||= pagy_get_page(vars)
|
54
|
+
vars[:limit] ||= pagy_get_limit(vars)
|
55
|
+
model, query_or_payload, options, *called = pagy_search_args
|
56
|
+
options[:size] = vars[:limit]
|
57
|
+
options[:from] = vars[:limit] * ((vars[:page] || 1) - 1)
|
58
|
+
response = model.send(DEFAULT[:elasticsearch_rails_search], query_or_payload, **options)
|
59
|
+
vars[:count] = ElasticsearchRailsExtra.total_count(response)
|
60
60
|
|
61
61
|
pagy = ::Pagy.new(**vars)
|
62
62
|
# with :last_page overflow we need to re-run the method in order to get the hits
|
@@ -65,15 +65,6 @@ class Pagy # :nodoc:
|
|
65
65
|
|
66
66
|
[pagy, called.empty? ? response : response.send(*called)]
|
67
67
|
end
|
68
|
-
|
69
|
-
# Sub-method called only by #pagy_elasticsearch_rails: here for easy customization of variables by overriding
|
70
|
-
# the _collection argument is not available when the method is called
|
71
|
-
def pagy_elasticsearch_rails_get_vars(_collection, vars)
|
72
|
-
vars.tap do |v|
|
73
|
-
v[:page] ||= pagy_get_page(v)
|
74
|
-
v[:limit] ||= pagy_get_limit(v) || DEFAULT[:limit]
|
75
|
-
end
|
76
|
-
end
|
77
68
|
end
|
78
69
|
Backend.prepend BackendAddOn
|
79
70
|
end
|
data/lib/pagy/extras/jsonapi.rb
CHANGED
@@ -45,11 +45,11 @@ class Pagy # :nodoc:
|
|
45
45
|
end
|
46
46
|
|
47
47
|
# Override the Backend method
|
48
|
-
def pagy_get_page(vars)
|
49
|
-
return super if pagy_skip_jsonapi?(vars)
|
50
|
-
return if params[:page].nil?
|
48
|
+
def pagy_get_page(vars, force_integer: true)
|
49
|
+
return super if pagy_skip_jsonapi?(vars) || params[:page].nil?
|
51
50
|
|
52
|
-
params[:page][vars[:page_param] || DEFAULT[:page_param]]
|
51
|
+
page = params[:page][vars[:page_param] || DEFAULT[:page_param]]
|
52
|
+
force_integer ? (page || 1).to_i : page
|
53
53
|
end
|
54
54
|
end
|
55
55
|
Backend.prepend BackendOverride
|
@@ -61,7 +61,7 @@ class Pagy # :nodoc:
|
|
61
61
|
# Override the LimitExtra::Backend method
|
62
62
|
def pagy_get_limit_param(vars)
|
63
63
|
return super if pagy_skip_jsonapi?(vars)
|
64
|
-
return
|
64
|
+
return unless params[:page]
|
65
65
|
|
66
66
|
params[:page][vars[:limit_param] || DEFAULT[:limit_param]]
|
67
67
|
end
|
@@ -77,11 +77,8 @@ class Pagy # :nodoc:
|
|
77
77
|
return super unless vars[:jsonapi]
|
78
78
|
|
79
79
|
query_params['page'] ||= {}
|
80
|
-
query_params['page'][vars[:page_param].to_s] = page
|
80
|
+
query_params['page'][vars[:page_param].to_s] = page
|
81
81
|
query_params['page'][vars[:limit_param].to_s] = vars[:limit] if vars[:limit_extra]
|
82
|
-
# :nocov:
|
83
|
-
query_params.delete(:page) if query_params['page'].empty?
|
84
|
-
# :nocov:
|
85
82
|
end
|
86
83
|
end
|
87
84
|
UrlHelpers.prepend UrlHelperOverride
|
data/lib/pagy/extras/keyset.rb
CHANGED
@@ -10,18 +10,12 @@ class Pagy # :nodoc:
|
|
10
10
|
|
11
11
|
# Return Pagy::Keyset object and paginated records
|
12
12
|
def pagy_keyset(set, **vars)
|
13
|
-
|
13
|
+
vars[:page] ||= pagy_get_page(vars, force_integer: false) # allow nil
|
14
|
+
vars[:limit] ||= pagy_get_limit(vars)
|
15
|
+
pagy = Keyset.new(set, **vars)
|
14
16
|
[pagy, pagy.records]
|
15
17
|
end
|
16
18
|
|
17
|
-
# Sub-method called only by #pagy_keyset: here for easy customization of variables by overriding
|
18
|
-
def pagy_keyset_get_vars(vars)
|
19
|
-
vars.tap do |v|
|
20
|
-
v[:page] ||= pagy_get_page(v)
|
21
|
-
v[:limit] ||= pagy_get_limit(v)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
19
|
# Return the URL string for the first page
|
26
20
|
def pagy_keyset_first_url(pagy, **vars)
|
27
21
|
pagy_url_for(pagy, nil, **vars)
|
data/lib/pagy/extras/limit.rb
CHANGED
@@ -16,8 +16,8 @@ class Pagy # :nodoc:
|
|
16
16
|
|
17
17
|
# Set the limit variable considering the params and other pagy variables
|
18
18
|
def pagy_get_limit(vars)
|
19
|
-
return unless vars.key?(:limit_extra) ? vars[:limit_extra] : DEFAULT[:limit_extra] # :limit_extra is false
|
20
|
-
return unless (limit_count = pagy_get_limit_param(vars)) # no limit from request params
|
19
|
+
return super unless vars.key?(:limit_extra) ? vars[:limit_extra] : DEFAULT[:limit_extra] # :limit_extra is false
|
20
|
+
return super unless (limit_count = pagy_get_limit_param(vars)) # no limit from request params
|
21
21
|
|
22
22
|
vars[:limit] = [limit_count.to_i, vars.key?(:limit_max) ? vars[:limit_max] : DEFAULT[:limit_max]].compact.min
|
23
23
|
end
|
@@ -36,8 +36,9 @@ class Pagy # :nodoc:
|
|
36
36
|
|
37
37
|
# Return Pagy object and results
|
38
38
|
def pagy_meilisearch(pagy_search_args, **vars)
|
39
|
+
vars[:page] ||= pagy_get_page(vars)
|
40
|
+
vars[:limit] ||= pagy_get_limit(vars)
|
39
41
|
model, term, options = pagy_search_args
|
40
|
-
vars = pagy_meilisearch_get_vars(nil, vars)
|
41
42
|
options[:hits_per_page] = vars[:limit]
|
42
43
|
options[:page] = vars[:page]
|
43
44
|
results = model.send(:ms_search, term, options)
|
@@ -50,15 +51,6 @@ class Pagy # :nodoc:
|
|
50
51
|
|
51
52
|
[pagy, results]
|
52
53
|
end
|
53
|
-
|
54
|
-
# Sub-method called only by #pagy_meilisearch: here for easy customization of variables by overriding.
|
55
|
-
# The _collection argument is not available when the method is called.
|
56
|
-
def pagy_meilisearch_get_vars(_collection, vars)
|
57
|
-
vars.tap do |v|
|
58
|
-
v[:page] ||= pagy_get_page(v)
|
59
|
-
v[:limit] ||= pagy_get_limit(v) || DEFAULT[:limit]
|
60
|
-
end
|
61
|
-
end
|
62
54
|
end
|
63
55
|
Backend.prepend BackendAddOn
|
64
56
|
end
|
@@ -38,8 +38,9 @@ class Pagy # :nodoc:
|
|
38
38
|
|
39
39
|
# Return Pagy object and results
|
40
40
|
def pagy_searchkick(pagy_search_args, **vars)
|
41
|
+
vars[:page] ||= pagy_get_page(vars)
|
42
|
+
vars[:limit] ||= pagy_get_limit(vars)
|
41
43
|
model, term, options, block, *called = pagy_search_args
|
42
|
-
vars = pagy_searchkick_get_vars(nil, vars)
|
43
44
|
options[:per_page] = vars[:limit]
|
44
45
|
options[:page] = vars[:page]
|
45
46
|
results = model.send(DEFAULT[:searchkick_search], term, **options, &block)
|
@@ -52,15 +53,6 @@ class Pagy # :nodoc:
|
|
52
53
|
|
53
54
|
[pagy, called.empty? ? results : results.send(*called)]
|
54
55
|
end
|
55
|
-
|
56
|
-
# Sub-method called only by #pagy_searchkick: here for easy customization of variables by overriding
|
57
|
-
# the _collection argument is not available when the method is called
|
58
|
-
def pagy_searchkick_get_vars(_collection, vars)
|
59
|
-
vars.tap do |v|
|
60
|
-
v[:page] ||= pagy_get_page(v)
|
61
|
-
v[:limit] ||= pagy_get_limit(v) || DEFAULT[:limit]
|
62
|
-
end
|
63
|
-
end
|
64
56
|
end
|
65
57
|
Backend.prepend BackendAddOn
|
66
58
|
end
|
data/lib/pagy/i18n.rb
CHANGED
data/lib/pagy.rb
CHANGED
@@ -6,7 +6,7 @@ require_relative 'pagy/shared_methods'
|
|
6
6
|
|
7
7
|
# Top superclass: it should define only what's common to all the subclasses
|
8
8
|
class Pagy
|
9
|
-
VERSION = '9.0.
|
9
|
+
VERSION = '9.0.3'
|
10
10
|
|
11
11
|
# Core default: constant for easy access, but mutable for customizable defaults
|
12
12
|
DEFAULT = { count_args: [:all], # rubocop:disable Style/MutableConstant
|
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: 9.0.
|
4
|
+
version: 9.0.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: 2024-07-
|
11
|
+
date: 2024-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Agnostic pagination in plain ruby. It does it all. Better.
|
14
14
|
email:
|
@@ -25,19 +25,9 @@ files:
|
|
25
25
|
- apps/keyset_s.ru
|
26
26
|
- apps/rails.ru
|
27
27
|
- apps/repro.ru
|
28
|
-
- apps/tmp/calendar.sqlite3
|
29
|
-
- apps/tmp/calendar.sqlite3-shm
|
30
|
-
- apps/tmp/calendar.sqlite3-wal
|
31
|
-
- apps/tmp/local_secret.txt
|
32
|
-
- apps/tmp/pagy-keyset-ar.sqlite3
|
33
|
-
- apps/tmp/pagy-keyset-ar.sqlite3-shm
|
34
|
-
- apps/tmp/pagy-keyset-ar.sqlite3-wal
|
35
|
-
- apps/tmp/pagy-keyset-s.sqlite3
|
36
28
|
- bin/pagy
|
37
29
|
- config/pagy.rb
|
38
|
-
- javascripts/pagy-module.js
|
39
30
|
- javascripts/pagy.d.ts
|
40
|
-
- javascripts/pagy.js
|
41
31
|
- javascripts/pagy.min.js
|
42
32
|
- javascripts/pagy.min.js.map
|
43
33
|
- javascripts/pagy.mjs
|
data/apps/tmp/calendar.sqlite3
DELETED
Binary file
|
Binary file
|
Binary file
|
data/apps/tmp/local_secret.txt
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0db96a70cc96bc7061757f38eec002ce6b14c6d987c4373d79a9f48bdcb0a26f4e00c88eec7a18c496d2779eb277f8b4a85f41dcac4c85482c7d5dd7cf05ba87
|
Binary file
|
Binary file
|
File without changes
|
Binary file
|
data/javascripts/pagy-module.js
DELETED
@@ -1,100 +0,0 @@
|
|
1
|
-
const Pagy = (() => {
|
2
|
-
const rjsObserver = new ResizeObserver((entries) => entries.forEach((e) => e.target.querySelectorAll(".pagy-rjs").forEach((el) => el.pagyRender())));
|
3
|
-
const initNav = (el, [tokens, sequels, labelSequels, trimParam]) => {
|
4
|
-
const container = el.parentElement ?? el;
|
5
|
-
const widths = Object.keys(sequels).map((w) => parseInt(w)).sort((a, b) => b - a);
|
6
|
-
let lastWidth = -1;
|
7
|
-
const fillIn = (a, page, label) => a.replace(/__pagy_page__/g, page).replace(/__pagy_label__/g, label);
|
8
|
-
(el.pagyRender = function() {
|
9
|
-
const width = widths.find((w) => w < container.clientWidth) || 0;
|
10
|
-
if (width === lastWidth) {
|
11
|
-
return;
|
12
|
-
}
|
13
|
-
let html = tokens.before;
|
14
|
-
const series = sequels[width.toString()];
|
15
|
-
const labels = labelSequels?.[width.toString()] ?? series.map((l) => l.toString());
|
16
|
-
series.forEach((item, i) => {
|
17
|
-
const label = labels[i];
|
18
|
-
let filled;
|
19
|
-
if (typeof item === "number") {
|
20
|
-
filled = fillIn(tokens.a, item.toString(), label);
|
21
|
-
} else if (item === "gap") {
|
22
|
-
filled = tokens.gap;
|
23
|
-
} else {
|
24
|
-
filled = fillIn(tokens.current, item, label);
|
25
|
-
}
|
26
|
-
html += typeof trimParam === "string" && item == 1 ? trim(filled, trimParam) : filled;
|
27
|
-
});
|
28
|
-
html += tokens.after;
|
29
|
-
el.innerHTML = "";
|
30
|
-
el.insertAdjacentHTML("afterbegin", html);
|
31
|
-
lastWidth = width;
|
32
|
-
})();
|
33
|
-
if (el.classList.contains("pagy-rjs")) {
|
34
|
-
rjsObserver.observe(container);
|
35
|
-
}
|
36
|
-
};
|
37
|
-
const initCombo = (el, [url_token, trimParam]) => initInput(el, (inputValue) => [inputValue, url_token.replace(/__pagy_page__/, inputValue)], trimParam);
|
38
|
-
const initSelector = (el, [from, url_token, trimParam]) => {
|
39
|
-
initInput(el, (inputValue) => {
|
40
|
-
const page = Math.max(Math.ceil(from / parseInt(inputValue)), 1).toString();
|
41
|
-
const url = url_token.replace(/__pagy_page__/, page).replace(/__pagy_items__/, inputValue);
|
42
|
-
return [page, url];
|
43
|
-
}, trimParam);
|
44
|
-
};
|
45
|
-
const initInput = (el, getVars, trimParam) => {
|
46
|
-
const input = el.querySelector("input");
|
47
|
-
const link = el.querySelector("a");
|
48
|
-
const initial = input.value;
|
49
|
-
const action = function() {
|
50
|
-
if (input.value === initial) {
|
51
|
-
return;
|
52
|
-
}
|
53
|
-
const [min, val, max] = [input.min, input.value, input.max].map((n) => parseInt(n) || 0);
|
54
|
-
if (val < min || val > max) {
|
55
|
-
input.value = initial;
|
56
|
-
input.select();
|
57
|
-
return;
|
58
|
-
}
|
59
|
-
let [page, url] = getVars(input.value);
|
60
|
-
if (typeof trimParam === "string" && page === "1") {
|
61
|
-
url = trim(url, trimParam);
|
62
|
-
}
|
63
|
-
link.href = url;
|
64
|
-
link.click();
|
65
|
-
};
|
66
|
-
["change", "focus"].forEach((e) => input.addEventListener(e, () => input.select()));
|
67
|
-
input.addEventListener("focusout", action);
|
68
|
-
input.addEventListener("keypress", (e) => {
|
69
|
-
if (e.key === "Enter") {
|
70
|
-
action();
|
71
|
-
}
|
72
|
-
});
|
73
|
-
};
|
74
|
-
const trim = (a, param) => a.replace(new RegExp(`[?&]${param}=1\\b(?!&)|\\b${param}=1&`), "");
|
75
|
-
return {
|
76
|
-
version: "8.6.3",
|
77
|
-
init(arg) {
|
78
|
-
const target = arg instanceof Element ? arg : document;
|
79
|
-
const elements = target.querySelectorAll("[data-pagy]");
|
80
|
-
for (const el of elements) {
|
81
|
-
try {
|
82
|
-
const uint8array = Uint8Array.from(atob(el.getAttribute("data-pagy")), (c) => c.charCodeAt(0));
|
83
|
-
const [keyword, ...args] = JSON.parse(new TextDecoder().decode(uint8array));
|
84
|
-
if (keyword === "nav") {
|
85
|
-
initNav(el, args);
|
86
|
-
} else if (keyword === "combo") {
|
87
|
-
initCombo(el, args);
|
88
|
-
} else if (keyword === "selector") {
|
89
|
-
initSelector(el, args);
|
90
|
-
} else {
|
91
|
-
console.warn("Skipped Pagy.init() for: %o\nUnknown keyword '%s'", el, keyword);
|
92
|
-
}
|
93
|
-
} catch (err) {
|
94
|
-
console.warn("Skipped Pagy.init() for: %o\n%s", el, err);
|
95
|
-
}
|
96
|
-
}
|
97
|
-
}
|
98
|
-
};
|
99
|
-
})();
|
100
|
-
export default Pagy;
|
data/javascripts/pagy.js
DELETED
@@ -1,4 +0,0 @@
|
|
1
|
-
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)=>Q<F.clientWidth)||0;if(H===L)return;let M=D.before;const R=E[H.toString()],X=z?.[H.toString()]??R.map((Q)=>Q.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_items__/,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(T<L||T>H){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:"8.6.3",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)}}}})();
|
2
|
-
|
3
|
-
//# debugId=B9DC02765C7A5B6764756E2164756E21
|
4
|
-
//# sourceMappingURL=pagy.min.js.map
|