Skip to content

Commit

Permalink
WIP: Add a few notes about the new changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Jan 20, 2025
1 parent ae31038 commit 554718d
Show file tree
Hide file tree
Showing 3 changed files with 342 additions and 1 deletion.
176 changes: 176 additions & 0 deletions CHANGELOG-10.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
---
icon: versions-24
---

# CHANGELOG

## Release Policy

Pagy follows the [Semantic Versioning 2.0.0](https://semver.org/), and introduces BREAKING CHANGES only for MAYOR versions.

We release any new version (MAJOR, MINOR, PATCH) as soon as it is ready for release, regardless of any time constraint, frequency
or duration.

We rarely deprecate elements (releasing a new MAYOR version is just simpler and more efficient). However, when we do, you can
expect the old/deprecated functionality to be supported ONLY during the current MAYOR version.

## Recommended Version Constraint

Given a version number `MAJOR.MINOR.PATCH` (e.g. `10.0.0`):

The `gem 'pagy', '~> 10.0'` Gemfile entry (without the PATCH number) ensures that the `bundle update` command will update pagy to
the most recent version WITHOUT BREAKING CHANGES.

Increment the MAYOR version in your Gemfile ONLY when you are ready to handle the BREAKING CHANGES.

## Breaking Changes

If you upgrade from version `< 10.0.0` see the following:

- [Breaking changes in version 10.0.0](#version-1000)
- [Breaking changes in version 9.0.0](CHANGELOG_LEGACY.md#version-900)
- [Breaking changes in version 8.0.0](CHANGELOG_LEGACY.md#version-800)
- [Breaking changes in version 7.0.0](CHANGELOG_LEGACY.md#version-700)
- [Breaking changes in version 6.0.0](CHANGELOG_LEGACY.md#version-600)
- [Breaking changes in version 5.0.0](CHANGELOG_LEGACY.md#version-500)
- [Breaking changes in version 4.0.0](CHANGELOG_LEGACY.md#version-400)
- [Breaking changes in version 3.0.0](CHANGELOG_LEGACY.md#version-300)
- [Breaking changes in version 2.0.0](CHANGELOG_LEGACY.md#version-200)
- [Breaking changes in version 1.0.0](CHANGELOG_LEGACY.md#version-100)

## Deprecations

None

<hr>

## Version 10.0.0

### Overview

This is a mayor, MAYOR version, with important additions and improvements, a lot easier to use and customize, it has fewer methods
and variables, cleaner code with a brand-new documentation and the new `Pagy AI`, ready to answer your questions.

### Keynav Pagination Addition

We invented the `keynav` new exclusive technique to use `keyset` pagination with `pagy_*navs` and other Frontend helpers. The best technique
for performance AND functionality!

### Improvements

**Automatic loading of just the code that you actually use**
Every class, module and helper is automatically loaded only if you actually use it, without any explicit `require`.
_(the legacy version was requiring more code)_

**Better file and namespace system organization**
The class hierarchy, the mixin files, and the test file structure have been deeply reorganized.
The code is cleaner, more concise and more readable, adding fewer modules in the `ancestors` array of yur app.

**The extras are almost all gone**
They have been converted to autoloaded mixins, or integrated in the core code at zero-cost. You can use the methods that you
need, and they will just work without explicit requiring.
The only extras that are left _(for different compelling reasons)_ are: `gearbox`, `i18n` and `size`. They must be required in
the initializer as usual.

**The Pagy::Countless remembers the last page**
When you jump back in the page nav, it remembers the current page count, so you can jump forward.

**Cleaner URLs**
No more empty params or extra '?' in the url string
URL templates are safer for string manipulation.
The `pagy_page_url` (legacy `pagy_url_for`) can be used also without a request (incorporating the legacy `standalone` extra)

**Javascript refactoring**
Updated the support for the pagy helpers and keynav pagination.
Added the plain `pagy.js` and relative source map.

### Breaking Changes

#### Core Changes

**The `Pagy::DEFAULT` is now frozen**
Remove all the `Pagy::DEFAULT` variables from your code and pass their variables to the constructor. As an alternative to
avoid repetitions, define your own `PAGY_DEFAULT = {...}` hash and pass it to the different constructors:
`pagy_offset(scope, **PAGY_DEFAULT, ...)`

**Direct instantiation of the pagy constructor classes is not recommended**
Use the provided constructor helpers for easier usage, maintenance and forward compatibility.

**Other changes**
Replace the existing (if any) `Pagy.root` with `Pagy::ROOT`
When the `:params` variable is set to a lambda, it should modify the passed `query_params` directly. The returned value is now
ignored for a sligtly better performance.

#### Simple renaming (without logic changes)

| Type | Search | Replace | Notes |
|-------------|----------------|-----------------|----------------------------------------------------------|
| Constructor | `pagy(` | `pagy_offset(` | For consistency with the other old and new constructors |
| Method | `pagy_url_for` | `pagy_page_url` | The legacy naming was causing rails-related expectations |

#### Extras Replacement

##### `arel`, `array`, `boostrap`, `bulma`, `calendar`, `countless`, `headers`, `keyset`, `pagy`

- Just remove the `require 'pagy/extras/<extra-name>'` from the initializer, and continue to use their features without changes.

##### `elasticsearch_rails`, `meilisearch`, `searchkick`

- Remove the `require 'pagy/extras/<extra-name>'` from the initializer
- Replace your existing (if any) `Pagy.new_from_<extra-name>` with `pagy_<extra-name>`. _(Active and passive modes are now handled
by the same helper.)_
- Replace the existing (if any) `extend Pagy::Search` statement in your models with `extend Pagy::Offset::Search`.
- The `pagy_search` name customization has been discontinued. Remove the existing (if any) `:<extra-name>_pagy_search`
variable from your code, and use the standard `pagy_search` method.
- Rename the existing (if any) `:<extra-name>_search` variable as `:search_method` and pass it to the constructor.

##### `jsonapi`

- Remove the `require 'pagy/extras/jsonapi'` from the initializer.
- Rename `pagy_jsonapi_links` as `pagy_links`. Notice that the `nil` links are now removed as the `JSON:API`
requires.
- You should pass the `:jsonapi` variable to the constructor when you want to trigger the feature.

##### `limit`

- Remove the `require 'pagy/extras/limit'` from the initializer.
- You should pass the `:maxable_limit` variable - set to the max limit allowed - to the constructor when you want to trigger the
feature.

##### `metadata`

- Remove the `require 'pagy/extras/metadata'` from the initializer.
- Rename the existing (if any) `:scaffold_url` to `url_template`

##### `overflow`

- Remove the `require 'pagy/extras/overflow'` from the initializer.
- You should pass the `:overflow: ...` variable to the constructor when you want to trigger the feature.

#### `standlone`

- Remove the `require 'pagy/extras/standalone'` from the initializer.
- Replace the `:url` variable with `:request`, and its content with `{ url_prefix: 'the-previous-value-of-url' }`. You can also
optionally add your `query_params` hash. For example `{ query_params: { param1: 'abc', param2: 'def' }` for complete control
over the generated url.

##### `trim` (discontinued)

- It was mostly useless and half backed, causing a lot of complications in the ruby and javascript code.
- Use a proper way to address your requirement, like using URL rewriting at the HTTP server level.

##### `gearbox`

- Remove the `:gearbox_extra` variable from your code
- You should pass the `gearbox_limit: [...]` variable to the constructor when you want to trigger the feature.

##### `i18n`, `size`

- No change required.

#### Possibly Breaking Overridings

- The internal Pagy protected methods have been renamed and refactored. If you use custom Pagy classes, you may need to search
into the code.

[LEGACY CHANGELOG >>>](CHANGELOG_LEGACY.md)
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Given a version number `MAJOR.MINOR.PATCH` (e.g. `9.3.3`):
The `gem 'pagy', '~> 9.3'` Gemfile entry (without the PATCH number) ensures that the `bundle update` command will update pagy to
the most recent version WITHOUT BREAKING CHANGES.

Increment the MAYOR version indicated in the Gemfile ONLY when you are ready to handle the BREAKING CHANGES
Increment the MAYOR version in the Gemfile ONLY when you are ready to handle the BREAKING CHANGES.

## Breaking Changes

Expand Down
165 changes: 165 additions & 0 deletions CHANGELOG_LEGACY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,171 @@ visibility: hidden

# LEGACY CHANGELOG

## Version 9.3.3

- Add test for locales - to find problematic keys (#752)
- Update locales: zh-CN, zh-HK, zh-TW (#751) (fix #608, fix #609, fix #610)
- Remove :other from :aria_label key and code comment
- Change :item_name which had :one_other keys to default to the :other key
- Fix comment

## Version 9.3.2

- Improve gapped series computation by a few milliseconds

## Version 9.3.1

- Added qualified column names to the keyset query

## Version 9.3.0

- Remove the :typecast_latest variable
- Add the :jsonify_keyset_attributes variable to override the encoding (#749)

## Version 9.2.2

- Replace inline templates with template block in sinatra apps
- Replace the rails calendar app with a sinatra app
- Add PagyApps::INDEX

## Version 9.2.1

- Improve bin/pagy to dynamically find apps and descriptions
- Apps refactoring:
- Update rails to 8.0
- Replace rails AR keyset apps with sinatra apps
- Improve consistency

## Version 9.2.0

- Simplify the keyset API:
- Deprecate the :after_latest variable in favour of :filter_newest
- Add the keyset argument to the :filter_newest lambda
- Rename protected after_latest_query > filter_newest_query

## Version 9.1.1

- Simplify calendar code

## Version 9.1.0

- Add Dzongkha (dz locale) (#741)

## Version 9.0.9

- Set freeze flag to false (#737)
- Fix: Prefix DEFAULT with Pagy:: (#736)

## Version 9.0.8

- Keep offset and limit variables untouched by the overflow extra in :empty_page mode (closes #733)

## Version 9.0.7

- Absolutize generic define? to fix module resolution

## Version 9.0.6

- Fix docs (closes #732)
- Replace pluck with pick

## Version 9.0.5

- Fix for missing variables passed to pagy_anchor from pagy_nav (closes #728)

## Version 9.0.4

- Fix groupdate timezone error on certain machines/config
- Fix gem containing tmp files

## Version 9.0.3

- Remove legacy and unused javascript files
- Improve pagy_get_page with force_integer option
- Fix jsonapi with keyset
- Complete the internal refactoring of version 9:
- Remove the pagy*_get_vars methods now useless
- Use to_i on the page variable for the search extras

## Version 9.0.2

- Rename and document the link header to pagy_link_header
- Add first and next url helpers to the keyset extra; add the keyset section to config/pagy.rb
- Fix nil page in keyset URL not overriding the params page
- Extracted shared method

## Version 9.0.1

- Fix countless executing the count query
- Rename row_comparison > tuple_comparison; ignore mixed orders

## Version 9.0.0

### Breaking Changes

#### Dropped support for deprecated stuff

- The `foundation`, `materialize`, `semantic` and `uikit` CSS extras have been removed:
(See the [reasons](https://github.com/ddnexus/pagy/discussions/672#discussioncomment-9212328))
- **Javascript renamed files**
- `pagy.js`: use `pagy.min.js`
- `pagy-module.js`: use `pagy.mjs`
- `pagy-dev.js`: use the `pagy.min.js`with the `pagy.min.js.map`
- `pagy-module.d.ts`: use `pagy.d.ts`
- The Array type for the `:size` (e.g. `size: [1, 4, 4, 1]`) that generates the classic bar is not supported anymore: use the
`:size` set to an integer with the `ends: true` variable (which are the default since 8.4.6). If a legacy bar remains REALLY a
requirement, add `require 'pagy/extras/size` to your `pagy.rb` initalizer. (See the
[size extra](https://ddnexus.github.io/pagy/docs/extras/size))

#### Simple renaming

We used `items` for too many things that confused even maintainers. The "items" are now referencing only the records/elements
fetched from a collection (plural entity), so they are kept as before (e.g. `pagy_*get_items` methods). The "number of items" (
singular entity), are now unmistakably referenced as the `limit` everywhere (code, API, files, extras, docs, etc.). The logic
didn't change so you have just to globally search 'items' and replace with `limit` and you should be done... or use the detailed
table below:

| Type | Search | Replace |
|-------------------|--------------------------|------------------------------|
| Pagy Variable | `:items` | `:limit` |
| Extra Path | `pagy/extras/items` | `pagy/extras/limit` |
| Extra Variable | `:items_param` | `:limit_param` |
| Default URL param | `items` | `limit` |
| Extra Variable | `:items_extra` | `:limit_extra` |
| Extra Variable | `:max_items` | `:limit_max` (now inverted) |
| Extra Method | `pagy_items_selector_js` | `pagy_limit_selector_js` |
| Extra Variable | `:headers[:items]` | `:headers[limit]` |

#### Code changes

- The `DEFAULT[:anchor_string]` was useless and has been dropped.
- The `:anchor_string`and the `:fragment` are not instance variables anymore, but keyword arguments for all the helpers, because
it is frontend code (see the [discussion](https://github.com/ddnexus/pagy/discussions/719)). Instead of passing them to the
`pagy*` method in the controller, pass it to any `pagy_*nav` method in the view.
- A general internal revamp has changed the positional argument for the Pagy::* objects and constructors methods to keyword
arguments. If you get a `wrong number of arguments (given 1, expected 0) (ArgumentError)`, just use a double splat `**`.

#### Possibly breaking overrides

- The internal Pagy protected methods have been renamed and refactored. If you use custom Pagy classes, you may need to search
into the code.

## Changes

- Improve Keyset::Sequel and docs
- BREAKING: Rename :max_limit > :limit_max
- BREAKING: Rename variable, param, accessor, extra and helper "items" to "limit"
- Add playground keyset_ar.ru and keyset_s.ru apps and integration with the rest of the gems
- Add keyset pagination base files
- Pagy::Keyset API
- ActiveRecord and Sequel adapters
- BREAKING: Transform the vars positional hash argument in keyword arguments (double splat); internal renaming of setup/assign
methods
- Refactor pagy_get_vars in various backend extras
- BREAKING: Refactor the fragment url
- BREAKING: Refactor the anchor_string system
- BREAKING: Drop the support for 8+ deprecations

## Version 8.6.3

- Add missing DEFAULT[:max_pages] hint to the config/pagy.rb
Expand Down

0 comments on commit 554718d

Please sign in to comment.