|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +# Pagy initializer file (6.0.0) |
| 4 | +# Customize only what you really need and notice that the core Pagy works also without any of the following lines. |
| 5 | +# Should you just cherry pick part of this file, please maintain the require-order of the extras |
| 6 | + |
| 7 | +# Pagy DEFAULT Variables |
| 8 | +# See https://ddnexus.github.io/pagy/docs/api/pagy#variables |
| 9 | +# All the Pagy::DEFAULT are set for all the Pagy instances but can be overridden per instance by just passing them to |
| 10 | +# Pagy.new|Pagy::Countless.new|Pagy::Calendar::*.new or any of the #pagy* controller methods |
| 11 | + |
| 12 | +# Instance variables |
| 13 | +# See https://ddnexus.github.io/pagy/docs/api/pagy#instance-variables |
| 14 | +# Pagy::DEFAULT[:page] = 1 # default |
| 15 | +# Pagy::DEFAULT[:items] = 20 # default |
| 16 | +# Pagy::DEFAULT[:outset] = 0 # default |
| 17 | + |
| 18 | +# Other Variables |
| 19 | +# See https://ddnexus.github.io/pagy/docs/api/pagy#other-variables |
| 20 | +# Pagy::DEFAULT[:size] = [1,4,4,1] # default |
| 21 | +# Pagy::DEFAULT[:page_param] = :page # default |
| 22 | +# The :params can be also set as a lambda e.g ->(params){ params.exclude('useless').merge!('custom' => 'useful') } |
| 23 | +# Pagy::DEFAULT[:params] = {} # default |
| 24 | +# Pagy::DEFAULT[:fragment] = '#fragment' # example |
| 25 | +# Pagy::DEFAULT[:link_extra] = 'data-remote="true"' # example |
| 26 | +# Pagy::DEFAULT[:i18n_key] = 'pagy.item_name' # default |
| 27 | +# Pagy::DEFAULT[:cycle] = true # example |
| 28 | +# Pagy::DEFAULT[:request_path] = "/foo" # example |
| 29 | + |
| 30 | +# Extras |
| 31 | +# See https://ddnexus.github.io/pagy/docs/extras |
| 32 | + |
| 33 | +# Backend Extras |
| 34 | + |
| 35 | +# Array extra: Paginate arrays efficiently, avoiding expensive array-wrapping and without overriding |
| 36 | +# See https://ddnexus.github.io/pagy/docs/extras/array |
| 37 | +# require 'pagy/extras/array' |
| 38 | + |
| 39 | +# Calendar extra: Add pagination filtering by calendar time unit (year, quarter, month, week, day) |
| 40 | +# See https://ddnexus.github.io/pagy/docs/extras/calendar |
| 41 | +# require 'pagy/extras/calendar' |
| 42 | +# Default for each unit |
| 43 | +# Pagy::Calendar::Year::DEFAULT[:order] = :asc # Time direction of pagination |
| 44 | +# Pagy::Calendar::Year::DEFAULT[:format] = '%Y' # strftime format |
| 45 | +# |
| 46 | +# Pagy::Calendar::Quarter::DEFAULT[:order] = :asc # Time direction of pagination |
| 47 | +# Pagy::Calendar::Quarter::DEFAULT[:format] = '%Y-Q%q' # strftime format |
| 48 | +# |
| 49 | +# Pagy::Calendar::Month::DEFAULT[:order] = :asc # Time direction of pagination |
| 50 | +# Pagy::Calendar::Month::DEFAULT[:format] = '%Y-%m' # strftime format |
| 51 | +# |
| 52 | +# Pagy::Calendar::Week::DEFAULT[:order] = :asc # Time direction of pagination |
| 53 | +# Pagy::Calendar::Week::DEFAULT[:format] = '%Y-%W' # strftime format |
| 54 | +# |
| 55 | +# Pagy::Calendar::Day::DEFAULT[:order] = :asc # Time direction of pagination |
| 56 | +# Pagy::Calendar::Day::DEFAULT[:format] = '%Y-%m-%d' # strftime format |
| 57 | +# |
| 58 | +# Uncomment the following lines, if you need calendar localization without using the I18n extra |
| 59 | +# module LocalizePagyCalendar |
| 60 | +# def localize(time, opts) |
| 61 | +# ::I18n.l(time, **opts) |
| 62 | +# end |
| 63 | +# end |
| 64 | +# Pagy::Calendar.prepend LocalizePagyCalendar |
| 65 | + |
| 66 | +# Countless extra: Paginate without any count, saving one query per rendering |
| 67 | +# See https://ddnexus.github.io/pagy/docs/extras/countless |
| 68 | +# require 'pagy/extras/countless' |
| 69 | +# Pagy::DEFAULT[:countless_minimal] = false # default (eager loading) |
| 70 | + |
| 71 | +# Elasticsearch Rails extra: Paginate `ElasticsearchRails::Results` objects |
| 72 | +# See https://ddnexus.github.io/pagy/docs/extras/elasticsearch_rails |
| 73 | +# Default :pagy_search method: change only if you use also |
| 74 | +# the searchkick or meilisearch extra that defines the same |
| 75 | +# Pagy::DEFAULT[:elasticsearch_rails_pagy_search] = :pagy_search |
| 76 | +# Default original :search method called internally to do the actual search |
| 77 | +# Pagy::DEFAULT[:elasticsearch_rails_search] = :search |
| 78 | +# require 'pagy/extras/elasticsearch_rails' |
| 79 | + |
| 80 | +# Headers extra: http response headers (and other helpers) useful for API pagination |
| 81 | +# See http://ddnexus.github.io/pagy/extras/headers |
| 82 | +# require 'pagy/extras/headers' |
| 83 | +# Pagy::DEFAULT[:headers] = { page: 'Current-Page', |
| 84 | +# items: 'Page-Items', |
| 85 | +# count: 'Total-Count', |
| 86 | +# pages: 'Total-Pages' } # default |
| 87 | + |
| 88 | +# Meilisearch extra: Paginate `Meilisearch` result objects |
| 89 | +# See https://ddnexus.github.io/pagy/docs/extras/meilisearch |
| 90 | +# Default :pagy_search method: change only if you use also |
| 91 | +# the elasticsearch_rails or searchkick extra that define the same method |
| 92 | +# Pagy::DEFAULT[:meilisearch_pagy_search] = :pagy_search |
| 93 | +# Default original :search method called internally to do the actual search |
| 94 | +# Pagy::DEFAULT[:meilisearch_search] = :ms_search |
| 95 | +# require 'pagy/extras/meilisearch' |
| 96 | + |
| 97 | +# Metadata extra: Provides the pagination metadata to Javascript frameworks like Vue.js, react.js, etc. |
| 98 | +# See https://ddnexus.github.io/pagy/docs/extras/metadata |
| 99 | +# you must require the frontend helpers internal extra (BEFORE the metadata extra) ONLY if you need also the :sequels |
| 100 | +# require 'pagy/extras/frontend_helpers' |
| 101 | +# require 'pagy/extras/metadata' |
| 102 | +# For performance reasons, you should explicitly set ONLY the metadata you use in the frontend |
| 103 | +# Pagy::DEFAULT[:metadata] = %i[scaffold_url page prev next last] # example |
| 104 | + |
| 105 | +# Searchkick extra: Paginate `Searchkick::Results` objects |
| 106 | +# See https://ddnexus.github.io/pagy/docs/extras/searchkick |
| 107 | +# Default :pagy_search method: change only if you use also |
| 108 | +# the elasticsearch_rails or meilisearch extra that defines the same |
| 109 | +# DEFAULT[:searchkick_pagy_search] = :pagy_search |
| 110 | +# Default original :search method called internally to do the actual search |
| 111 | +# Pagy::DEFAULT[:searchkick_search] = :search |
| 112 | +# require 'pagy/extras/searchkick' |
| 113 | +# uncomment if you are going to use Searchkick.pagy_search |
| 114 | +# Searchkick.extend Pagy::Searchkick |
| 115 | + |
| 116 | +# Frontend Extras |
| 117 | + |
| 118 | +# Bootstrap extra: Add nav, nav_js and combo_nav_js helpers and templates for Bootstrap pagination |
| 119 | +# See https://ddnexus.github.io/pagy/docs/extras/bootstrap |
| 120 | +# require 'pagy/extras/bootstrap' |
| 121 | + |
| 122 | +# Bulma extra: Add nav, nav_js and combo_nav_js helpers and templates for Bulma pagination |
| 123 | +# See https://ddnexus.github.io/pagy/docs/extras/bulma |
| 124 | +# require 'pagy/extras/bulma' |
| 125 | + |
| 126 | +# Foundation extra: Add nav, nav_js and combo_nav_js helpers and templates for Foundation pagination |
| 127 | +# See https://ddnexus.github.io/pagy/docs/extras/foundation |
| 128 | +# require 'pagy/extras/foundation' |
| 129 | + |
| 130 | +# Materialize extra: Add nav, nav_js and combo_nav_js helpers for Materialize pagination |
| 131 | +# See https://ddnexus.github.io/pagy/docs/extras/materialize |
| 132 | +# require 'pagy/extras/materialize' |
| 133 | + |
| 134 | +# Navs extra: Add nav_js and combo_nav_js javascript helpers |
| 135 | +# Notice: the other frontend extras add their own framework-styled versions, |
| 136 | +# so require this extra only if you need the unstyled version |
| 137 | +# See https://ddnexus.github.io/pagy/docs/extras/navs |
| 138 | +# require 'pagy/extras/navs' |
| 139 | + |
| 140 | +# Semantic extra: Add nav, nav_js and combo_nav_js helpers for Semantic UI pagination |
| 141 | +# See https://ddnexus.github.io/pagy/docs/extras/semantic |
| 142 | +# require 'pagy/extras/semantic' |
| 143 | + |
| 144 | +# UIkit extra: Add nav helper and templates for UIkit pagination |
| 145 | +# See https://ddnexus.github.io/pagy/docs/extras/uikit |
| 146 | +# require 'pagy/extras/uikit' |
| 147 | + |
| 148 | +# Multi size var used by the *_nav_js helpers |
| 149 | +# See https://ddnexus.github.io/pagy/docs/extras/navs#steps |
| 150 | +# Pagy::DEFAULT[:steps] = { 0 => [2,3,3,2], 540 => [3,5,5,3], 720 => [5,7,7,5] } # example |
| 151 | + |
| 152 | +# Feature Extras |
| 153 | + |
| 154 | +# Gearbox extra: Automatically change the number of items per page depending on the page number |
| 155 | +# See https://ddnexus.github.io/pagy/docs/extras/gearbox |
| 156 | +# require 'pagy/extras/gearbox' |
| 157 | +# set to false only if you want to make :gearbox_extra an opt-in variable |
| 158 | +# Pagy::DEFAULT[:gearbox_extra] = false # default true |
| 159 | +# Pagy::DEFAULT[:gearbox_items] = [15, 30, 60, 100] # default |
| 160 | + |
| 161 | +# Items extra: Allow the client to request a custom number of items per page with an optional selector UI |
| 162 | +# See https://ddnexus.github.io/pagy/docs/extras/items |
| 163 | +# require 'pagy/extras/items' |
| 164 | +# set to false only if you want to make :items_extra an opt-in variable |
| 165 | +# Pagy::DEFAULT[:items_extra] = false # default true |
| 166 | +# Pagy::DEFAULT[:items_param] = :items # default |
| 167 | +# Pagy::DEFAULT[:max_items] = 100 # default |
| 168 | + |
| 169 | +# Overflow extra: Allow for easy handling of overflowing pages |
| 170 | +# See https://ddnexus.github.io/pagy/docs/extras/overflow |
| 171 | +# require 'pagy/extras/overflow' |
| 172 | +# Pagy::DEFAULT[:overflow] = :empty_page # default (other options: :last_page and :exception) |
| 173 | + |
| 174 | +# Support extra: Extra support for features like: incremental, infinite, auto-scroll pagination |
| 175 | +# See https://ddnexus.github.io/pagy/docs/extras/support |
| 176 | +# require 'pagy/extras/support' |
| 177 | + |
| 178 | +# Trim extra: Remove the page=1 param from links |
| 179 | +# See https://ddnexus.github.io/pagy/docs/extras/trim |
| 180 | +# require 'pagy/extras/trim' |
| 181 | +# set to false only if you want to make :trim_extra an opt-in variable |
| 182 | +# Pagy::DEFAULT[:trim_extra] = false # default true |
| 183 | + |
| 184 | +# Standalone extra: Use pagy in non Rack environment/gem |
| 185 | +# See https://ddnexus.github.io/pagy/docs/extras/standalone |
| 186 | +# require 'pagy/extras/standalone' |
| 187 | +# Pagy::DEFAULT[:url] = 'http://www.example.com/subdir' # optional default |
| 188 | + |
| 189 | +# Rails |
| 190 | +# Enable the .js file required by the helpers that use javascript |
| 191 | +# (pagy*_nav_js, pagy*_combo_nav_js, and pagy_items_selector_js) |
| 192 | +# See https://ddnexus.github.io/pagy/docs/extras#javascript |
| 193 | + |
| 194 | +# With the asset pipeline |
| 195 | +# Sprockets need to look into the pagy javascripts dir, so add it to the assets paths |
| 196 | +# Rails.application.config.assets.paths << Pagy.root.join('javascripts') |
| 197 | + |
| 198 | +# I18n |
| 199 | + |
| 200 | +# Pagy internal I18n: ~18x faster using ~10x less memory than the i18n gem |
| 201 | +# See https://ddnexus.github.io/pagy/docs/api/frontend#i18n |
| 202 | +# Notice: No need to configure anything in this section if your app uses only "en" |
| 203 | +# or if you use the i18n extra below |
| 204 | +# |
| 205 | +# Examples: |
| 206 | +# load the "de" built-in locale: |
| 207 | +# Pagy::I18n.load(locale: 'de') |
| 208 | +# |
| 209 | +# load the "de" locale defined in the custom file at :filepath: |
| 210 | +# Pagy::I18n.load(locale: 'de', filepath: 'path/to/pagy-de.yml') |
| 211 | +# |
| 212 | +# load the "de", "en" and "es" built-in locales: |
| 213 | +# (the first passed :locale will be used also as the default_locale) |
| 214 | +# Pagy::I18n.load({ locale: 'de' }, |
| 215 | +# { locale: 'en' }, |
| 216 | +# { locale: 'es' }) |
| 217 | +# |
| 218 | +# load the "en" built-in locale, a custom "es" locale, |
| 219 | +# and a totally custom locale complete with a custom :pluralize proc: |
| 220 | +# (the first passed :locale will be used also as the default_locale) |
| 221 | +# Pagy::I18n.load({ locale: 'en' }, |
| 222 | +# { locale: 'es', filepath: 'path/to/pagy-es.yml' }, |
| 223 | +# { locale: 'xyz', # not built-in |
| 224 | +# filepath: 'path/to/pagy-xyz.yml', |
| 225 | +# pluralize: lambda{ |count| ... } ) |
| 226 | + |
| 227 | +# I18n extra: uses the standard i18n gem which is ~18x slower using ~10x more memory |
| 228 | +# than the default pagy internal i18n (see above) |
| 229 | +# See https://ddnexus.github.io/pagy/docs/extras/i18n |
| 230 | +# require 'pagy/extras/i18n' |
| 231 | + |
| 232 | +# Default i18n key |
| 233 | +# Pagy::DEFAULT[:i18n_key] = 'pagy.item_name' # default |
| 234 | + |
| 235 | +# When you are done setting your own default freeze it, so it will not get changed accidentally |
| 236 | +Pagy::DEFAULT.freeze |
0 commit comments