Skip to content

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

Merged

Conversation

cdrini
Copy link
Collaborator

@cdrini cdrini commented May 10, 2025

Small improvement to be able to easily find which languages have the most ebooks.

Technical

Testing

Screenshot

image

Stakeholders

@cdrini cdrini force-pushed the feature/language-page-sorting branch from 708b8f2 to d49ac95 Compare May 10, 2025 09:12
@cdrini cdrini force-pushed the feature/language-page-sorting branch from d49ac95 to 88c1120 Compare May 12, 2025 20:26
@cdrini cdrini marked this pull request as ready for review May 12, 2025 20:27
@Copilot Copilot AI review requested due to automatic review settings May 12, 2025 20:27
Copy link
Contributor

@Copilot Copilot AI left a 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"

Comment on lines +9 to 18
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

Copy link
Preview

Copilot AI May 12, 2025

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.

@mekarpeles mekarpeles self-assigned this May 19, 2025
@mekarpeles mekarpeles added the Priority: 1 Do this week, receiving emails, time sensitive, . [managed] label May 27, 2025
@mekarpeles mekarpeles merged commit 8b3f45d into internetarchive:master Jun 6, 2025
4 checks passed
@cdrini cdrini deleted the feature/language-page-sorting branch June 6, 2025 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: 1 Do this week, receiving emails, time sensitive, . [managed]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants