Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Jun 5, 2024
2 parents 62f5563 + 0e64b31 commit ce26030
Show file tree
Hide file tree
Showing 38 changed files with 348 additions and 352 deletions.
1 change: 1 addition & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Here are a few useful information for contributors:
the [Pagy Playground](https://ddnexus.github.io/pagy/playground) and/or
with the [Pagy::Console](https://ddnexus.github.io/pagy/docs/api/console/) directly from the repo
- **Docs**
- The docs run on retype, and the repo is configured for its linux package. You may want to install the [platform specific npm package](https://retype.com/guides/getting-started/#platform-specific) in order to use it
- `cd` in the pagy root directory
- Install [bun](https://bun.sh/docs/installation)
- Run `bun install`
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/Code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ body:
attributes:
label: 👀 Before submitting...
options:
- label: I upgraded to pagy version 8.4.2
- label: I upgraded to pagy version 8.4.3
required: true
- label: I searched through the [Documentation](https://ddnexus.github.io/pagy/)
required: true
Expand Down
7 changes: 3 additions & 4 deletions .github/latest_release_body.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### ✴ What's new in 8.3+ ✴
### ✴ What's new in 8.0+ ✴

- New [Pagy Playground](https://ddnexus.github.io/pagy/playground/) to showcase, clone and develop pagy APPs without any setup on
your side (try the [pagy demo](https://ddnexus.github.io/pagy/playground.md#3-demo-app))
Expand All @@ -8,11 +8,10 @@
the [details](https://github.com/ddnexus/pagy/discussions/672#discussioncomment-9212328))
- See the [CHANGELOG](https://ddnexus.github.io/pagy/changelog) for possible breaking changes

### Changes in 8.4.2
### Changes in 8.4.3

<!-- changes start -->
- Limit the playground --rerun option to linux platforms
- Simplify and improve the js environment by using bun
- Deprecate/rename javascript files keeping copies of old files to avoid production breaking changes; updates playground apps
<!-- changes end -->

[CHANGELOG](https://ddnexus.github.io/pagy/changelog)

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,17 @@ If you upgrade from version `< 8.0.0` see the following:
- The `foundation`, `materialize`, `semantic` and `uikit` CSS extras have been discontinued and will be removed in v9
(See the [details](https://github.com/ddnexus/pagy/discussions/672#discussioncomment-9212328))
- Protected method `Pagy#setup_pages_var`. Use `Pagy#setup_last_var` instead

- **Javascript files renamed**
- `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`
<hr>

## Version 8.4.3

- Deprecate/rename javascript files keeping copies of old files to avoid production breaking changes; updates playground apps

## Version 8.4.2

- Limit the playground --rerun option to linux platforms
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: gem
specs:
pagy (8.4.2)
pagy (8.4.3)

GEM
remote: https://rubygems.org/
Expand Down
101 changes: 22 additions & 79 deletions docs/api/javascript/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,27 @@ in the browser.

### 1. Pick a Javascript File

+++ `pagy-module.js`
+++ `pagy.mjs`

!!! success
Your app uses modern build tools
!!!

* ES6 module to use with webpacker, esbuild, parcel, etc.

[!file](/gem/javascripts/pagy-module.js)
[!file](/gem/javascripts/pagy.mjs)

```ruby
module_path = Pagy.root.join('javascripts', 'pagy-module.js')
module_path = Pagy.root.join('javascripts', 'pagy.mjs')
```

[!file](/gem/javascripts/pagy-module.d.ts)
[!file](/gem/javascripts/pagy.d.ts)

```ruby
types_path = Pagy.root.join('javascripts', 'pagy-modules.d.ts')
types_path = Pagy.root.join('javascripts', 'pagy.d.ts')
```

+++ `pagy.js`
+++ `pagy.min.js`
!!! success
Your app needs standard script or old browser compatibility
!!!
Expand All @@ -59,30 +59,22 @@ Your app needs standard script or old browser compatibility
production pages and without any further processing
* Minified (~2k) and polyfilled to work also with quite old browsers

[!file](/gem/javascripts/pagy.js)
[!file](/gem/javascripts/pagy.min.js)

```ruby
script_path = Pagy.root.join('javascripts', 'pagy.js')
script_path = Pagy.root.join('javascripts', 'pagy.min.js')
```

+++ `pagy-dev.js`
+++ `pagy.min.js.map`

!!! success
You need to debug the javascript helpers
You need to debug the javascript helpers while using the `pagy.min.js` file
!!!

!!! warning Debug only!

* Large size
* It contains the source map to debug typescript
* It works only on new browsers

!!!

[!file](/gem/javascripts/pagy-dev.js)
[!file](/gem/javascripts/pagy.min.js.map)

```ruby
script_path = Pagy.root.join('javascripts', 'pagy-dev.js')
script_path = Pagy.root.join('javascripts', 'pagy.min.js.map')
```

+++
Expand Down Expand Up @@ -112,11 +104,11 @@ Rails.application.config.assets.paths << Pagy.root.join('javascripts') #uncommen
```

```js app/assets/config/manifest.js
//= link pagy-module.js
//= link pagy.mjs
```

```ruby config/importmap.rb
pin 'pagy-module'
pin 'pagy'
```

+++ Propshaft
Expand All @@ -133,18 +125,18 @@ Rails.application.config.assets.paths << Pagy.root.join('javascripts')

#### Builders

In order to bundle the `pagy-module.js` your builder has to find it either with a link or local copy, or by looking into the pagy
In order to bundle the `pagy.mjs` your builder has to find it either with a link or local copy, or by looking into the pagy
javascript path:

+++ Generic
You can create a symlink or a copy of the `pagy-module.js` file (available in the pagy gem) into an app compiled dir and use it as
You can create a symlink or a copy of the `pagy.mjs` file (available in the pagy gem) into an app compiled dir and use it as
a regular app file. That way any builder will pick it up. For example:

```ruby config/initializers/pagy.rb
# Create/refresh the `app/javascript/pagy-module.js` symlink/copy every time
# Create/refresh the `app/javascript/pagy.mjs` symlink/copy every time
# the app restarts (unless in production), ensuring syncing when pagy is updated.
# Replace the FileUtils.ln_sf with FileUtils.cp if your OS doesn't support file linking.
FileUtils.ln_sf(Pagy.root.join('javascripts', 'pagy-module.js'), Rails.root.join('app', 'javascript')) \
FileUtils.ln_sf(Pagy.root.join('javascripts', 'pagy.mjs'), Rails.root.join('app', 'javascript')) \
unless Rails.env.production?
```

Expand Down Expand Up @@ -178,55 +170,6 @@ module.exports = {
}
```

#### Legacy way

Ensure that the `erb` loader is installed:

```sh
bundle exec rails webpacker:install:erb
```

Generate a local pagy javascript file using `erb` with webpacker:

```erb app/javascript/packs/pagy.js.erb
<%= Pagy.root.join('javascripts', 'pagy.js').read %>
window.addEventListener(YOUR_EVENT_LISTENER, Pagy.init)
```

_where `YOUR_EVENT_LISTENER` is the load event that works with your app (
e.g. `"turbo:load"`, `"turbolinks:load"`, `"load"`, ...)._

```js app/javascript/application.js
import './pagy.js.erb'
```

+++ Rollup
Prepend the `NODE_PATH` environment variable to the `scripts.build` command:

```json package.json
{
"build": "NODE_PATH=\"$(bundle show 'pagy')/javascripts\" <your original command>"
}
```

Configure the `plugins[resolve]`:

```js rollup.confg.js
export default {
..., // your original config
plugins: [
resolve({
moduleDirectories: [ // add moduleDirectories
"node_modules", // node_modules dir
process.env.PAGY_PATH // pagy dir
]
})
]
}
```

+++

#### Non-Rails apps

* Just ensure `Pagy.root.join('javascripts', 'pagy.js')` is served with the page.
Expand All @@ -239,7 +182,7 @@ After the helper is loaded you have to initialize `Pagy` to make it work:

```js pagy_initializer_controller.js
import {Controller} from "@hotwired/stimulus"
import Pagy from "pagy-module" // if using sprockets, you can remove above line, but make sure you have the appropriate directive if your manifest.js file.
import Pagy from "pagy" // if using sprockets, you can remove above line, but make sure you have the appropriate directive if your manifest.js file.

export default class extends Controller {
connect() {
Expand All @@ -258,16 +201,16 @@ export default class extends Controller {
Import and use the pagy module:

```js app/javascript/application.js
import Pagy from "pagy-module";
import Pagy from "pagy";

window.addEventListener("turbo:load", Pagy.init);
```

+++ Others

```js
// if you choose pagy-module.js
import Pagy from "pagy-module"
// if you choose pagy.mjs
import Pagy from "pagy"

// plain javascript
window.addEventListener("load", Pagy.init)
Expand Down
2 changes: 1 addition & 1 deletion e2e/cypress/e2e/calendar.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {snapIds} from "../support/test-helper.ts";

const app = "calendar";
const app = "calendar";
const calIds = ["#year-nav", "#month-nav", "#day-nav", "#pagy-info"];

describe(`[${app}] Test helpers`, () => {
Expand Down
2 changes: 1 addition & 1 deletion e2e/cypress/e2e/demo.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {testNav, testComboNav, testInfo, testItemsSelector} from "../support/test-helper.ts";

const app = "demo";
const app = "demo";
const paths = [
"/pagy",
"/bootstrap",
Expand Down
2 changes: 1 addition & 1 deletion e2e/cypress/support/test-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export function testComboNav(app:string, id:string) {

export function testItemsSelector(app:string, id:string, path = "/", trim = false) {
it(`[${app}] Test ${id}`, () => {
const pages = [1, 36, 50];
const pages = [1, 36, 50];
const id_input = `${id} input`;
for (const page of pages) {
cy.visit(`${path}?page=${page}`);
Expand Down
2 changes: 1 addition & 1 deletion gem/apps/calendar.ru
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# DOC
# https://ddnexus.github.io/pagy/playground/#4-calendar-app

VERSION = '8.4.2'
VERSION = '8.4.3'

require 'bundler/inline'
require 'bundler'
Expand Down
Loading

0 comments on commit ce26030

Please sign in to comment.