Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Nov 6, 2019
2 parents 224748a + 91da776 commit 0aa603e
Show file tree
Hide file tree
Showing 21 changed files with 78 additions and 28 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,27 @@
# CHANGELOG

## Version 3.7.0

### Changes

- updated French and Spanish translations
- added Italian translation
- interenal renaming `Pagy::Frontend::MARK` > `Pagy::PAGE_PLACEHOLDER`

### Commits

- [434912b](http://github.com/ddnexus/pagy/commit/434912b): updated rubyzip gem
- [b627e55](http://github.com/ddnexus/pagy/commit/b627e55): add italian translation (#202)
- [3341dcc](http://github.com/ddnexus/pagy/commit/3341dcc): created ITEMS_PLACEHOLDER constant
- [7775155](http://github.com/ddnexus/pagy/commit/7775155): replaced Pagy::Frontend::MARK with Pagy::PAGE_PLACEHOLDER (MARK is still defined for backward compatibility)
- [439676e](http://github.com/ddnexus/pagy/commit/439676e): Fixed previous translation for Spanish (#199)
- [ee1b1f0](http://github.com/ddnexus/pagy/commit/ee1b1f0): Update fr.yml (#195)
- [8b6f81f](http://github.com/ddnexus/pagy/commit/8b6f81f): added pagy-cursor link in README
- [c290dca](http://github.com/ddnexus/pagy/commit/c290dca): update incorrect tutorial link (#198)
- [77c045d](http://github.com/ddnexus/pagy/commit/77c045d): add: tutorial link in ReadMe - complex search forms (#194)
- [846eece](http://github.com/ddnexus/pagy/commit/846eece): fix in README.md
- [224748a](http://github.com/ddnexus/pagy/commit/224748a): fix for resurrected-by-mistake line in README

## Version 3.6.0

### Changes
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -26,4 +26,5 @@ gem 'codecov', :require => false
# gem 'memory_profiler'

# docs server
gem "rubyzip", ">= 1.3.0"
gem "github-pages", '198', group: :jekyll_plugins
3 changes: 2 additions & 1 deletion Gemfile.lock
Expand Up @@ -251,7 +251,7 @@ GEM
i18n
ruby-progressbar (1.10.1)
ruby_dep (1.5.0)
rubyzip (1.2.3)
rubyzip (2.0.0)
safe_yaml (1.0.5)
sass (3.7.4)
sass-listen (~> 4.0.0)
Expand Down Expand Up @@ -290,6 +290,7 @@ DEPENDENCIES
rake
rubocop (~> 0.75.0)
rubocop-performance (~> 1.5.0)
rubyzip (>= 1.3.0)
simplecov

BUNDLED WITH
Expand Down
2 changes: 1 addition & 1 deletion lib/config/pagy.rb
@@ -1,7 +1,7 @@
# encoding: utf-8
# frozen_string_literal: true

# Pagy initializer file (3.6.0)
# Pagy initializer file (3.7.0)
# Customize only what you really need and notice that 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
2 changes: 1 addition & 1 deletion lib/javascripts/pagy.js
Expand Up @@ -2,7 +2,7 @@

function Pagy(){}

Pagy.version = '3.6.0';
Pagy.version = '3.7.0';

Pagy.init = function(arg){
var target = arg instanceof Event || arg === undefined ? document : arg,
Expand Down
2 changes: 1 addition & 1 deletion lib/locales/es.yml
Expand Up @@ -8,7 +8,7 @@ es:
other: "ítems"

nav:
prev: "‹ Prev"
prev: "‹ Anterior"
next: "Siguiente ›"
gap: "…"

Expand Down
4 changes: 2 additions & 2 deletions lib/locales/fr.yml
Expand Up @@ -4,8 +4,8 @@ fr:
pagy:

item_name:
one: "élement"
other: "élements"
one: "élément"
other: "éléments"

nav:
prev: "‹ Précédent"
Expand Down
22 changes: 22 additions & 0 deletions lib/locales/it.yml
@@ -0,0 +1,22 @@
# :one_other pluralization (see https://github.com/ddnexus/pagy/blob/master/lib/locales/utils/p11n.rb)

it:
pagy:

item_name:
one: "elemento"
other: "elementi"

nav:
prev: "‹ Precedente"
next: "Seguente ›"
gap: "…"

info:
no_items: "Nessun %{item_name} trovato"
single_page: "Visualizzazione di <b>%{count}</b> %{item_name}"
multiple_pages: "Visualizzazione %{item_name} <b>%{from}-%{to}</b> di <b>%{count}</b> in totale"

combo_nav_js: "Pagina %{page_input} di %{pages}"

items_selector_js: "Mostra %{items_input} %{item_name} per pagina"
2 changes: 1 addition & 1 deletion lib/pagy.rb
Expand Up @@ -4,7 +4,7 @@

require 'pathname'

class Pagy ; VERSION = '3.6.0'
class Pagy ; VERSION = '3.7.0'

# Root pathname to get the path of Pagy files like templates or dictionaries
def self.root; @root ||= Pathname.new(__FILE__).dirname.freeze end
Expand Down
2 changes: 1 addition & 1 deletion lib/pagy/extras/bootstrap.rb
Expand Up @@ -29,7 +29,7 @@ def pagy_bootstrap_nav_js(pagy, id=pagy_id)
link, p_prev, p_next = pagy_link_proc(pagy, 'class="page-link"'), pagy.prev, pagy.next
tags = { 'before' => p_prev ? %(<ul class="pagination"><li class="page-item prev">#{link.call p_prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"'}</li>)
: %(<ul class="pagination"><li class="page-item prev disabled"><a href="#" class="page-link">#{pagy_t('pagy.nav.prev')}</a></li>),
'link' => %(<li class="page-item">#{mark = link.call(MARK)}</li>),
'link' => %(<li class="page-item">#{mark = link.call(PAGE_PLACEHOLDER)}</li>),
'active' => %(<li class="page-item active">#{mark}</li>),
'gap' => %(<li class="page-item gap disabled"><a href="#" class="page-link">#{pagy_t('pagy.nav.gap')}</a></li>),
'after' => p_next ? %(<li class="page-item next">#{link.call p_next, pagy_t('pagy.nav.next'), 'aria-label="next"'}</li></ul>)
Expand Down
4 changes: 2 additions & 2 deletions lib/pagy/extras/bulma.rb
Expand Up @@ -34,8 +34,8 @@ def pagy_bulma_nav_js(pagy, id=pagy_id)
+ (p_next ? link.call(p_next, pagy_t('pagy.nav.next'), 'class="pagination-next" aria-label="next page"')
: %(<a class="pagination-next" disabled>#{pagy_t('pagy.nav.next')}</a>)) \
+ '<ul class="pagination-list">' ),
'link' => %(<li>#{link.call(MARK, MARK, %(class="pagination-link" aria-label="goto page #{MARK}"))}</li>),
'active' => %(<li>#{link.call(MARK, MARK, %(class="pagination-link is-current" aria-current="page" aria-label="page #{MARK}"))}</li>),
'link' => %(<li>#{link.call(PAGE_PLACEHOLDER, PAGE_PLACEHOLDER, %(class="pagination-link" aria-label="goto page #{PAGE_PLACEHOLDER}"))}</li>),
'active' => %(<li>#{link.call(PAGE_PLACEHOLDER, PAGE_PLACEHOLDER, %(class="pagination-link is-current" aria-current="page" aria-label="page #{PAGE_PLACEHOLDER}"))}</li>),
'gap' => %(<li><span class="pagination-ellipsis">#{pagy_t('pagy.nav.gap')}</span></li>),
'after' => '</ul>' }
%(<nav id="#{id}" class="pagy-bulma-nav-js pagination is-centered" role="navigation" aria-label="pagination"></nav>#{pagy_json_tag(:nav, id, tags, pagy.sequels, defined?(TRIM) && pagy.vars[:page_param])})
Expand Down
2 changes: 1 addition & 1 deletion lib/pagy/extras/foundation.rb
Expand Up @@ -30,7 +30,7 @@ def pagy_foundation_nav_js(pagy, id=pagy_id)
tags = { 'before' => ( '<ul class="pagination">' \
+ (p_prev ? %(<li class="prev">#{link.call(p_prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"')}</li>)
: %(<li class="prev disabled">#{pagy_t('pagy.nav.prev')}</li>)) ),
'link' => %(<li>#{link.call(MARK)}</li>),
'link' => %(<li>#{link.call(PAGE_PLACEHOLDER)}</li>),
'active' => %(<li class="current">#{pagy.page}</li>),
'gap' => %(<li class="ellipsis gap" aria-hidden="true"></li>),
'after' => ( (p_next ? %(<li class="next">#{link.call(p_next, pagy_t('pagy.nav.next'), 'aria-label="next"')}</li>)
Expand Down
4 changes: 2 additions & 2 deletions lib/pagy/extras/headers.rb
Expand Up @@ -23,8 +23,8 @@ def pagy_headers(pagy)
def pagy_headers_hash(pagy)
countless = defined?(Pagy::Countless) && pagy.is_a?(Pagy::Countless)
rels = { 'first' => 1, 'prev' => pagy.prev, 'next' => pagy.next }; rels['last'] = pagy.last unless countless
url_str = pagy_url_for(Frontend::MARK, pagy, :url)
hash = { 'Link' => Hash[rels.map{|rel, n|[rel, url_str.sub(Frontend::MARK, n.to_s)] if n}.compact] }
url_str = pagy_url_for(PAGE_PLACEHOLDER, pagy, :url)
hash = { 'Link' => Hash[rels.map{|rel, n|[rel, url_str.sub(PAGE_PLACEHOLDER, n.to_s)] if n}.compact] }
headers = pagy.vars[:headers]
hash[headers[:page]] = pagy.page if headers[:page]
hash[headers[:items]] = pagy.vars[:items] if headers[:items]
Expand Down
4 changes: 3 additions & 1 deletion lib/pagy/extras/items.rb
Expand Up @@ -10,6 +10,8 @@ class Pagy
VARS[:items_param] = :items
VARS[:max_items] = 100

ITEMS_PLACEHOLDER = '__pagy_items__'

# Handle a custom number of :items from params
module Backend ; private

Expand Down Expand Up @@ -49,7 +51,7 @@ def pagy_url_for_with_items(page, pagy, url=false)
def pagy_items_selector_js(pagy, id=pagy_id)
p_vars = pagy.vars
p_items = p_vars[:items]
p_vars[:items] = '__pagy_items__'
p_vars[:items] = ITEMS_PLACEHOLDER
link = pagy_marked_link(pagy_link_proc(pagy))
p_vars[:items] = p_items # restore the items

Expand Down
2 changes: 1 addition & 1 deletion lib/pagy/extras/materialize.rb
Expand Up @@ -29,7 +29,7 @@ def pagy_materialize_nav_js(pagy, id=pagy_id)
tags = { 'before' => ( '<ul class="pagination">' \
+ (p_prev ? %(<li class="waves-effect prev">#{link.call(p_prev, '<i class="material-icons">chevron_left</i>', 'aria-label="previous"')}</li>)
: %(<li class="prev disabled"><a href="#"><i class="material-icons">chevron_left</i></a></li>)) ),
'link' => %(<li class="waves-effect">#{mark = link.call(MARK)}</li>),
'link' => %(<li class="waves-effect">#{mark = link.call(PAGE_PLACEHOLDER)}</li>),
'active' => %(<li class="active">#{mark}</li>),
'gap' => %(<li class="gap disabled"><a href="#">#{pagy_t('pagy.nav.gap')}</a></li>),
'after' => ( (p_next ? %(<li class="waves-effect next">#{link.call(p_next, '<i class="material-icons">chevron_right</i>', 'aria-label="next"')}</li>)
Expand Down
12 changes: 6 additions & 6 deletions lib/pagy/extras/metadata.rb
Expand Up @@ -17,16 +17,16 @@ module Backend ; private
def pagy_metadata(pagy, url=false)
names = pagy.vars[:metadata]
(unknown = names - METADATA).empty? or raise(VariableError.new(pagy), "unknown metadata #{unknown.inspect}")
scaffold_url = pagy_url_for(Frontend::MARK, pagy, url)
scaffold_url = pagy_url_for(PAGE_PLACEHOLDER, pagy, url)
metadata = {}
names.each do |key|
metadata[key] = case key
when :scaffold_url ; scaffold_url
when :first_url ; scaffold_url.sub(Frontend::MARK, 1.to_s)
when :prev_url ; scaffold_url.sub(Frontend::MARK, pagy.prev.to_s)
when :page_url ; scaffold_url.sub(Frontend::MARK, pagy.page.to_s)
when :next_url ; scaffold_url.sub(Frontend::MARK, pagy.next.to_s)
when :last_url ; scaffold_url.sub(Frontend::MARK, pagy.last.to_s)
when :first_url ; scaffold_url.sub(PAGE_PLACEHOLDER, 1.to_s)
when :prev_url ; scaffold_url.sub(PAGE_PLACEHOLDER, pagy.prev.to_s)
when :page_url ; scaffold_url.sub(PAGE_PLACEHOLDER, pagy.page.to_s)
when :next_url ; scaffold_url.sub(PAGE_PLACEHOLDER, pagy.next.to_s)
when :last_url ; scaffold_url.sub(PAGE_PLACEHOLDER, pagy.last.to_s)
else pagy.send(key)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/pagy/extras/navs.rb
Expand Up @@ -12,7 +12,7 @@ def pagy_nav_js(pagy, id=pagy_id)
link, p_prev, p_next = pagy_link_proc(pagy), pagy.prev, pagy.next
tags = { 'before' => p_prev ? %(<span class="page prev">#{link.call p_prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"'}</span> )
: %(<span class="page prev disabled">#{pagy_t('pagy.nav.prev')}</span> ),
'link' => %(<span class="page">#{link.call(MARK)}</span> ),
'link' => %(<span class="page">#{link.call(PAGE_PLACEHOLDER)}</span> ),
'active' => %(<span class="page active">#{pagy.page}</span> ),
'gap' => %(<span class="page gap">#{pagy_t('pagy.nav.gap')}</span> ),
'after' => p_next ? %(<span class="page next">#{link.call p_next, pagy_t('pagy.nav.next'), 'aria-label="next"'}</span>)
Expand Down
2 changes: 1 addition & 1 deletion lib/pagy/extras/semantic.rb
Expand Up @@ -29,7 +29,7 @@ def pagy_semantic_nav_js(pagy, id=pagy_id)
link, p_prev, p_next = pagy_link_proc(pagy, 'class="item"'), pagy.prev, pagy.next
tags = { 'before' => (p_prev ? %(#{link.call(p_prev, '<i class="left small chevron icon"></i>', 'aria-label="previous"')})
: %(<div class="item disabled"><i class="left small chevron icon"></i></div>)),
'link' => %(#{link.call(MARK)}),
'link' => %(#{link.call(PAGE_PLACEHOLDER)}),
'active' => %(<a class="item active">#{pagy.page}</a>),
'gap' => %(<div class="disabled item">#{pagy_t('pagy.nav.gap')}</div>),
'after' => (p_next ? %(#{link.call(p_next, '<i class="right small chevron icon"></i>', 'aria-label="next"')})
Expand Down
2 changes: 1 addition & 1 deletion lib/pagy/extras/shared.rb
Expand Up @@ -45,7 +45,7 @@ def pagy_id

# it returns the marked link to used by pagy.js
def pagy_marked_link(link)
link.call(MARK, '', 'style="display: none;"')
link.call(PAGE_PLACEHOLDER, '', 'style="display: none;"')
end

end
Expand Down
4 changes: 2 additions & 2 deletions lib/pagy/extras/uikit.rb
Expand Up @@ -33,8 +33,8 @@ def pagy_uikit_nav_js(pagy, id=pagy_id)
next_span = "<span uk-pagination-next>#{pagy_t('pagy.nav.next')}</span>"
tags = { 'before' => p_prev ? %(<li>#{link.call p_prev, previous_span}</li>)
: %(<li class="uk-disabled"><a href="#">#{previous_span}</a></li>),
'link' => %(<li>#{link.call(MARK)}</li>),
'active' => %(<li class="uk-active"><span>#{MARK}</span></li>),
'link' => %(<li>#{link.call(PAGE_PLACEHOLDER)}</li>),
'active' => %(<li class="uk-active"><span>#{PAGE_PLACEHOLDER}</span></li>),
'gap' => %(<li class="uk-disabled"><span>#{pagy_t('pagy.nav.gap')}</span></li>),
'after' => p_next ? %(<li>#{link.call p_next, next_span}</li>)
: %(<li class="uk-disabled"><a href="#">#{next_span}</a></li>) }
Expand Down
6 changes: 4 additions & 2 deletions lib/pagy/frontend.rb
Expand Up @@ -6,6 +6,8 @@

class Pagy

PAGE_PLACEHOLDER = '__pagy_page__' # string used for search and replace, hardcoded also in the pagy.js file

# I18n static hash loaded at startup, used as default alternative to the i18n gem.
# see https://ddnexus.github.io/pagy/api/frontend#i18n
I18n = eval(Pagy.root.join('locales', 'utils', 'i18n.rb').read) #rubocop:disable Security/Eval
Expand All @@ -28,7 +30,7 @@ module Frontend
include Helpers

EMPTY = '' # EMPTY + 'string' is almost as fast as +'string' but is also 1.9 compatible
MARK = '__pagy_page__' # string used for search and replace, hardcoded also in the pagy.js file
MARK = PAGE_PLACEHOLDER # backward compatibility in case of helper-overriding in legacy apps

# Generic pagination: it returns the html with the series of links to the pages
def pagy_nav(pagy)
Expand Down Expand Up @@ -59,7 +61,7 @@ def pagy_info(pagy)
# Benchmarked on a 20 link nav: it is ~22x faster and uses ~18x less memory than rails' link_to
def pagy_link_proc(pagy, link_extra='')
p_prev, p_next = pagy.prev, pagy.next
a, b = %(<a href="#{pagy_url_for(MARK, pagy)}" #{pagy.vars[:link_extra]} #{link_extra}).split(MARK, 2)
a, b = %(<a href="#{pagy_url_for(PAGE_PLACEHOLDER, pagy)}" #{pagy.vars[:link_extra]} #{link_extra}).split(PAGE_PLACEHOLDER, 2)
lambda {|n, text=n, extra=''| "#{a}#{n}#{b}#{ if n == p_prev ; ' rel="prev"'
elsif n == p_next ; ' rel="next"'
else '' end } #{extra}>#{text}</a>"}
Expand Down

0 comments on commit 0aa603e

Please sign in to comment.