pagy 9.2.1 → 9.3.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/apps/calendar.ru +98 -102
- data/apps/demo.ru +256 -244
- data/apps/index.rb +7 -0
- data/apps/keyset_ar.ru +85 -84
- data/apps/keyset_s.ru +81 -84
- data/apps/rails.ru +1 -1
- data/apps/repro.ru +93 -91
- data/bin/pagy +3 -3
- data/config/pagy.rb +1 -1
- data/javascripts/pagy.min.js +2 -2
- data/javascripts/pagy.min.js.map +2 -2
- data/javascripts/pagy.mjs +1 -1
- data/lib/pagy/keyset/active_record.rb +2 -2
- data/lib/pagy/keyset/sequel.rb +2 -2
- data/lib/pagy/keyset.rb +18 -14
- data/lib/pagy.rb +1 -1
- metadata +3 -2
    
        data/apps/keyset_ar.ru
    CHANGED
    
    | @@ -16,7 +16,7 @@ | |
| 16 16 | 
             
            # URL
         | 
| 17 17 | 
             
            #    http://0.0.0.0:8000
         | 
| 18 18 |  | 
| 19 | 
            -
            VERSION = '9. | 
| 19 | 
            +
            VERSION = '9.3.0'
         | 
| 20 20 |  | 
| 21 21 | 
             
            # Bundle
         | 
| 22 22 | 
             
            require 'bundler/inline'
         | 
| @@ -27,7 +27,6 @@ gemfile(ENV['PAGY_INSTALL_BUNDLE'] == 'true') do | |
| 27 27 | 
             
              gem 'activerecord'
         | 
| 28 28 | 
             
              gem 'puma'
         | 
| 29 29 | 
             
              gem 'sinatra'
         | 
| 30 | 
            -
              gem 'sinatra-contrib'
         | 
| 31 30 | 
             
              gem 'sqlite3'
         | 
| 32 31 | 
             
            end
         | 
| 33 32 |  | 
| @@ -42,12 +41,6 @@ Pagy::DEFAULT.freeze | |
| 42 41 | 
             
            require 'sinatra/base'
         | 
| 43 42 | 
             
            # Sinatra application
         | 
| 44 43 | 
             
            class PagyKeyset < Sinatra::Base
         | 
| 45 | 
            -
              configure do
         | 
| 46 | 
            -
                # Templates defined in the __END__ section as @@ ...
         | 
| 47 | 
            -
                enable :inline_templates
         | 
| 48 | 
            -
              end
         | 
| 49 | 
            -
             | 
| 50 | 
            -
              # Controller
         | 
| 51 44 | 
             
              include Pagy::Backend
         | 
| 52 45 | 
             
              # Root route/action
         | 
| 53 46 | 
             
              get '/' do
         | 
| @@ -57,7 +50,7 @@ class PagyKeyset < Sinatra::Base | |
| 57 50 | 
             
                @pagy, @pets = pagy_keyset(Pet.order(@order))
         | 
| 58 51 | 
             
                erb :main
         | 
| 59 52 | 
             
              end
         | 
| 60 | 
            -
             | 
| 53 | 
            +
             | 
| 61 54 | 
             
              helpers do
         | 
| 62 55 | 
             
                include Pagy::Frontend
         | 
| 63 56 |  | 
| @@ -65,10 +58,90 @@ class PagyKeyset < Sinatra::Base | |
| 65 58 | 
             
                  { asc: '↗', desc: '↘' }[dir]
         | 
| 66 59 | 
             
                end
         | 
| 67 60 | 
             
              end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
              # Views
         | 
| 63 | 
            +
              template :layout do
         | 
| 64 | 
            +
                <<~ERB
         | 
| 65 | 
            +
                  <!DOCTYPE html>
         | 
| 66 | 
            +
                  <html lang="en">
         | 
| 67 | 
            +
                  <html>
         | 
| 68 | 
            +
                  <head>
         | 
| 69 | 
            +
                     <title>Pagy Keyset App</title>
         | 
| 70 | 
            +
                    <meta name="viewport" content="width=device-width, initial-scale=1.0">
         | 
| 71 | 
            +
                    <style type="text/css">
         | 
| 72 | 
            +
                      @media screen { html, body {
         | 
| 73 | 
            +
                        font-size: 1rem;
         | 
| 74 | 
            +
                        line-height: 1.2s;
         | 
| 75 | 
            +
                        padding: 0;
         | 
| 76 | 
            +
                        margin: 0;
         | 
| 77 | 
            +
                      } }
         | 
| 78 | 
            +
                      body {
         | 
| 79 | 
            +
                        background: white !important;
         | 
| 80 | 
            +
                        margin: 0 !important;
         | 
| 81 | 
            +
                        font-family: sans-serif !important;
         | 
| 82 | 
            +
                      }
         | 
| 83 | 
            +
                      .content {
         | 
| 84 | 
            +
                        padding: 1rem 1.5rem 2rem !important;
         | 
| 85 | 
            +
                      }
         | 
| 86 | 
            +
             | 
| 87 | 
            +
                      <%= Pagy.root.join('stylesheets', 'pagy.css').read %>
         | 
| 88 | 
            +
                    </style>
         | 
| 89 | 
            +
                  </head>
         | 
| 90 | 
            +
                  <body>
         | 
| 91 | 
            +
                    <%= yield %>
         | 
| 92 | 
            +
                  </body>
         | 
| 93 | 
            +
                  </html>
         | 
| 94 | 
            +
                ERB
         | 
| 95 | 
            +
              end
         | 
| 96 | 
            +
             | 
| 97 | 
            +
              template :main do
         | 
| 98 | 
            +
                <<~ERB
         | 
| 99 | 
            +
                  <div class="content">
         | 
| 100 | 
            +
                    <h1>Pagy Keyset App</h1>
         | 
| 101 | 
            +
                    <p>Self-contained, standalone app usable to easily reproduce any keyset related pagy issue with ActiveRecord sets.</p>
         | 
| 102 | 
            +
                    <p>Please, report the following versions in any new issue.</p>
         | 
| 103 | 
            +
                    <h2>Versions</h2>
         | 
| 104 | 
            +
                    <ul>
         | 
| 105 | 
            +
                      <li>Ruby:    <%= RUBY_VERSION %></li>
         | 
| 106 | 
            +
                      <li>Rack:    <%= Rack::RELEASE %></li>
         | 
| 107 | 
            +
                      <li>Sinatra: <%= Sinatra::VERSION %></li>
         | 
| 108 | 
            +
                      <li>Pagy:    <%= Pagy::VERSION %></li>
         | 
| 109 | 
            +
                    </ul>
         | 
| 110 | 
            +
             | 
| 111 | 
            +
                    <h3>Collection</h3>
         | 
| 112 | 
            +
                    <div id="records" class="collection">
         | 
| 113 | 
            +
                    <table border="1" cellspacing="0" cellpadding="3">
         | 
| 114 | 
            +
                      <tr>
         | 
| 115 | 
            +
                        <th>animal <%= order_symbol(@order[:animal]) %></th>
         | 
| 116 | 
            +
                        <th>name <%= order_symbol(@order[:name]) %></th>
         | 
| 117 | 
            +
                        <th>birthdate <%= order_symbol(@order[:birthdate]) %></th>
         | 
| 118 | 
            +
                        <th>id <%= order_symbol(@order[:id]) %></th>
         | 
| 119 | 
            +
                      </tr>
         | 
| 120 | 
            +
                      <% @pets.each do |pet| %>
         | 
| 121 | 
            +
                      <tr>
         | 
| 122 | 
            +
                        <td><%= pet.animal %></td>
         | 
| 123 | 
            +
                        <td><%= pet.name %></td>
         | 
| 124 | 
            +
                        <td><%= pet.birthdate %></td>
         | 
| 125 | 
            +
                        <td><%= pet.id %></td>
         | 
| 126 | 
            +
                      </tr>
         | 
| 127 | 
            +
                      <% end %>
         | 
| 128 | 
            +
                    </table>
         | 
| 129 | 
            +
                    </div>
         | 
| 130 | 
            +
                    <p>
         | 
| 131 | 
            +
                    <nav class="pagy" id="next" aria-label="Pagy next">
         | 
| 132 | 
            +
                      <%= pagy_next_a(@pagy, text: 'Next page >') %>
         | 
| 133 | 
            +
                    </nav>
         | 
| 134 | 
            +
                  </div>
         | 
| 135 | 
            +
                ERB
         | 
| 136 | 
            +
              end
         | 
| 68 137 | 
             
            end
         | 
| 69 138 |  | 
| 70 139 | 
             
            # ActiveRecord setup
         | 
| 71 140 | 
             
            require 'active_record'
         | 
| 141 | 
            +
             | 
| 142 | 
            +
            # Match the microsecods with the strings stored into the time columns of SQLite
         | 
| 143 | 
            +
            # ActiveSupport::JSON::Encoding.time_precision = 6
         | 
| 144 | 
            +
             | 
| 72 145 | 
             
            # Log
         | 
| 73 146 | 
             
            output = ENV['APP_ENV'].equal?('showcase') ? IO::NULL : $stdout
         | 
| 74 147 | 
             
            ActiveRecord::Base.logger = Logger.new(output)
         | 
| @@ -90,8 +163,7 @@ end | |
| 90 163 | 
             
            # Models
         | 
| 91 164 | 
             
            class Pet < ActiveRecord::Base; end
         | 
| 92 165 |  | 
| 93 | 
            -
             | 
| 94 | 
            -
            PETS = <<~PETS
         | 
| 166 | 
            +
            data = <<~DATA
         | 
| 95 167 | 
             
              Luna  | dog    | 2018-03-10
         | 
| 96 168 | 
             
              Coco  | cat    | 2019-05-15
         | 
| 97 169 | 
             
              Dodo  | dog    | 2020-06-25
         | 
| @@ -142,85 +214,14 @@ PETS = <<~PETS | |
| 142 214 | 
             
              Sary  | bird   | 2023-04-29
         | 
| 143 215 | 
             
              Rocky | bird   | 2023-05-14
         | 
| 144 216 | 
             
              Coco  | dog    | 2023-05-27
         | 
| 145 | 
            -
             | 
| 217 | 
            +
            DATA
         | 
| 146 218 |  | 
| 147 219 | 
             
            # DB seed
         | 
| 148 220 | 
             
            pets = []
         | 
| 149 | 
            -
             | 
| 221 | 
            +
            data.each_line(chomp: true) do |pet|
         | 
| 150 222 | 
             
              name, animal, birthdate = pet.split('|').map(&:strip)
         | 
| 151 223 | 
             
              pets << { name:, animal:, birthdate: }
         | 
| 152 224 | 
             
            end
         | 
| 153 225 | 
             
            Pet.insert_all(pets)
         | 
| 154 226 |  | 
| 155 227 | 
             
            run PagyKeyset
         | 
| 156 | 
            -
             | 
| 157 | 
            -
            __END__
         | 
| 158 | 
            -
             | 
| 159 | 
            -
            @@ layout
         | 
| 160 | 
            -
            <!DOCTYPE html>
         | 
| 161 | 
            -
            <html lang="en">
         | 
| 162 | 
            -
            <html>
         | 
| 163 | 
            -
            <head>
         | 
| 164 | 
            -
               <title>Pagy Keyset App</title>
         | 
| 165 | 
            -
              <meta name="viewport" content="width=device-width, initial-scale=1.0">
         | 
| 166 | 
            -
              <style type="text/css">
         | 
| 167 | 
            -
                @media screen { html, body {
         | 
| 168 | 
            -
                  font-size: 1rem;
         | 
| 169 | 
            -
                  line-height: 1.2s;
         | 
| 170 | 
            -
                  padding: 0;
         | 
| 171 | 
            -
                  margin: 0;
         | 
| 172 | 
            -
                } }
         | 
| 173 | 
            -
                body {
         | 
| 174 | 
            -
                  background: white !important;
         | 
| 175 | 
            -
                  margin: 0 !important;
         | 
| 176 | 
            -
                  font-family: sans-serif !important;
         | 
| 177 | 
            -
                }
         | 
| 178 | 
            -
                .content {
         | 
| 179 | 
            -
                  padding: 1rem 1.5rem 2rem !important;
         | 
| 180 | 
            -
                }
         | 
| 181 | 
            -
             | 
| 182 | 
            -
                <%= Pagy.root.join('stylesheets', 'pagy.css').read %>
         | 
| 183 | 
            -
              </style>
         | 
| 184 | 
            -
            </head>
         | 
| 185 | 
            -
            <body>
         | 
| 186 | 
            -
              <%= yield %>
         | 
| 187 | 
            -
            </body>
         | 
| 188 | 
            -
            </html>
         | 
| 189 | 
            -
             | 
| 190 | 
            -
            @@ main
         | 
| 191 | 
            -
            <div class="content">
         | 
| 192 | 
            -
              <h1>Pagy Keyset App</h1>
         | 
| 193 | 
            -
              <p>Self-contained, standalone app usable to easily reproduce any keyset related pagy issue with ActiveRecord sets.</p>
         | 
| 194 | 
            -
              <p>Please, report the following versions in any new issue.</p>
         | 
| 195 | 
            -
              <h2>Versions</h2>
         | 
| 196 | 
            -
              <ul>
         | 
| 197 | 
            -
                <li>Ruby:    <%= RUBY_VERSION %></li>
         | 
| 198 | 
            -
                <li>Rack:    <%= Rack::RELEASE %></li>
         | 
| 199 | 
            -
                <li>Sinatra: <%= Sinatra::VERSION %></li>
         | 
| 200 | 
            -
                <li>Pagy:    <%= Pagy::VERSION %></li>
         | 
| 201 | 
            -
              </ul>
         | 
| 202 | 
            -
             | 
| 203 | 
            -
              <h3>Collection</h3>
         | 
| 204 | 
            -
              <div id="records" class="collection">
         | 
| 205 | 
            -
              <table border="1" cellspacing="0" cellpadding="3">
         | 
| 206 | 
            -
                <tr>
         | 
| 207 | 
            -
                  <th>animal <%= order_symbol(@order[:animal]) %></th>
         | 
| 208 | 
            -
                  <th>name <%= order_symbol(@order[:name]) %></th>
         | 
| 209 | 
            -
                  <th>birthdate <%= order_symbol(@order[:birthdate]) %></th>
         | 
| 210 | 
            -
                  <th>id <%= order_symbol(@order[:id]) %></th>
         | 
| 211 | 
            -
                </tr>
         | 
| 212 | 
            -
                <% @pets.each do |pet| %>
         | 
| 213 | 
            -
                <tr>
         | 
| 214 | 
            -
                  <td><%= pet.animal %></td>
         | 
| 215 | 
            -
                  <td><%= pet.name %></td>
         | 
| 216 | 
            -
                  <td><%= pet.birthdate %></td>
         | 
| 217 | 
            -
                  <td><%= pet.id %></td>
         | 
| 218 | 
            -
                </tr>
         | 
| 219 | 
            -
                <% end %>
         | 
| 220 | 
            -
              </table>
         | 
| 221 | 
            -
              </div>
         | 
| 222 | 
            -
              <p>
         | 
| 223 | 
            -
              <nav class="pagy" id="next" aria-label="Pagy next">
         | 
| 224 | 
            -
                <%= pagy_next_a(@pagy, text: 'Next page >') %>
         | 
| 225 | 
            -
              </nav>
         | 
| 226 | 
            -
            </div>
         | 
    
        data/apps/keyset_s.ru
    CHANGED
    
    | @@ -16,7 +16,7 @@ | |
| 16 16 | 
             
            # URL
         | 
| 17 17 | 
             
            #    http://0.0.0.0:8000
         | 
| 18 18 |  | 
| 19 | 
            -
            VERSION = '9. | 
| 19 | 
            +
            VERSION = '9.3.0'
         | 
| 20 20 |  | 
| 21 21 | 
             
            # Bundle
         | 
| 22 22 | 
             
            require 'bundler/inline'
         | 
| @@ -27,7 +27,6 @@ gemfile(ENV['PAGY_INSTALL_BUNDLE'] == 'true') do | |
| 27 27 | 
             
              gem 'puma'
         | 
| 28 28 | 
             
              gem 'sequel'
         | 
| 29 29 | 
             
              gem 'sinatra'
         | 
| 30 | 
            -
              gem 'sinatra-contrib'
         | 
| 31 30 | 
             
              gem 'sqlite3'
         | 
| 32 31 | 
             
            end
         | 
| 33 32 |  | 
| @@ -43,12 +42,6 @@ require 'sinatra/base' | |
| 43 42 | 
             
            require 'logger'
         | 
| 44 43 | 
             
            # Sinatra application
         | 
| 45 44 | 
             
            class PagyKeyset < Sinatra::Base
         | 
| 46 | 
            -
              configure do
         | 
| 47 | 
            -
                # Templates defined in the __END__ section as @@ ...
         | 
| 48 | 
            -
                enable :inline_templates
         | 
| 49 | 
            -
              end
         | 
| 50 | 
            -
             | 
| 51 | 
            -
              # Controller
         | 
| 52 45 | 
             
              include Pagy::Backend
         | 
| 53 46 | 
             
              # Root route/action
         | 
| 54 47 | 
             
              get '/' do
         | 
| @@ -56,7 +49,7 @@ class PagyKeyset < Sinatra::Base | |
| 56 49 | 
             
                @pagy, @pets = pagy_keyset(Pet.order(:animal, :name, Sequel.desc(:birthdate), :id))
         | 
| 57 50 | 
             
                erb :main
         | 
| 58 51 | 
             
              end
         | 
| 59 | 
            -
             | 
| 52 | 
            +
             | 
| 60 53 | 
             
              helpers do
         | 
| 61 54 | 
             
                include Pagy::Frontend
         | 
| 62 55 |  | 
| @@ -64,6 +57,82 @@ class PagyKeyset < Sinatra::Base | |
| 64 57 | 
             
                  { asc: '↗', desc: '↘' }[dir]
         | 
| 65 58 | 
             
                end
         | 
| 66 59 | 
             
              end
         | 
| 60 | 
            +
             | 
| 61 | 
            +
              # Views
         | 
| 62 | 
            +
              template :layout do
         | 
| 63 | 
            +
                <<~ERB
         | 
| 64 | 
            +
                  <!DOCTYPE html>
         | 
| 65 | 
            +
                  <html lang="en">
         | 
| 66 | 
            +
                  <html>
         | 
| 67 | 
            +
                  <head>
         | 
| 68 | 
            +
                     <title>Pagy Keyset App</title>
         | 
| 69 | 
            +
                    <meta name="viewport" content="width=device-width, initial-scale=1.0">
         | 
| 70 | 
            +
                    <style type="text/css">
         | 
| 71 | 
            +
                      @media screen { html, body {
         | 
| 72 | 
            +
                        font-size: 1rem;
         | 
| 73 | 
            +
                        line-height: 1.2s;
         | 
| 74 | 
            +
                        padding: 0;
         | 
| 75 | 
            +
                        margin: 0;
         | 
| 76 | 
            +
                      } }
         | 
| 77 | 
            +
                      body {
         | 
| 78 | 
            +
                        background: white !important;
         | 
| 79 | 
            +
                        margin: 0 !important;
         | 
| 80 | 
            +
                        font-family: sans-serif !important;
         | 
| 81 | 
            +
                      }
         | 
| 82 | 
            +
                      .content {
         | 
| 83 | 
            +
                        padding: 1rem 1.5rem 2rem !important;
         | 
| 84 | 
            +
                      }
         | 
| 85 | 
            +
             | 
| 86 | 
            +
                      <%= Pagy.root.join('stylesheets', 'pagy.css').read %>
         | 
| 87 | 
            +
                    </style>
         | 
| 88 | 
            +
                  </head>
         | 
| 89 | 
            +
                  <body>
         | 
| 90 | 
            +
                    <%= yield %>
         | 
| 91 | 
            +
                  </body>
         | 
| 92 | 
            +
                  </html>
         | 
| 93 | 
            +
                ERB
         | 
| 94 | 
            +
              end
         | 
| 95 | 
            +
             | 
| 96 | 
            +
              template :main do
         | 
| 97 | 
            +
                <<~ERB
         | 
| 98 | 
            +
                  <div class="content">
         | 
| 99 | 
            +
                    <h1>Pagy Keyset App</h1>
         | 
| 100 | 
            +
                    <p>Self-contained, standalone app usable to easily reproduce any keyset related pagy issue with ActiveRecord sets.</p>
         | 
| 101 | 
            +
                    <p>Please, report the following versions in any new issue.</p>
         | 
| 102 | 
            +
                    <h2>Versions</h2>
         | 
| 103 | 
            +
                    <ul>
         | 
| 104 | 
            +
                      <li>Ruby:    <%= RUBY_VERSION %></li>
         | 
| 105 | 
            +
                      <li>Rack:    <%= Rack::RELEASE %></li>
         | 
| 106 | 
            +
                      <li>Sinatra: <%= Sinatra::VERSION %></li>
         | 
| 107 | 
            +
                      <li>Pagy:    <%= Pagy::VERSION %></li>
         | 
| 108 | 
            +
                    </ul>
         | 
| 109 | 
            +
             | 
| 110 | 
            +
                    <h3>Collection</h3>
         | 
| 111 | 
            +
                    <div id="records" class="collection">
         | 
| 112 | 
            +
                    <table border="1" cellspacing="0" cellpadding="3">
         | 
| 113 | 
            +
                      <tr>
         | 
| 114 | 
            +
                        <th>animal <%= order_symbol(@order[:animal]) %></th>
         | 
| 115 | 
            +
                        <th>name <%= order_symbol(@order[:name]) %></th>
         | 
| 116 | 
            +
                        <th>birthdate <%= order_symbol(@order[:birthdate]) %></th>
         | 
| 117 | 
            +
                        <th>id <%= order_symbol(@order[:id]) %></th>
         | 
| 118 | 
            +
                      </tr>
         | 
| 119 | 
            +
                      <% @pets.each do |pet| %>
         | 
| 120 | 
            +
                      <tr>
         | 
| 121 | 
            +
                        <td><%= pet.animal %></td>
         | 
| 122 | 
            +
                        <td><%= pet.name %></td>
         | 
| 123 | 
            +
                        <td><%= pet.birthdate %></td>
         | 
| 124 | 
            +
                        <td><%= pet.id %></td>
         | 
| 125 | 
            +
                      </tr>
         | 
| 126 | 
            +
                      <% end %>
         | 
| 127 | 
            +
                    </table>
         | 
| 128 | 
            +
                    </div>
         | 
| 129 | 
            +
                    <p>
         | 
| 130 | 
            +
                    <nav class="pagy" id="next" aria-label="Pagy next">
         | 
| 131 | 
            +
                      <%= pagy_next_a(@pagy, text: 'Next page >') %>
         | 
| 132 | 
            +
                    </nav>
         | 
| 133 | 
            +
                  </div>
         | 
| 134 | 
            +
                ERB
         | 
| 135 | 
            +
              end
         | 
| 67 136 | 
             
            end
         | 
| 68 137 |  | 
| 69 138 | 
             
            # Sequel setup
         | 
| @@ -88,8 +157,7 @@ end | |
| 88 157 | 
             
            # Models
         | 
| 89 158 | 
             
            class Pet < Sequel::Model; end
         | 
| 90 159 |  | 
| 91 | 
            -
             | 
| 92 | 
            -
            PETS = <<~PETS
         | 
| 160 | 
            +
            data = <<~DATA
         | 
| 93 161 | 
             
              Luna  | dog    | 2018-03-10
         | 
| 94 162 | 
             
              Coco  | cat    | 2019-05-15
         | 
| 95 163 | 
             
              Dodo  | dog    | 2020-06-25
         | 
| @@ -140,83 +208,12 @@ PETS = <<~PETS | |
| 140 208 | 
             
              Sary  | bird   | 2023-04-29
         | 
| 141 209 | 
             
              Rocky | bird   | 2023-05-14
         | 
| 142 210 | 
             
              Coco  | dog    | 2023-05-27
         | 
| 143 | 
            -
             | 
| 211 | 
            +
            DATA
         | 
| 144 212 |  | 
| 145 213 | 
             
            dataset = DB[:pets]
         | 
| 146 | 
            -
             | 
| 214 | 
            +
            data.each_line(chomp: true) do |pet|
         | 
| 147 215 | 
             
              name, animal, birthdate = pet.split('|').map(&:strip)
         | 
| 148 216 | 
             
              dataset.insert(name:, animal:, birthdate:)
         | 
| 149 217 | 
             
            end
         | 
| 150 218 |  | 
| 151 219 | 
             
            run PagyKeyset
         | 
| 152 | 
            -
             | 
| 153 | 
            -
            __END__
         | 
| 154 | 
            -
             | 
| 155 | 
            -
            @@ layout
         | 
| 156 | 
            -
            <!DOCTYPE html>
         | 
| 157 | 
            -
            <html lang="en">
         | 
| 158 | 
            -
            <html>
         | 
| 159 | 
            -
            <head>
         | 
| 160 | 
            -
               <title>Pagy Keyset App</title>
         | 
| 161 | 
            -
              <meta name="viewport" content="width=device-width, initial-scale=1.0">
         | 
| 162 | 
            -
              <style type="text/css">
         | 
| 163 | 
            -
                @media screen { html, body {
         | 
| 164 | 
            -
                  font-size: 1rem;
         | 
| 165 | 
            -
                  line-height: 1.2s;
         | 
| 166 | 
            -
                  padding: 0;
         | 
| 167 | 
            -
                  margin: 0;
         | 
| 168 | 
            -
                } }
         | 
| 169 | 
            -
                body {
         | 
| 170 | 
            -
                  background: white !important;
         | 
| 171 | 
            -
                  margin: 0 !important;
         | 
| 172 | 
            -
                  font-family: sans-serif !important;
         | 
| 173 | 
            -
                }
         | 
| 174 | 
            -
                .content {
         | 
| 175 | 
            -
                  padding: 1rem 1.5rem 2rem !important;
         | 
| 176 | 
            -
                }
         | 
| 177 | 
            -
             | 
| 178 | 
            -
                <%= Pagy.root.join('stylesheets', 'pagy.css').read %>
         | 
| 179 | 
            -
              </style>
         | 
| 180 | 
            -
            </head>
         | 
| 181 | 
            -
            <body>
         | 
| 182 | 
            -
              <%= yield %>
         | 
| 183 | 
            -
            </body>
         | 
| 184 | 
            -
            </html>
         | 
| 185 | 
            -
             | 
| 186 | 
            -
            @@ main
         | 
| 187 | 
            -
            <div class="content">
         | 
| 188 | 
            -
              <h1>Pagy Keyset App</h1>
         | 
| 189 | 
            -
              <p>Self-contained, standalone app usable to easily reproduce any keyset related pagy issue with ActiveRecord sets.</p>
         | 
| 190 | 
            -
              <p>Please, report the following versions in any new issue.</p>
         | 
| 191 | 
            -
              <h2>Versions</h2>
         | 
| 192 | 
            -
              <ul>
         | 
| 193 | 
            -
                <li>Ruby:    <%= RUBY_VERSION %></li>
         | 
| 194 | 
            -
                <li>Rack:    <%= Rack::RELEASE %></li>
         | 
| 195 | 
            -
                <li>Sinatra: <%= Sinatra::VERSION %></li>
         | 
| 196 | 
            -
                <li>Pagy:    <%= Pagy::VERSION %></li>
         | 
| 197 | 
            -
              </ul>
         | 
| 198 | 
            -
             | 
| 199 | 
            -
              <h3>Collection</h3>
         | 
| 200 | 
            -
              <div id="records" class="collection">
         | 
| 201 | 
            -
              <table border="1" cellspacing="0" cellpadding="3">
         | 
| 202 | 
            -
                <tr>
         | 
| 203 | 
            -
                  <th>animal <%= order_symbol(@order[:animal]) %></th>
         | 
| 204 | 
            -
                  <th>name <%= order_symbol(@order[:name]) %></th>
         | 
| 205 | 
            -
                  <th>birthdate <%= order_symbol(@order[:birthdate]) %></th>
         | 
| 206 | 
            -
                  <th>id <%= order_symbol(@order[:id]) %></th>
         | 
| 207 | 
            -
                </tr>
         | 
| 208 | 
            -
                <% @pets.each do |pet| %>
         | 
| 209 | 
            -
                <tr>
         | 
| 210 | 
            -
                  <td><%= pet.animal %></td>
         | 
| 211 | 
            -
                  <td><%= pet.name %></td>
         | 
| 212 | 
            -
                  <td><%= pet.birthdate %></td>
         | 
| 213 | 
            -
                  <td><%= pet.id %></td>
         | 
| 214 | 
            -
                </tr>
         | 
| 215 | 
            -
                <% end %>
         | 
| 216 | 
            -
              </table>
         | 
| 217 | 
            -
              </div>
         | 
| 218 | 
            -
              <p>
         | 
| 219 | 
            -
              <nav class="pagy" id="next" aria-label="Pagy next">
         | 
| 220 | 
            -
                <%= pagy_next_a(@pagy, text: 'Next page >') %>
         | 
| 221 | 
            -
              </nav>
         | 
| 222 | 
            -
            </div>
         | 
    
        data/apps/rails.ru
    CHANGED
    
    
    
        data/apps/repro.ru
    CHANGED
    
    | @@ -16,7 +16,7 @@ | |
| 16 16 | 
             
            # URL
         | 
| 17 17 | 
             
            #    http://0.0.0.0:8000
         | 
| 18 18 |  | 
| 19 | 
            -
            VERSION = '9. | 
| 19 | 
            +
            VERSION = '9.3.0'
         | 
| 20 20 |  | 
| 21 21 | 
             
            # Bundle
         | 
| 22 22 | 
             
            require 'bundler/inline'
         | 
| @@ -27,7 +27,6 @@ gemfile(ENV['PAGY_INSTALL_BUNDLE'] == 'true') do | |
| 27 27 | 
             
              gem 'oj'
         | 
| 28 28 | 
             
              gem 'puma'
         | 
| 29 29 | 
             
              gem 'sinatra'
         | 
| 30 | 
            -
              gem 'sinatra-contrib'
         | 
| 31 30 | 
             
            end
         | 
| 32 31 |  | 
| 33 32 | 
             
            # Edit this section adding/removing the extras and Pagy::DEFAULT as needed
         | 
| @@ -42,9 +41,6 @@ Pagy::DEFAULT.freeze | |
| 42 41 | 
             
            require 'sinatra/base'
         | 
| 43 42 | 
             
            # Sinatra application
         | 
| 44 43 | 
             
            class PagyRepro < Sinatra::Base
         | 
| 45 | 
            -
              configure do
         | 
| 46 | 
            -
                enable :inline_templates
         | 
| 47 | 
            -
              end
         | 
| 48 44 | 
             
              include Pagy::Backend
         | 
| 49 45 |  | 
| 50 46 | 
             
              get('/javascripts/:file') do
         | 
| @@ -61,12 +57,103 @@ class PagyRepro < Sinatra::Base | |
| 61 57 | 
             
              get '/' do
         | 
| 62 58 | 
             
                collection = MockCollection.new
         | 
| 63 59 | 
             
                @pagy, @records = pagy(collection)
         | 
| 64 | 
            -
                erb :main | 
| 60 | 
            +
                erb :main
         | 
| 65 61 | 
             
              end
         | 
| 62 | 
            +
             | 
| 66 63 | 
             
              # Edit this section adding your own helpers as needed
         | 
| 67 64 | 
             
              helpers do
         | 
| 68 65 | 
             
                include Pagy::Frontend
         | 
| 69 66 | 
             
              end
         | 
| 67 | 
            +
             | 
| 68 | 
            +
              # Views
         | 
| 69 | 
            +
              template :layout do
         | 
| 70 | 
            +
                <<~ERB
         | 
| 71 | 
            +
                  <!DOCTYPE html>
         | 
| 72 | 
            +
                  <html lang="en">
         | 
| 73 | 
            +
                  <html>
         | 
| 74 | 
            +
                  <head>
         | 
| 75 | 
            +
                     <title>Pagy Repro App</title>
         | 
| 76 | 
            +
                    <script src="javascripts/pagy.min.js"></script>
         | 
| 77 | 
            +
                    <script>
         | 
| 78 | 
            +
                      window.addEventListener("load", Pagy.init);
         | 
| 79 | 
            +
                    </script>
         | 
| 80 | 
            +
                    <meta name="viewport" content="width=device-width, initial-scale=1.0">
         | 
| 81 | 
            +
                    <style type="text/css">
         | 
| 82 | 
            +
                      @media screen { html, body {
         | 
| 83 | 
            +
                        font-size: 1rem;
         | 
| 84 | 
            +
                        line-height: 1.2s;
         | 
| 85 | 
            +
                        padding: 0;
         | 
| 86 | 
            +
                        margin: 0;
         | 
| 87 | 
            +
                      } }
         | 
| 88 | 
            +
                      body {
         | 
| 89 | 
            +
                        background: white !important;
         | 
| 90 | 
            +
                        margin: 0 !important;
         | 
| 91 | 
            +
                        font-family: sans-serif !important;
         | 
| 92 | 
            +
                      }
         | 
| 93 | 
            +
                      .content {
         | 
| 94 | 
            +
                        padding: 1rem 1.5rem 2rem !important;
         | 
| 95 | 
            +
                      }
         | 
| 96 | 
            +
             | 
| 97 | 
            +
                      /* Quick demo for overriding the element style attribute of certain pagy helpers
         | 
| 98 | 
            +
                      .pagy input[style] {
         | 
| 99 | 
            +
                        width: 5rem !important;
         | 
| 100 | 
            +
                      }
         | 
| 101 | 
            +
                      */
         | 
| 102 | 
            +
             | 
| 103 | 
            +
                      /*
         | 
| 104 | 
            +
                        If you want to customize the style,
         | 
| 105 | 
            +
                        please replace the line below with the actual file content
         | 
| 106 | 
            +
                      */
         | 
| 107 | 
            +
                      <%= Pagy.root.join('stylesheets', 'pagy.css').read %>
         | 
| 108 | 
            +
                    </style>
         | 
| 109 | 
            +
                  </head>
         | 
| 110 | 
            +
                  <body>
         | 
| 111 | 
            +
                    <%= yield %>
         | 
| 112 | 
            +
                  </body>
         | 
| 113 | 
            +
                  </html>
         | 
| 114 | 
            +
                ERB
         | 
| 115 | 
            +
              end
         | 
| 116 | 
            +
             | 
| 117 | 
            +
              template :main do
         | 
| 118 | 
            +
                <<~ERB
         | 
| 119 | 
            +
                  <div class="content">
         | 
| 120 | 
            +
                    <h1>Pagy Repro App</h1>
         | 
| 121 | 
            +
                    <p> Self-contained, standalone app usable to easily reproduce any pagy issue.</p>
         | 
| 122 | 
            +
                    <p>Please, report the following versions in any new issue.</p>
         | 
| 123 | 
            +
                    <h2>Versions</h4>
         | 
| 124 | 
            +
                    <ul>
         | 
| 125 | 
            +
                      <li>Ruby:    <%= RUBY_VERSION %></li>
         | 
| 126 | 
            +
                      <li>Rack:    <%= Rack::RELEASE %></li>
         | 
| 127 | 
            +
                      <li>Sinatra: <%= Sinatra::VERSION %></li>
         | 
| 128 | 
            +
                      <li>Pagy:    <%= Pagy::VERSION %></li>
         | 
| 129 | 
            +
                    </ul>
         | 
| 130 | 
            +
             | 
| 131 | 
            +
                    <h3>Collection</h3>
         | 
| 132 | 
            +
                    <p id="records">@records: <%= @records.join(',') %></p>
         | 
| 133 | 
            +
             | 
| 134 | 
            +
                    <hr>
         | 
| 135 | 
            +
             | 
| 136 | 
            +
                    <h4>pagy_nav</h4>
         | 
| 137 | 
            +
                    <%= pagy_nav(@pagy, id: 'nav', aria_label: 'Pages nav') %>
         | 
| 138 | 
            +
             | 
| 139 | 
            +
                    <h4>pagy_nav_js</h4>
         | 
| 140 | 
            +
                    <%= pagy_nav_js(@pagy, id: 'nav-js', aria_label: 'Pages nav_js') %>
         | 
| 141 | 
            +
             | 
| 142 | 
            +
                    <h4>pagy_nav_js</h4>
         | 
| 143 | 
            +
                    <%= pagy_nav_js(@pagy, id: 'nav-js-responsive', aria_label: 'Pages nav_js_responsove',
         | 
| 144 | 
            +
                       steps: { 0 => 5, 500 => 7, 750 => 9, 1000 => 11 }) %>
         | 
| 145 | 
            +
             | 
| 146 | 
            +
                    <h4>pagy_combo_nav_js</h4>
         | 
| 147 | 
            +
                    <%= pagy_combo_nav_js(@pagy, id: 'combo-nav-js', aria_label: 'Pages combo_nav_js') %>
         | 
| 148 | 
            +
             | 
| 149 | 
            +
                    <h4>pagy_limit_selector_js</h4>
         | 
| 150 | 
            +
                    <%= pagy_limit_selector_js(@pagy, id: 'limit-selector-js') %>
         | 
| 151 | 
            +
             | 
| 152 | 
            +
                    <h4>pagy_info</h4>
         | 
| 153 | 
            +
                    <%= pagy_info(@pagy, id: 'pagy-info') %>
         | 
| 154 | 
            +
                  </div>
         | 
| 155 | 
            +
                ERB
         | 
| 156 | 
            +
              end
         | 
| 70 157 | 
             
            end
         | 
| 71 158 |  | 
| 72 159 | 
             
            # Simple array-based collection that acts as a standard DB collection.
         | 
| @@ -93,88 +180,3 @@ class MockCollection < Array | |
| 93 180 | 
             
            end
         | 
| 94 181 |  | 
| 95 182 | 
             
            run PagyRepro
         | 
| 96 | 
            -
             | 
| 97 | 
            -
            __END__
         | 
| 98 | 
            -
             | 
| 99 | 
            -
            @@ layout
         | 
| 100 | 
            -
            <!DOCTYPE html>
         | 
| 101 | 
            -
            <html lang="en">
         | 
| 102 | 
            -
            <html>
         | 
| 103 | 
            -
            <head>
         | 
| 104 | 
            -
               <title>Pagy Repro App</title>
         | 
| 105 | 
            -
              <script src="javascripts/pagy.min.js"></script>
         | 
| 106 | 
            -
              <script>
         | 
| 107 | 
            -
                window.addEventListener("load", Pagy.init);
         | 
| 108 | 
            -
              </script>
         | 
| 109 | 
            -
              <meta name="viewport" content="width=device-width, initial-scale=1.0">
         | 
| 110 | 
            -
              <style type="text/css">
         | 
| 111 | 
            -
                @media screen { html, body {
         | 
| 112 | 
            -
                  font-size: 1rem;
         | 
| 113 | 
            -
                  line-height: 1.2s;
         | 
| 114 | 
            -
                  padding: 0;
         | 
| 115 | 
            -
                  margin: 0;
         | 
| 116 | 
            -
                } }
         | 
| 117 | 
            -
                body {
         | 
| 118 | 
            -
                  background: white !important;
         | 
| 119 | 
            -
                  margin: 0 !important;
         | 
| 120 | 
            -
                  font-family: sans-serif !important;
         | 
| 121 | 
            -
                }
         | 
| 122 | 
            -
                .content {
         | 
| 123 | 
            -
                  padding: 1rem 1.5rem 2rem !important;
         | 
| 124 | 
            -
                }
         | 
| 125 | 
            -
             | 
| 126 | 
            -
                /* Quick demo for overriding the element style attribute of certain pagy helpers
         | 
| 127 | 
            -
                .pagy input[style] {
         | 
| 128 | 
            -
                  width: 5rem !important;
         | 
| 129 | 
            -
                }
         | 
| 130 | 
            -
                */
         | 
| 131 | 
            -
             | 
| 132 | 
            -
                /*
         | 
| 133 | 
            -
                  If you want to customize the style,
         | 
| 134 | 
            -
                  please replace the line below with the actual file content
         | 
| 135 | 
            -
                */
         | 
| 136 | 
            -
                <%= Pagy.root.join('stylesheets', 'pagy.css').read %>
         | 
| 137 | 
            -
              </style>
         | 
| 138 | 
            -
            </head>
         | 
| 139 | 
            -
            <body>
         | 
| 140 | 
            -
              <%= yield %>
         | 
| 141 | 
            -
            </body>
         | 
| 142 | 
            -
            </html>
         | 
| 143 | 
            -
             | 
| 144 | 
            -
            @@ main
         | 
| 145 | 
            -
            <div class="content">
         | 
| 146 | 
            -
              <h1>Pagy Repro App</h1>
         | 
| 147 | 
            -
              <p> Self-contained, standalone app usable to easily reproduce any pagy issue.</p>
         | 
| 148 | 
            -
              <p>Please, report the following versions in any new issue.</p>
         | 
| 149 | 
            -
              <h2>Versions</h4>
         | 
| 150 | 
            -
              <ul>
         | 
| 151 | 
            -
                <li>Ruby: <%= RUBY_VERSION %></li>
         | 
| 152 | 
            -
                <li>Rack: <%= Rack::RELEASE %></li>
         | 
| 153 | 
            -
                <li>Sinatra: <%= Sinatra::VERSION %></li>
         | 
| 154 | 
            -
                <li>Pagy: <%= Pagy::VERSION %></li>
         | 
| 155 | 
            -
              </ul>
         | 
| 156 | 
            -
             | 
| 157 | 
            -
              <h3>Collection</h3>
         | 
| 158 | 
            -
              <p id="records">@records: <%= @records.join(',') %></p>
         | 
| 159 | 
            -
             | 
| 160 | 
            -
              <hr>
         | 
| 161 | 
            -
             | 
| 162 | 
            -
              <h4>pagy_nav</h4>
         | 
| 163 | 
            -
              <%= pagy_nav(@pagy, id: 'nav', aria_label: 'Pages nav') %>
         | 
| 164 | 
            -
             | 
| 165 | 
            -
              <h4>pagy_nav_js</h4>
         | 
| 166 | 
            -
              <%= pagy_nav_js(@pagy, id: 'nav-js', aria_label: 'Pages nav_js') %>
         | 
| 167 | 
            -
             | 
| 168 | 
            -
              <h4>pagy_nav_js</h4>
         | 
| 169 | 
            -
              <%= pagy_nav_js(@pagy, id: 'nav-js-responsive', aria_label: 'Pages nav_js_responsove',
         | 
| 170 | 
            -
                 steps: { 0 => 5, 500 => 7, 750 => 9, 1000 => 11 }) %>
         | 
| 171 | 
            -
             | 
| 172 | 
            -
              <h4>pagy_combo_nav_js</h4>
         | 
| 173 | 
            -
              <%= pagy_combo_nav_js(@pagy, id: 'combo-nav-js', aria_label: 'Pages combo_nav_js') %>
         | 
| 174 | 
            -
             | 
| 175 | 
            -
              <h4>pagy_limit_selector_js</h4>
         | 
| 176 | 
            -
              <%= pagy_limit_selector_js(@pagy, id: 'limit-selector-js') %>
         | 
| 177 | 
            -
             | 
| 178 | 
            -
              <h4>pagy_info</h4>
         | 
| 179 | 
            -
              <%= pagy_info(@pagy, id: 'pagy-info') %>
         | 
| 180 | 
            -
            </div>
         | 
    
        data/bin/pagy
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            #!/usr/bin/env ruby
         | 
| 2 2 | 
             
            # frozen_string_literal: true
         | 
| 3 3 |  | 
| 4 | 
            -
            VERSION = '9. | 
| 4 | 
            +
            VERSION = '9.3.0'
         | 
| 5 5 | 
             
            LINUX   = RbConfig::CONFIG['host_os'].include?('linux')
         | 
| 6 6 | 
             
            HOST    = '0.0.0.0'
         | 
| 7 7 | 
             
            PORT    = '8000'
         | 
| 8 8 |  | 
| 9 9 | 
             
            require_relative '../lib/optimist'
         | 
| 10 | 
            -
             | 
| 11 | 
            -
            apps =  | 
| 10 | 
            +
            require_relative '../apps/index'
         | 
| 11 | 
            +
            apps = PagyApps::INDEX
         | 
| 12 12 | 
             
            opts = Optimist.options do
         | 
| 13 13 | 
             
              text <<~HEAD
         | 
| 14 14 | 
             
                Pagy #{VERSION} (https://ddnexus.github.io/pagy/playground)
         | 
    
        data/config/pagy.rb
    CHANGED
    
    | @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            -
            # Pagy initializer file (9. | 
| 3 | 
            +
            # Pagy initializer file (9.3.0)
         | 
| 4 4 | 
             
            # Customize only what you really need and notice that the core Pagy works also without any of the following lines.
         | 
| 5 5 | 
             
            # Should you just cherry pick part of this file, please maintain the require-order of the extras
         | 
| 6 6 |  |