Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AO3-6880 Use pagy gem for pagination on select pages #5054

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

ceithir
Copy link
Contributor

@ceithir ceithir commented Feb 6, 2025

Pull Request Checklist

Issue

https://otwarchive.atlassian.net/browse/AO3-6880

Purpose

As per ticket.

Visible (frontend) differences from will_paginate:

  • rel="prev" and rel="next" have disappeared but seem to be obsolete anyway (cf https://developers.google.com/search/docs/specialty/ecommerce/pagination-and-incremental-page-loading)
  • Weird title attributes (all equal to an untranslated "pagination" string) have not made the cut
  • Blank space characters between <li> tags have been removed. In other words, the HTML was previously </li> <li> and is now </li><li>. This means the pagination is slightly more compact looking. Maybe need to add back some padding in CSS?
  • will_paginate was always showing the first two and the last two items in the list (1 2 ... <> ... 312 313) while pagy only shows the very first and the last (1 ... <> ... 313). There doesn't seem to be an option to modify that behavior without going into the code (cf Pagy#series). Unsure if worth it.

Before/after pictures:
will_paginate
pagy

Testing Instructions

In theory, everything should be working as before on the three modified pages, except for the minor changes listed above.

Credit

Ceithir (he/him)

app/views/bookmarks/index.html.erb Fixed Show fixed Hide fixed
app/views/bookmarks/index.html.erb Fixed Show fixed Hide fixed
app/views/works/index.html.erb Fixed Show fixed Hide fixed
app/views/works/index.html.erb Fixed Show fixed Hide fixed
@ceithir
Copy link
Contributor Author

ceithir commented Feb 6, 2025

Supposedly, the Brakeman warnings should be ignored. Not sure if/how I can tell Github Actions to ignore them on my side (our doc only refers to the local ignore file)

rescue Pagy::OverflowError
nil
end
end
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping the same behavior as now by not showing the pagination in case of overflow ("page 66 of 10").

pagy's alternative options for reference.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're not setting Pagy::DEFAULT[:overflow], the default is :empty_page instead of :exception, do we need to wrap calls in pagy_overflow_handler?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the require 'pagy/extras/overflow' line, Pagy always raises an exception in case of overflow (source)

@redsummernight
Copy link
Member

Supposedly, the Brakeman warnings should be ignored. Not sure if/how I can tell Github Actions to ignore them on my side (our doc only refers to the local ignore file)

You can add pagy_nav as a safe method in config/brakeman.yml.

We stopped keeping the ignore file in the repo since #4158. I'll update the wiki.

rescue Pagy::OverflowError
nil
end
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're not setting Pagy::DEFAULT[:overflow], the default is :empty_page instead of :exception, do we need to wrap calls in pagy_overflow_handler?

app/helpers/application_helper.rb Outdated Show resolved Hide resolved
app/helpers/application_helper.rb Outdated Show resolved Hide resolved
Copy link
Member

@redsummernight redsummernight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants