pagy 3.3.2 → 3.4.0
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/lib/config/pagy.rb +5 -1
- data/lib/pagy.rb +1 -1
- data/lib/pagy/extras/uikit.rb +62 -0
- data/lib/templates/uikit_nav.html.erb +15 -0
- data/lib/templates/uikit_nav.html.haml +28 -0
- data/lib/templates/uikit_nav.html.slim +28 -0
- metadata +6 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: a00174d5d8af0760d883355ba8e77f9f9118954a7c6dec7e5e6e7ab503dcfde9
         | 
| 4 | 
            +
              data.tar.gz: 64a379d944f3b013e6b17ec8f899661346ac837780c028295e1916e796a1930e
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 4d2d2d25d9df71c80de2786165ed678b82744ba617bad804beb8a56eb41011a239ad3d7ce96abfef80a4e6313f483edab43e9f9d331a161a4fead6f07675013d
         | 
| 7 | 
            +
              data.tar.gz: e4dba23f4e9fd2ccc1d77c1f8e0bcb00c3a3ba7b770126afd57eb7247a51168e0bcb2ba4ec4ebfb30e34eac97913099e79e2409225ddbcd72ba618f77fa20597
         | 
    
        data/lib/config/pagy.rb
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            # encoding: utf-8
         | 
| 2 2 | 
             
            # frozen_string_literal: true
         | 
| 3 3 |  | 
| 4 | 
            -
            # Pagy initializer file (3. | 
| 4 | 
            +
            # Pagy initializer file (3.4.0)
         | 
| 5 5 | 
             
            # Customize only what you really need and notice that Pagy works also without any of the following lines.
         | 
| 6 6 | 
             
            # Should you just cherry pick part of this file, please maintain the require-order of the extras
         | 
| 7 7 |  | 
| @@ -58,6 +58,10 @@ | |
| 58 58 | 
             
            # See https://ddnexus.github.io/pagy/extras/semantic
         | 
| 59 59 | 
             
            # require 'pagy/extras/semantic'
         | 
| 60 60 |  | 
| 61 | 
            +
            # UIkit extra: Add nav helper and templates for UIkit pagination
         | 
| 62 | 
            +
            # See https://ddnexus.github.io/pagy/extras/uikit
         | 
| 63 | 
            +
            # require 'pagy/extras/uikit'
         | 
| 64 | 
            +
             | 
| 61 65 | 
             
            # Multi size var used by the *_nav_js helpers
         | 
| 62 66 | 
             
            # See https://ddnexus.github.io/pagy/extras/navs#steps
         | 
| 63 67 | 
             
            # Pagy::VARS[:steps] = { 0 => [2,3,3,2], 540 => [3,5,5,3], 720 => [5,7,7,5] }   # example
         | 
    
        data/lib/pagy.rb
    CHANGED
    
    
| @@ -0,0 +1,62 @@ | |
| 1 | 
            +
            # See the Pagy documentation: https://ddnexus.github.io/pagy/extras/uikit
         | 
| 2 | 
            +
            # encoding: utf-8
         | 
| 3 | 
            +
            # frozen_string_literal: true
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            require 'pagy/extras/shared'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            class Pagy
         | 
| 8 | 
            +
              module Frontend
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                # Pagination for uikit: it returns the html with the series of links to the pages
         | 
| 11 | 
            +
                def pagy_uikit_nav(pagy)
         | 
| 12 | 
            +
                  link, p_prev, p_next = pagy_link_proc(pagy), pagy.prev, pagy.next
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  previous_span = "<span uk-pagination-previous>#{pagy_t('pagy.nav.prev')}</span>"
         | 
| 15 | 
            +
                  html = EMPTY + (p_prev ? %(<li>#{link.call p_prev, previous_span}</li>)
         | 
| 16 | 
            +
                                         : %(<li class="uk-disabled"><a href="#">#{previous_span}</a></li>))
         | 
| 17 | 
            +
                  pagy.series.each do |item|
         | 
| 18 | 
            +
                    html << if    item.is_a?(Integer); %(<li>#{link.call item}</li>)
         | 
| 19 | 
            +
                            elsif item.is_a?(String) ; %(<li class="uk-active"><span>#{item}</span></li>)
         | 
| 20 | 
            +
                            elsif item == :gap       ; %(<li class="uk-disabled"><span>#{pagy_t('pagy.nav.gap')}</span></li>)
         | 
| 21 | 
            +
                            end
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
                  next_span = "<span uk-pagination-next>#{pagy_t('pagy.nav.next')}</span>"
         | 
| 24 | 
            +
                  html << (p_next ? %(<li>#{link.call p_next, next_span}</li>)
         | 
| 25 | 
            +
                                  : %(<li class="uk-disabled"><a href="#">#{next_span}</a></li>))
         | 
| 26 | 
            +
                  %(<ul class="pagy-uikit-nav uk-pagination uk-flex-center">#{html}</ul>)
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                # Javascript pagination for uikit: it returns a nav and a JSON tag used by the Pagy.nav javascript
         | 
| 30 | 
            +
                def pagy_uikit_nav_js(pagy, id=pagy_id)
         | 
| 31 | 
            +
                  link, p_prev, p_next = pagy_link_proc(pagy), pagy.prev, pagy.next
         | 
| 32 | 
            +
                  previous_span = "<span uk-pagination-previous>#{pagy_t('pagy.nav.prev')}</span>"
         | 
| 33 | 
            +
                  next_span     = "<span uk-pagination-next>#{pagy_t('pagy.nav.next')}</span>"
         | 
| 34 | 
            +
                  tags = { 'before' => p_prev ? %(<li>#{link.call p_prev, previous_span}</li>)
         | 
| 35 | 
            +
                                              : %(<li class="uk-disabled"><a href="#">#{previous_span}</a></li>),
         | 
| 36 | 
            +
                           'link'   => %(<li>#{link.call(MARK)}</li>),
         | 
| 37 | 
            +
                           'active' => %(<li class="uk-active"><span>#{MARK}</span></li>),
         | 
| 38 | 
            +
                           'gap'    => %(<li class="uk-disabled"><span>#{pagy_t('pagy.nav.gap')}</span></li>),
         | 
| 39 | 
            +
                           'after'  => p_next ? %(<li>#{link.call p_next, next_span}</li>)
         | 
| 40 | 
            +
                                              : %(<li class="uk-disabled"><a href="#">#{next_span}</a></li>) }
         | 
| 41 | 
            +
                  %(<ul id="#{id}" class="pagy-uikit-nav-js uk-pagination uk-flex-center"></ul>#{pagy_json_tag(:nav, id, tags, pagy.sequels, defined?(TRIM) && pagy.vars[:page_param])})
         | 
| 42 | 
            +
                end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                # Javascript combo pagination for uikit: it returns a nav and a JSON tag used by the Pagy.combo_nav javascript
         | 
| 45 | 
            +
                def pagy_uikit_combo_nav_js(pagy, id=pagy_id)
         | 
| 46 | 
            +
                  link, p_prev, p_next, p_page, p_pages = pagy_link_proc(pagy), pagy.prev, pagy.next, pagy.page, pagy.pages
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                  html = %(<div id="#{id}" class="pagy-uikit-combo-nav-js uk-button-group">)
         | 
| 49 | 
            +
                  html = html + (p_prev ? link.call(p_prev, pagy_t('pagy.nav.prev'), 'class="uk-button uk-button-default"')
         | 
| 50 | 
            +
                                        : %(<button class="uk-button uk-button-default" disabled>#{pagy_t('pagy.nav.prev')}</button>))
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                  html << %(<div class="uk-text-middle uk-margin-left uk-margin-right">)
         | 
| 53 | 
            +
                  input = %(<input type="number" min="1" max="#{p_pages}" value="#{p_page}" class="uk-input" style="padding: 0; text-align: center; width: #{p_pages.to_s.length+1}rem;">)
         | 
| 54 | 
            +
                  html << pagy_t('pagy.combo_nav_js', page_input: input, count: p_page, pages: p_pages) + '</div>'
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                  html << (p_next ? link.call(p_next, pagy_t('pagy.nav.next'), 'class="uk-button uk-button-default"')
         | 
| 57 | 
            +
                                  : %(<button class="uk-button uk-button-default" disabled>#{pagy_t('pagy.nav.next')}</button>))
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                  html << %(</div>#{pagy_json_tag(:combo_nav, id, p_page, pagy_marked_link(link), defined?(TRIM) && pagy.vars[:page_param])})
         | 
| 60 | 
            +
                end
         | 
| 61 | 
            +
              end
         | 
| 62 | 
            +
            end
         | 
| @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            <% link = pagy_link_proc(pagy) -%>
         | 
| 2 | 
            +
            <%#                            -%> <ul class="uk-pagination uk-flex-center">
         | 
| 3 | 
            +
            <% if page.prev                -%>   <li><%== link.call(pagy.prev, "<span uk-pagination-previous>#{pagy_t('pagy.nav.prev')}</span>") %></li>
         | 
| 4 | 
            +
            <% else                        -%>   <li class="uk-disabled"><a href="#"><span uk-pagination-previous><%== pagy_t('pagy.nav.prev') %></span></a></li>
         | 
| 5 | 
            +
            <% end                         -%>
         | 
| 6 | 
            +
            <% pagy.series.each do |item|  -%>
         | 
| 7 | 
            +
            <%   if    item.is_a?(Integer) -%>   <li><%== link.call(item) %></li>
         | 
| 8 | 
            +
            <%   elsif item.is_a?(String)  -%>   <li class="uk-active"><span><%== item %></span></li>
         | 
| 9 | 
            +
            <%   elsif item == :gap        -%>   <li class="uk-disabled"><span><%== pagy_t('pagy.nav.gap') %></span></li>
         | 
| 10 | 
            +
            <%   end                       -%>
         | 
| 11 | 
            +
            <% end                         -%>
         | 
| 12 | 
            +
            <% if pagy.next                -%>   <li><%== link.call(p_next, "<span uk-pagination-next>#{pagy_t('pagy.nav.next')}</span>") %></li>
         | 
| 13 | 
            +
            <% else                        -%>   <li class="uk-disabled"><a href="#"><span uk-pagination-next><%== pagy_t('pagy.nav.next') %></span></a></li>
         | 
| 14 | 
            +
            <% end                         -%>
         | 
| 15 | 
            +
            <%#                            -%> </ul>
         | 
| @@ -0,0 +1,28 @@ | |
| 1 | 
            +
            - link = pagy_link_proc(pagy)
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            %ul.uk-pagination.uk-flex-center
         | 
| 4 | 
            +
              - if page.prev
         | 
| 5 | 
            +
                %li!= link.call(pagy.prev, "<span uk-pagination-previous>#{pagy_t('pagy.nav.prev')}</span>")
         | 
| 6 | 
            +
              - else
         | 
| 7 | 
            +
                %li.uk-disabled
         | 
| 8 | 
            +
                  %a{href: "#"}
         | 
| 9 | 
            +
                    %span{"uk-pagination-previous" => ""}!= pagy_t('pagy.nav.prev')
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              - pagy.series.each do |item|
         | 
| 12 | 
            +
                - if    item.is_a?(Integer)
         | 
| 13 | 
            +
                  %li!= link.call(item)
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                - elsif item.is_a?(String)
         | 
| 16 | 
            +
                  %li.uk-active
         | 
| 17 | 
            +
                    %span!= item
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                - elsif item == :gap
         | 
| 20 | 
            +
                  %li.uk-disabled
         | 
| 21 | 
            +
                    %span!= pagy_t('pagy.nav.gap')
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              - if pagy.next
         | 
| 24 | 
            +
                %li!= link.call(p_next, "<span uk-pagination-next>#{pagy_t('pagy.nav.next')}</span>")
         | 
| 25 | 
            +
              - else
         | 
| 26 | 
            +
                %li.uk-disabled
         | 
| 27 | 
            +
                  %a{href: "#"}
         | 
| 28 | 
            +
                    %span{"uk-pagination-next" => ""}!= pagy_t('pagy.nav.next')
         | 
| @@ -0,0 +1,28 @@ | |
| 1 | 
            +
            - link = pagy_link_proc(pagy)
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            ul.uk-pagination.uk-flex-center
         | 
| 4 | 
            +
              - if page.prev
         | 
| 5 | 
            +
                li== link.call(pagy.prev, "<span uk-pagination-previous>#{pagy_t('pagy.nav.prev')}</span>")
         | 
| 6 | 
            +
              - else
         | 
| 7 | 
            +
                li.uk-disabled
         | 
| 8 | 
            +
                  a href="#"
         | 
| 9 | 
            +
                    span uk-pagination-previous="" == pagy_t('pagy.nav.prev')
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              - pagy.series.each do |item|
         | 
| 12 | 
            +
                - if    item.is_a?(Integer)
         | 
| 13 | 
            +
                  li== link.call(item)
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                - elsif item.is_a?(String)
         | 
| 16 | 
            +
                  li.uk-active
         | 
| 17 | 
            +
                    span== item
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                - elsif item == :gap
         | 
| 20 | 
            +
                  li.uk-disabled
         | 
| 21 | 
            +
                    span== pagy_t('pagy.nav.gap')
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              - if pagy.next
         | 
| 24 | 
            +
                li== link.call(p_next, "<span uk-pagination-next>#{pagy_t('pagy.nav.next')}</span>")
         | 
| 25 | 
            +
              - else
         | 
| 26 | 
            +
                li.uk-disabled
         | 
| 27 | 
            +
                  a href="#"
         | 
| 28 | 
            +
                    span uk-pagination-next="" == pagy_t('pagy.nav.next')
         | 
    
        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: 3. | 
| 4 | 
            +
              version: 3.4.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Domizio Demichelis
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2019-07- | 
| 11 | 
            +
            date: 2019-07-15 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies: []
         | 
| 13 13 | 
             
            description: 'Agnostic pagination in plain ruby: it works with any framework, ORM
         | 
| 14 14 | 
             
              and DB type, with all kinds of collections, even pre-paginated, scopes, Arrays,
         | 
| @@ -65,6 +65,7 @@ files: | |
| 65 65 | 
             
            - lib/pagy/extras/shared.rb
         | 
| 66 66 | 
             
            - lib/pagy/extras/support.rb
         | 
| 67 67 | 
             
            - lib/pagy/extras/trim.rb
         | 
| 68 | 
            +
            - lib/pagy/extras/uikit.rb
         | 
| 68 69 | 
             
            - lib/pagy/frontend.rb
         | 
| 69 70 | 
             
            - lib/templates/bootstrap_nav.html.erb
         | 
| 70 71 | 
             
            - lib/templates/bootstrap_nav.html.haml
         | 
| @@ -78,6 +79,9 @@ files: | |
| 78 79 | 
             
            - lib/templates/nav.html.erb
         | 
| 79 80 | 
             
            - lib/templates/nav.html.haml
         | 
| 80 81 | 
             
            - lib/templates/nav.html.slim
         | 
| 82 | 
            +
            - lib/templates/uikit_nav.html.erb
         | 
| 83 | 
            +
            - lib/templates/uikit_nav.html.haml
         | 
| 84 | 
            +
            - lib/templates/uikit_nav.html.slim
         | 
| 81 85 | 
             
            - pagy.gemspec
         | 
| 82 86 | 
             
            homepage: https://github.com/ddnexus/pagy
         | 
| 83 87 | 
             
            licenses:
         |