-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add sort options to languages page #10751
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
Add sort options to languages page #10751
Conversation
708b8f2
to
d49ac95
Compare
d49ac95
to
88c1120
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds sort options for the languages page so users can easily filter languages based on ebook counts and other criteria.
- Refactored sort options template logic to support nested sort options and conditional admin-only options.
- Updated languages rendering and backend sorting in the worksearch plugin to handle new sort parameters.
- Modified internationalization messages to match the updated sort option labels.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
openlibrary/templates/search/sort_options.html | Replaced the old sort_option_names dictionary and helper with a new get_selected_sort_option function and adjusted the admin check for the title sort option. |
openlibrary/templates/languages/index.html | Integrated the new sort options template for the languages page and adjusted link formatting in the language list. |
openlibrary/plugins/worksearch/languages.py | Added a new sort parameter for top languages, included marc_code and ebook edition count, and validated sort inputs. |
openlibrary/i18n/messages.pot | Updated msgid strings to reflect new sort option names and their order. |
Comments suppressed due to low confidence (1)
openlibrary/i18n/messages.pot:7023
- [nitpick] The msgid strings have been reordered and renamed to match new sort option labels; please verify that the translation mappings correspond correctly to the intended UI labels to avoid inconsistencies for translators and end users.
msgid "Most Recent"
selected = option['sort'] == selected_sort or option.get('selected') | ||
if selected: | ||
return option | ||
|
||
selected_sort_name = get_selected_sort_name(selected_sort, default_sort, sort_option_names) | ||
sub_sorts = option.get('sub_sorts', []) | ||
if sub_sorts: | ||
selected_sub_sort = get_selected_sort_option(sub_sorts, selected_sort) | ||
if selected_sub_sort: | ||
return selected_sub_sort | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The function returns immediately when a top-level option is marked as selected, which prevents checking for a more specific match among sub_sorts. Consider revising the logic order to ensure that nested sub_sort options are considered appropriately when available.
Copilot uses AI. Check for mistakes.
Small improvement to be able to easily find which languages have the most ebooks.
Technical
Testing
Screenshot
Stakeholders