From 487eb70f9e080a8568d05aa971f2b7ba9ae16328 Mon Sep 17 00:00:00 2001 From: Domizio Demichelis Date: Wed, 14 Apr 2021 14:09:38 +0700 Subject: [PATCH] small code normalization --- lib/pagy/extras/bootstrap.rb | 2 +- lib/pagy/extras/bulma.rb | 6 +++--- lib/pagy/extras/foundation.rb | 10 ++++++---- lib/pagy/extras/materialize.rb | 18 +++++++++--------- lib/pagy/extras/navs.rb | 14 +++++++------- lib/pagy/extras/overflow.rb | 4 ++-- lib/pagy/extras/semantic.rb | 12 ++++++------ lib/pagy/extras/uikit.rb | 18 +++++++++--------- lib/pagy/frontend.rb | 2 +- 9 files changed, 44 insertions(+), 42 deletions(-) diff --git a/lib/pagy/extras/bootstrap.rb b/lib/pagy/extras/bootstrap.rb index 89a008414..61703a8b7 100644 --- a/lib/pagy/extras/bootstrap.rb +++ b/lib/pagy/extras/bootstrap.rb @@ -56,7 +56,7 @@ def pagy_bootstrap_combo_nav_js(pagy, id=pagy_id) %() end }#{ - pagy_json_tag(pagy, :combo_nav, id, p_page, pagy_marked_link(link)) + pagy_json_tag pagy, :combo_nav, id, p_page, pagy_marked_link(link) }) end diff --git a/lib/pagy/extras/bulma.rb b/lib/pagy/extras/bulma.rb index 51f03da3b..24feb3306 100644 --- a/lib/pagy/extras/bulma.rb +++ b/lib/pagy/extras/bulma.rb @@ -17,7 +17,7 @@ def pagy_bulma_nav(pagy) html << case item when Integer then %(
  • #{link.call item, item, %(class="pagination-link" aria-label="goto page #{item}") }
  • ) # page link when String then %(
  • #{link.call item, item, %(class="pagination-link is-current" aria-label="page #{item}" aria-current="page")}
  • ) # active page - when :gap then %(
  • #{pagy_t('pagy.nav.gap')}
  • ) # page gap + when :gap then %(
  • #{pagy_t 'pagy.nav.gap'}
  • ) # page gap end end html << %() @@ -48,14 +48,14 @@ def pagy_bulma_combo_nav_js(pagy, id=pagy_id) else %(

    #{pagy_t 'pagy.nav.prev'}

    ) end - }
    #{pagy_t('pagy.combo_nav_js', page_input: input, count: p_page, pages: p_pages)}
    #{ + }
    #{pagy_t 'pagy.combo_nav_js', page_input: input, count: p_page, pages: p_pages}
    #{ if (p_next = pagy.next) %(

    #{link.call p_next, pagy_t('pagy.nav.next'), 'class="button" aria-label="next page"'}

    ) else %(

    #{pagy_t 'pagy.nav.next'}

    ) end }#{ - pagy_json_tag(pagy, :combo_nav, id, p_page, pagy_marked_link(link)) + pagy_json_tag pagy, :combo_nav, id, p_page, pagy_marked_link(link) }) end diff --git a/lib/pagy/extras/foundation.rb b/lib/pagy/extras/foundation.rb index e2b22c2dc..b0d8667e3 100644 --- a/lib/pagy/extras/foundation.rb +++ b/lib/pagy/extras/foundation.rb @@ -26,11 +26,11 @@ def pagy_foundation_nav(pagy) # Javascript pagination for foundation: it returns a nav and a JSON tag used by the Pagy.nav javascript def pagy_foundation_nav_js(pagy, id=pagy_id) link = pagy_link_proc(pagy) - tags = { 'before' => %() } html = %() html << pagy_json_tag(pagy, :nav, id, tags, pagy.sequels) @@ -47,7 +47,7 @@ def pagy_foundation_combo_nav_js(pagy, id=pagy_id) if (p_prev = pagy.prev) link.call p_prev, pagy_t('pagy.nav.prev'), 'style="margin-bottom: 0px;" aria-label="previous" class="prev button primary"' else - %() + %() end }#{pagy_t 'pagy.combo_nav_js', page_input: input, count: p_page, pages: p_pages}#{ if (p_next = pagy.next) @@ -55,7 +55,9 @@ def pagy_foundation_combo_nav_js(pagy, id=pagy_id) else %() end - }#{pagy_json_tag(pagy, :combo_nav, id, p_page, pagy_marked_link(link))}) + }#{ + pagy_json_tag pagy, :combo_nav, id, p_page, pagy_marked_link(link) + }) end private diff --git a/lib/pagy/extras/materialize.rb b/lib/pagy/extras/materialize.rb index 440d6772d..b2ba6ca72 100644 --- a/lib/pagy/extras/materialize.rb +++ b/lib/pagy/extras/materialize.rb @@ -16,7 +16,7 @@ def pagy_materialize_nav(pagy) html << case item when Integer then %(
  • #{link.call item}
  • ) # page link when String then %(
  • #{link.call item}
  • ) # active page - when :gap then %(
  • #{pagy_t('pagy.nav.gap')}
  • ) # page gap + when :gap then %(
  • #{pagy_t 'pagy.nav.gap'}
  • ) # page gap end end html << pagy_materialize_next_html(pagy, link) @@ -26,11 +26,11 @@ def pagy_materialize_nav(pagy) # Javascript pagination for materialize: it returns a nav and a JSON tag used by the Pagy.nav javascript def pagy_materialize_nav_js(pagy, id=pagy_id) link = pagy_link_proc(pagy) - tags = { 'before' => %() } html = %() html << pagy_json_tag(pagy, :nav, id, tags, pagy.sequels) @@ -45,13 +45,13 @@ def pagy_materialize_combo_nav_js(pagy, id=pagy_id) input = %() %(#{ - pagy_json_tag(pagy, :combo_nav, id, p_page, pagy_marked_link(link)) + pagy_json_tag pagy, :combo_nav, id, p_page, pagy_marked_link(link) }) end @@ -66,7 +66,7 @@ def pagy_uikit_combo_nav_js(pagy, id=pagy_id) private def pagy_uikit_prev_html(pagy, link) - previous_span = %(#{pagy_t('pagy.nav.prev')}) + previous_span = %(#{pagy_t 'pagy.nav.prev'}) if (p_prev = pagy.prev) %(
  • #{link.call p_prev, previous_span}
  • ) else @@ -75,7 +75,7 @@ def pagy_uikit_prev_html(pagy, link) end def pagy_uikit_next_html(pagy, link) - next_span = %(#{pagy_t('pagy.nav.next')}) + next_span = %(#{pagy_t 'pagy.nav.next'}) if (p_next = pagy.next) %(
  • #{link.call p_next, next_span}
  • ) else diff --git a/lib/pagy/frontend.rb b/lib/pagy/frontend.rb index 50870d8f9..93a69b68e 100644 --- a/lib/pagy/frontend.rb +++ b/lib/pagy/frontend.rb @@ -73,7 +73,7 @@ def pagy_info(pagy, item_name=nil) def pagy_link_proc(pagy, link_extra='') p_prev = pagy.prev p_next = pagy.next - left, right = %(