Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Mar 8, 2024
2 parents ccb935c + d649e43 commit 14a2778
Show file tree
Hide file tree
Showing 42 changed files with 525 additions and 559 deletions.
2 changes: 1 addition & 1 deletion .github/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
GEM=pagy
VERSION=7.0.9
VERSION=7.0.10
2 changes: 1 addition & 1 deletion .idea/runConfigurations/update_top100.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/version_bump_sh.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ If you upgrade from version `< 7.0.0` see the following:

<hr>

## Version 7.0.10

- Added name attribute to combo and items input tags; removed pagy_marked_link and refactored js input action

## Version 7.0.9

- Improve all pagy apps
Expand Down
2 changes: 1 addition & 1 deletion README.md

Large diffs are not rendered by default.

43 changes: 25 additions & 18 deletions apps/pagy_styles.ru
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ class Formatter
push.(tag)
elsif (match = input.match(PAIRED))
tag_start, name, block, tag_end, rest = match.captures
## Handle incomplete same-tag nesting
while block.scan(/<#{name}.*?>/).size > block.scan(tag_end).size
more, rest = rest.split(tag_end, 2)
block << tag_end << more
end
if name.eql?('a')
tag_start.gsub!(/[\s]+/, ' ')
tag_start.gsub!(/[\s]>/, '>')
Expand Down Expand Up @@ -213,58 +218,60 @@ __END__
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<%= erb :"#{style}_head" if defined?(style) %>
<style type="text/css">
@media screen { html {
font-size: 1em !important;
@media screen { html, body {
font-size: 1rem;
line-height: 1.2s;
padding: 0;
margin: 0;
} }
body {
background: white !important;
margin: 0 !important;
font-family: sans-serif !important;
font-size: 1em;
}
h1, h4 {
font-size: 1.8em !important;
font-size: 1.8rem !important;
font-weight: 600 !important;
margin-top: 1em !important;
margin-bottom: 0.5em !important;
margin-top: 1rem !important;
margin-bottom: 0.5rem !important;
line-height: 1.5 !important;
color: rgb(90 90 90) !important;
}
h4 {
font-size: 1em !important;
margin-top: 1.5em !important;
font-size: 1.05rem !important;
margin-top: 1.5rem !important;
}
summary {
font-size: .8em;
font-size: .8rem;
color: gray;
margin-top: .5rem;
font-style: italic;
cursor: pointer;
}
pre {
pre, pre code {
display: block;
margin-top: 0;
margin-top: .3rem;
margin-bottom: 1rem;
font-size: 1em;
font-size: .8rem !important;
line-heigth: 1rem !important;
color: white;
background-color: rgb(30 30 30);
padding: 1rem;
overflow: auto;
}
.content {
padding: 0 1rem 2rem !important;
font-size: 1em !important;
.content {
padding: 0 1.5rem 2rem !important;
}

#style-menu {
flex;
font-family: sans-serif;
font-size: 1.1em;
line-height: 1.5em;
font-size: 1.1rem;
line-height: 1.5rem;
white-space: nowrap;
color: white;
background-color: gray;
padding: .2em 1em;
padding: .2rem 1.5rem;
}
#style-menu > :not([hidden]) ~ :not([hidden]) {
--space-reverse: 0;
Expand Down
158 changes: 79 additions & 79 deletions e2e/snapshots.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/config/pagy.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

# Pagy initializer file (7.0.9)
# Pagy initializer file (7.0.10)
# 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

Expand Down
19 changes: 9 additions & 10 deletions lib/javascripts/pagy-dev.js

Large diffs are not rendered by default.

17 changes: 8 additions & 9 deletions lib/javascripts/pagy-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ const Pagy = (() => {
}
};
// Init the *_combo_nav_js helpers
const initCombo = (el, [link, trimParam]) => initInput(el, inputValue => [inputValue, link.replace(/__pagy_page__/, inputValue)], trimParam);
const initCombo = (el, [url_token, trimParam]) => initInput(el, inputValue => [inputValue, url_token.replace(/__pagy_page__/, inputValue)], trimParam);
// Init the items_selector_js helper
const initSelector = (el, [from, link, trimParam]) => {
const initSelector = (el, [from, url_token, trimParam]) => {
initInput(el, inputValue => {
const page = Math.max(Math.ceil(from / parseInt(inputValue)), 1).toString();
const html = link.replace(/__pagy_page__/, page).replace(/__pagy_items__/, inputValue);
return [page, html];
const url = url_token.replace(/__pagy_page__/, page).replace(/__pagy_items__/, inputValue);
return [page, url];
}, trimParam);
};
// Init the input element
Expand All @@ -63,12 +63,11 @@ const Pagy = (() => {
input.select();
return;
}
let [page, html] = getVars(input.value); // eslint-disable-line prefer-const
let [page, url] = getVars(input.value); // eslint-disable-line prefer-const
if (typeof trimParam === "string" && page === "1") {
html = trim(html, trimParam);
url = trim(url, trimParam);
}
el.insertAdjacentHTML("afterbegin", html);
el.querySelector("a").click();
window.location.href = url;
};
["change", "focus"].forEach(e => input.addEventListener(e, input.select)); // auto-select
input.addEventListener("focusout", action); // trigger action
Expand All @@ -80,7 +79,7 @@ const Pagy = (() => {
const trim = (link, param) => link.replace(new RegExp(`[?&]${param}=1\\b(?!&)|\\b${param}=1&`), "");
// Public interface
return {
version: "7.0.9",
version: "7.0.10",
// Scan for elements with a "data-pagy" attribute and call their init functions with the decoded args
init(arg) {
const target = arg instanceof Element ? arg : document;
Expand Down
2 changes: 1 addition & 1 deletion lib/javascripts/pagy.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/pagy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Core class
class Pagy
VERSION = '7.0.9'
VERSION = '7.0.10'

# Root pathname to get the path of Pagy files like templates or dictionaries
def self.root
Expand Down
4 changes: 2 additions & 2 deletions lib/pagy/extras/bootstrap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ def pagy_bootstrap_combo_nav_js(pagy, pagy_id: nil, link_extra: '',
link = pagy_link_proc(pagy, link_extra:)
p_page = pagy.page
p_pages = pagy.pages
input = %(<input type="number" min="1" max="#{p_pages}" value="#{
input = %(<input name="page" type="number" min="1" max="#{p_pages}" value="#{
p_page}" style="padding: 0; border: none; text-align: center; width: #{
p_pages.to_s.length + 1}rem;" aria-current="page">)

%(<nav#{p_id} class="pagy-bootstrap-combo-nav-js pagination" #{
nav_aria_label_attr(pagy, nav_aria_label, nav_i18n_key)} #{
pagy_data(pagy, :combo, pagy_marked_link(link)) }><div class="btn-group" role="group">#{
pagy_data(pagy, :combo, pagy_url_for(pagy, PAGE_TOKEN)) }><div class="btn-group" role="group">#{
if (p_prev = pagy.prev)
link.call(p_prev, pagy_t('pagy.prev'), %(class="prev btn btn-primary" #{prev_aria_label_attr}))
else
Expand Down
4 changes: 2 additions & 2 deletions lib/pagy/extras/bulma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ def pagy_bulma_combo_nav_js(pagy, pagy_id: nil, link_extra: '',
link = pagy_link_proc(pagy, link_extra:)
p_page = pagy.page
p_pages = pagy.pages
input = %(<input class="input" type="number" min="1" max="#{p_pages}" value="#{
input = %(<input name="page" class="input" type="number" min="1" max="#{p_pages}" value="#{
p_page}" style="padding: 0; text-align: center; width: #{
p_pages.to_s.length + 1}rem; margin:0 0.3rem;" aria-current="page">)

html = %(<nav#{p_id} class="pagy-bulma-combo-nav-js #{DEFAULT[:bulma_nav_classes]}" #{
nav_aria_label_attr(pagy, nav_aria_label, nav_i18n_key)} #{
pagy_data(pagy, :combo, pagy_marked_link(link))}>)
pagy_data(pagy, :combo, pagy_url_for(pagy, PAGE_TOKEN))}>)
%(#{html}<div class="field is-grouped is-grouped-centered" role="group">#{
if (p_prev = pagy.prev)
%(<p class="control">#{link.call(p_prev, pagy_t('pagy.prev'), %(class="button" #{prev_aria_label_attr}))}</p>)
Expand Down
4 changes: 2 additions & 2 deletions lib/pagy/extras/foundation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ def pagy_foundation_combo_nav_js(pagy, pagy_id: nil, link_extra: '',
link = pagy_link_proc(pagy, link_extra:)
p_page = pagy.page
p_pages = pagy.pages
input = %(<input class="input-group-field cell shrink" type="number" min="1" max="#{
input = %(<input name="page" class="input-group-field cell shrink" type="number" min="1" max="#{
p_pages}" value="#{p_page}" style="width: #{
p_pages.to_s.length + 1}rem; padding: 0 0.3rem; margin: 0 0.3rem;" aria-current="page">)

%(<nav#{p_id} class="pagy-foundation-combo-nav-js" #{
nav_aria_label_attr(pagy, nav_aria_label, nav_i18n_key)} #{
pagy_data(pagy, :combo, pagy_marked_link(link))}><div class="input-group">#{
pagy_data(pagy, :combo, pagy_url_for(pagy, PAGE_TOKEN))}><div class="input-group">#{
if (p_prev = pagy.prev)
link.call(p_prev, pagy_t('pagy.prev'),
%(style="margin-bottom: 0" class="prev button primary" #{prev_aria_label_attr}))
Expand Down
5 changes: 0 additions & 5 deletions lib/pagy/extras/frontend_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ def pagy_data(pagy, *args)
%(data-pagy="#{strict_base64_encoded}")
end
end

# Return the marked link used by pagy.js
def pagy_marked_link(link)
link.call PAGE_TOKEN, '', 'style="display: none;"'
end
end
Frontend.prepend FrontendAddOn
end
Expand Down
8 changes: 4 additions & 4 deletions lib/pagy/extras/items.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ module FrontendAddOn
ITEMS_PLACEHOLDER = '__pagy_items__'

# Return the items selector HTML. For example "Show [20] items per page"
def pagy_items_selector_js(pagy, pagy_id: nil, item_name: nil, item_i18n_key: nil, link_extra: '')
def pagy_items_selector_js(pagy, pagy_id: nil, item_name: nil, item_i18n_key: nil)
return '' unless pagy.vars[:items_extra]

p_id = %( id="#{pagy_id}") if pagy_id
p_vars = pagy.vars
p_items = p_vars[:items]
p_vars[:items] = ITEMS_PLACEHOLDER
link = pagy_marked_link(pagy_link_proc(pagy, link_extra:))
url_token = pagy_url_for(pagy, PAGE_TOKEN)
p_vars[:items] = p_items # restore the items

html = +%(<span#{p_id} class="pagy pagy-items-selector-js" #{pagy_data(pagy, :selector, pagy.from, link)}>)
input = %(<input type="number" min="1" max="#{p_vars[:max_items]}" value="#{
html = +%(<span#{p_id} class="pagy pagy-items-selector-js" #{pagy_data(pagy, :selector, pagy.from, url_token)}>)
input = %(<input name="items" type="number" min="1" max="#{p_vars[:max_items]}" value="#{
p_items}" style="padding: 0; text-align: center; width: #{p_items.to_s.length + 1}rem;">)
html << pagy_t('pagy.items_selector_js',
item_name: item_name || pagy_t(item_i18n_key || p_vars[:item_i18n_key], count: p_items),
Expand Down
4 changes: 2 additions & 2 deletions lib/pagy/extras/materialize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ def pagy_materialize_combo_nav_js(pagy, pagy_id: nil, link_extra: '',
p_page = pagy.page
p_pages = pagy.pages
style = ' style="vertical-align: middle"'
input = %(<input type="number" class="browser-default" min="1" max="#{p_pages}" value="#{
input = %(<input name="page" type="number" class="browser-default" min="1" max="#{p_pages}" value="#{
p_page}" style="text-align: center; width: #{p_pages.to_s.length + 1}rem;" aria-current="page">)

html = %(<ul#{p_id} class="pagy-materialize-combo-nav-js pagination chip" role="navigation" #{
nav_aria_label_attr(pagy, nav_aria_label, nav_i18n_key)})
%(#{html} style="padding-right: 0" #{
pagy_data(pagy, :combo, pagy_marked_link(link))}>#{
pagy_data(pagy, :combo, pagy_url_for(pagy, PAGE_TOKEN))}>#{
materialize_prev_html pagy, link, style}<li class="pagy-combo-input">#{
pagy_t 'pagy.combo_nav_js', page_input: input, count: p_page, pages: p_pages}</li>#{
materialize_next_html pagy, link, style}</ul>)
Expand Down
4 changes: 2 additions & 2 deletions lib/pagy/extras/navs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ def pagy_combo_nav_js(pagy, pagy_id: nil, link_extra: '',
link = pagy_link_proc(pagy, link_extra:)
p_page = pagy.page
p_pages = pagy.pages
input = %(<input type="number" min="1" max="#{p_pages}" value="#{p_page}" ) +
input = %(<input name="page" type="number" min="1" max="#{p_pages}" value="#{p_page}" ) +
%(style="padding: 0; text-align: center; width: #{p_pages.to_s.length + 1}rem;" aria-current="page">)

%(<nav#{p_id} class="pagy pagy-combo-nav-js pagination" #{
nav_aria_label_attr(pagy, nav_aria_label, nav_i18n_key)} #{
pagy_data(pagy, :combo, pagy_marked_link(link))}>#{
pagy_data(pagy, :combo, pagy_url_for(pagy, PAGE_TOKEN))}>#{
prev_html(pagy, link)
}<span class="pagy-combo-input">#{
pagy_t('pagy.combo_nav_js', page_input: input, count: p_page, pages: p_pages)
Expand Down
4 changes: 2 additions & 2 deletions lib/pagy/extras/semantic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ def pagy_semantic_combo_nav_js(pagy, pagy_id: nil, link_extra: '',
link = pagy_link_proc(pagy, link_extra: %(class="item" #{link_extra}))
p_page = pagy.page
p_pages = pagy.pages
input = %(<input type="number" min="1" max="#{p_pages}" value="#{
input = %(<input name="page" type="number" min="1" max="#{p_pages}" value="#{
p_page}" style="padding: 0; text-align: center; width: #{
p_pages.to_s.length + 1}rem; margin: 0 0.3rem" aria-current="page">)

%(<div#{p_id} class="pagy-semantic-combo-nav-js ui compact menu" role="navigation" #{
nav_aria_label_attr(pagy, nav_aria_label, nav_i18n_key)} #{
pagy_data(pagy, :combo, pagy_marked_link(link))}>#{
pagy_data(pagy, :combo, pagy_url_for(pagy, PAGE_TOKEN))}>#{
semantic_prev_html pagy, link
}<div class="pagy-combo-input item">#{
pagy_t 'pagy.combo_nav_js', page_input: input, count: p_page, pages: p_pages
Expand Down
4 changes: 2 additions & 2 deletions lib/pagy/extras/uikit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ def pagy_uikit_combo_nav_js(pagy, pagy_id: nil, link_extra: '',
link = pagy_link_proc(pagy, link_extra:)
p_page = pagy.page
p_pages = pagy.pages
input = %(<input type="number" min="1" max="#{p_pages}" value="#{
input = %(<input name="page" type="number" min="1" max="#{p_pages}" value="#{
p_page}" style="text-align: center; width: #{p_pages.to_s.length + 1}rem;" aria-current="page">)

%(<ul#{p_id} class="pagy-uikit-combo-nav-js uk-button-group uk-pagination uk-flex-center" role="navigation" #{
nav_aria_label_attr(pagy, nav_aria_label, nav_i18n_key)} #{
pagy_data(pagy, :combo, pagy_marked_link(link))
pagy_data(pagy, :combo, pagy_url_for(pagy, PAGE_TOKEN))
}>#{
uikit_prev_html pagy, link
}<li>#{
Expand Down
2 changes: 1 addition & 1 deletion retype.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ url: https://ddnexus.github.io/pagy

branding:
title: Pagy
label: 7.0.9
label: 7.0.10
colors:
label:
text: "#FFFFFF"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion script/version-bump.sh → scripts/version-bump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ bundle exec ruby -Itest test/pagy_test.rb --name "/pagy::Version match(#|::)/"
# Optional update of top 100
read -rp 'Do you want to update the "Top 100 contributors"? (y/n)> ' input
if [[ $input = y ]] || [[ $input = Y ]]; then
bundle exec "$ROOT/script/update_top100.rb"
bundle exec "$ROOT/scripts/update_top100.rb"
fi

## Optional show diff
Expand Down
Loading

0 comments on commit 14a2778

Please sign in to comment.