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 5, 2024
2 parents c5b71e2 + 1818551 commit ccb935c
Show file tree
Hide file tree
Showing 23 changed files with 338 additions and 270 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.8
VERSION=7.0.9
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ Style/CommentedKeyword:
Enabled: false
Style/EmptyCaseCondition:
Enabled: false
Style/LambdaCall:
Enabled: false

# cannot inline the disabling in the file because rubocop complains anyway
Style/RedundantInitialize:
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ If you upgrade from version `< 7.0.0` see the following:

<hr>

## Version 7.0.9

- Improve all pagy apps
- Normalized bootstrap, bulma, foundation, navs extra

## Version 7.0.8

- Update gems and fix a rubocop bug
Expand Down
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ group :test do
end

group :apps do
gem 'nokogiri'
gem 'puma'
gem 'rerun'
gem 'rouge'
Expand Down
3 changes: 0 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ GEM
ruby2_keywords (~> 0.0.1)
mutex_m (0.2.0)
nio4r (2.7.0)
nokogiri (1.16.2-x86_64-linux)
racc (~> 1.4)
oj (3.16.3)
bigdecimal (>= 3.0)
parallel (1.24.0)
Expand Down Expand Up @@ -161,7 +159,6 @@ DEPENDENCIES
memory_profiler
minitest
minitest-reporters
nokogiri
oj
puma
rack
Expand Down
2 changes: 1 addition & 1 deletion README.md

Large diffs are not rendered by default.

67 changes: 61 additions & 6 deletions apps/pagy_styles.ru
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ else
require 'bundler/inline'
gemfile true do
source 'https://rubygems.org'
gem 'nokogiri'
gem 'oj'
gem 'pagy'
gem 'puma'
Expand Down Expand Up @@ -113,15 +112,70 @@ class PagyStyles < Sinatra::Base
end

def highlight(html)
# Crappy nokogiri cannot configure NOENT option to avoid expanding & in &amp;!!!
indented = Nokogiri::HTML5.fragment(html).to_xhtml.gsub('&amp;', '&')
formatted = Formatter.new.format(html)
lexer = Rouge::Lexers::HTML.new
formatter = Rouge::Formatters::HTMLInline.new('monokai')
%(<details><summary>HTML</summary><pre>#{formatter.format(lexer.lex(indented))}</pre></details>)
%(<details><summary>Served HTML (pretty formatted)</summary><pre>\n#{
formatter.format(lexer.lex(formatted))
}</pre></details>)
end
end
end

# Cheap pagy formatter for helpers output
class Formatter
INDENT = ' '
TEXT_SPACE = "\u00B7"
TEXT = /^([^<>]+)(.*)/
UNPAIRED = /^(<(input).*?>)(.*)/
PAIRED = %r{^(<(nav|div|span|p|a|b|label|ul|li).*?>)(.*?)(</\2>)(.*)}
WRAPPER = /<.*?>/
DATA_PAGY = /(data-pagy="([^"]+)")/

def initialize
@formatted = +''
end

def format(input, level = 0)
process(input, level)
@formatted
end

private

def process(input, level)
push = ->(content) { @formatted << ((INDENT * level) + content + "\n") }
rest = nil
if (match = input.match(TEXT))
text, rest = match.captures
push.(text.gsub(' ', TEXT_SPACE))
elsif (match = input.match(UNPAIRED))
tag, _name, rest = match.captures
push.(tag)
elsif (match = input.match(PAIRED))
tag_start, name, block, tag_end, rest = match.captures
if name.eql?('a')
tag_start.gsub!(/[\s]+/, ' ')
tag_start.gsub!(/[\s]>/, '>')
end
if (match = tag_start.match(DATA_PAGY))
search, data = match.captures
formatted = data.scan(/.{1,76}/).join("\n")
replace = %(\n#{INDENT * (level + 1)}data-pagy="#{formatted}")
tag_start.sub!(search, replace)
end
if block.match(WRAPPER)
push.(tag_start)
process(block, level + 1)
push.(tag_end)
else
push.(tag_start + block + tag_end)
end
end
process(rest, level) if rest
end
end

# Simple array-based collection that acts as a standard DB collection.
class MockCollection < Array
def initialize(arr = Array(1..1000))
Expand Down Expand Up @@ -159,7 +213,7 @@ __END__
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<%= erb :"#{style}_head" if defined?(style) %>
<style type="text/css">
@media only screen { html {
@media screen { html {
font-size: 1em !important;
} }
body {
Expand Down Expand Up @@ -198,7 +252,8 @@ __END__
overflow: auto;
}
.content {
padding: 0 1rem !important;
padding: 0 1rem 2rem !important;
font-size: 1em !important;
}

#style-menu {
Expand Down
92 changes: 46 additions & 46 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.8)
# Pagy initializer file (7.0.9)
# 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
4 changes: 2 additions & 2 deletions lib/javascripts/pagy-dev.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/javascripts/pagy-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const Pagy = (() => {
const trim = (link, param) => link.replace(new RegExp(`[?&]${param}=1\\b(?!&)|\\b${param}=1&`), "");
// Public interface
return {
version: "7.0.8",
version: "7.0.9",
// 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.8'
VERSION = '7.0.9'

# Root pathname to get the path of Pagy files like templates or dictionaries
def self.root
Expand Down
6 changes: 3 additions & 3 deletions lib/pagy/extras/bootstrap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ def pagy_bootstrap_combo_nav_js(pagy, pagy_id: nil, link_extra: '',
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)}><div class="btn-group" role="group" #{
pagy_data(pagy, :combo, pagy_marked_link(link))}>#{
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">#{
if (p_prev = pagy.prev)
link.call(p_prev, pagy_t('pagy.prev'), %(class="prev btn btn-primary" #{prev_aria_label_attr}))
else
Expand All @@ -90,7 +90,7 @@ def bootstrap_prev_html(pagy, link)
if (p_prev = pagy.prev)
%(<li class="page-item prev">#{link.call(p_prev, pagy_t('pagy.prev'), prev_aria_label_attr)}</li>)
else
%(<li class="page-item prev disabled"><a role="link"class="page-link" aria-disabled="true" #{
%(<li class="page-item prev disabled"><a role="link" class="page-link" aria-disabled="true" #{
prev_aria_label_attr}>#{pagy_t('pagy.prev')}</a></li>)
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/pagy/extras/bulma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ def pagy_bulma_combo_nav_js(pagy, pagy_id: nil, link_extra: '',
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)}>)
%(#{html}<div class="field is-grouped is-grouped-centered" role="group" #{
pagy_data(pagy, :combo, pagy_marked_link(link))}>#{
nav_aria_label_attr(pagy, nav_aria_label, nav_i18n_key)} #{
pagy_data(pagy, :combo, pagy_marked_link(link))}>)
%(#{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>)
else
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 @@ -61,8 +61,8 @@ def pagy_foundation_combo_nav_js(pagy, pagy_id: nil, link_extra: '',
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)}><div class="input-group" #{
pagy_data(pagy, :combo, pagy_marked_link(link))}>#{
nav_aria_label_attr(pagy, nav_aria_label, nav_i18n_key)} #{
pagy_data(pagy, :combo, pagy_marked_link(link))}><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
2 changes: 1 addition & 1 deletion lib/pagy/extras/navs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def pagy_combo_nav_js(pagy, pagy_id: nil, link_extra: '',
prev_html(pagy, link)
}<span class="pagy-combo-input">#{
pagy_t('pagy.combo_nav_js', page_input: input, count: p_page, pages: p_pages)
}</span> #{
}</span>#{
next_html(pagy, link)
}</nav>)
end
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.8
label: 7.0.9
colors:
label:
text: "#FFFFFF"
Expand Down
2 changes: 1 addition & 1 deletion src/pagy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const Pagy = (() => {

// Public interface
return {
version: "7.0.8",
version: "7.0.9",

// Scan for elements with a "data-pagy" attribute and call their init functions with the decoded args
init(arg?:Element | never) {
Expand Down
Loading

0 comments on commit ccb935c

Please sign in to comment.