Global "Book Preferences" filter on top IA bar
Feature Request
On OpenLibrary.org, the most common way for a patron to encounter books is through:
- book carousels
- search results
This issue can be split into multiple PRs, but the goal is to make it so that the patron has a set of global options that apply to carousel results and search results
These options include:
- A checkbox whether to display ebooks only (versus all book records in the catalog)
- A dropdown for selecting books in a specific language (a distinct option from changing the language of the website itself)
The search page already has some mechanism for toggling the mode (e.g. All v. Ebooks) and in the future (out of scope for this issue) maybe we can drop this in favor of the global settings (if the design is intuitive enough).
Today:
The top bar offers a way for patrons to select the language of the website, though this may be expanded to also request books published in a specific language be shown.
Problem / Opportunity
Right now patrons have facets for the search page but no option to control the results of carousels.
This make key pages like the homepage less relevant for international patrons.
Proposal
- Some persistent layer like LocalStorage may be used to store the session's book preferences
- The UI may appear next to or grouped with site language chooser on IA topbar
- The design might be informed by the filter options experience at openlibrary.org/explore
- Should communicate these are global filter settings for Books being shown
- Options should include book language, ebook v. all (for now)
- Global preferences should be overwritten by per-carousel rules (see: #10512)
Related files
Refer to this map of common Endpoints: *
Stakeholders
- @jimchamp -- macros for carousels, partials, + testing "load more"
- @cdrini -- search APIs
- @mekarpeles -- product sign-off
Instructions for Contributors
- Before creating a new branch or pushing up changes to a PR, please first run these commands to ensure your repository is up to date, as the pre-commit bot may add commits to your PRs upstream.
Hi @mekarpeles, can I try this one out?
Hi @mekarpeles and @cdrini, I'm so sorry for the long pause as I was a bit busy with my finals. Now that I'm back, here's my proposal for this feature: I will begin by building a global filtering system that works across the book browsing interface. This includes: a persistent facet-based filter panel (language, genre, age group, availability,...) and an advanced search input for power users to run more complex queries. These filters will be backed by /search.json endpoint, with query parameters built based on user selections. Additionally, this filter state will be stored in a global context provider so that it persists across routes. However, right now, I am still a bit stuck on how this persistence can be implemented. This is only a rough draft and please let me know if this aligns with your goals. Looking forward to hearing back from you!
Hi @BearSunny, thank you for your interest in working on this high impact feature -- we'd be delighted to support you.
Persistant Storage
You have the right intuition about implementing the feature and your question is a good one --
A key question is whether these settings should be related to the session or the account. The mechanism can be changed in the future so it's not a high-commitment decision. The more challenging aspect of this feature will be getting all carousels to cleanly and safely incorporate these global settings.
This feature is very similar to #10512 (which would allow any carousel to override its defaults & global settings) and if you're up for it (and it's not too much to ask), I'd love if you were willing to design a solution that may help us mutually accomplish the goals of both issues! 🙇
My suggestion for now re: global settings is that maybe we use LocalStorage for these settings (and possibly the same mechanism for #10512, though I am interested in hearing your & @cdrini's thoughts as well.
Design
The UX design decisions we can delay for a later stage/discussion. We may want to have a conversation about how the global top bar could be used to achieve this:
We have a similar interface (the library explorer) which offers one approach to global settings: https://openlibrary.org/explore
Next Step
It's up to you whether you want to start programming or sync up further; I think it may be useful to do a more detailed breakdown and describe your approach here so we can work through the solution and support you!
Hi @mekarpeles and @cdrini, after thinking for a while, here's what I think we could do to unify #10512 and #10760. For this, we can use a layered filtering system. This will apply global user preferences across all carousels, while preserving carousel-specific filters. Technically, I’ll implement this in preference_engine.py with a function called build_carousel_filters(carousel_id, system_overrides, user_prefs), which merges base configs, system overrides, and user prefs into filters compatible with Solr. The macro QueryCarousel.html will be updated to accept and apply these filters. On the frontend, a PreferenceManager in JS will handle localStorage-based global preferences with schema validation and migration logic. Homepage context and templates will be updated to inject and use these filters. This is the first time I’m working on a feature with this much scope, so while I may not have all the answers yet, I’m fully committed to learning whatever is needed to see it through. If there are any suggestions, improvements, or relevant files I should be aware of (for reference or future modifications), I’d really appreciate your guidance. Looking forward to your feedback!
Direction Update — Homepage Filter Bar
Thanks for the great work on this, @BearSunny! Here's where we'd like to take this feature for the next iteration.
Goal: Homepage Top Filter Bar (like reader.archive.org)
Rather than placing the global filter controls in a settings cog/dropdown on the IA top bar, we'd like to move toward a dedicated filter bar on the homepage — similar to the filterbar pattern used at reader.archive.org.
The bar should surface two controls that wire directly into global settings:
- Language facet selector — select a language and have it apply to all carousels on the homepage
- Readable-only toggle — a Lit component that filters carousels to show only ebooks/readable books
How it connects to your PR
Your current implementation (preferences stored in localStorage, synced to cookies, carousels reading preferences) is the right foundation. The next step is:
- Move the UI controls out of the top IA bar and into a homepage-specific filter bar component
- Both the language selector and readable-only toggle should be Lit components
- When a user changes either control, it should update
localStorage+ cookies (your existing flow) and reload/refilter all carousels on the page
Current PR scope
The current PR (#11331) focuses on getting the preferences backend (localStorage, cookies, Solr params) wired up correctly. The settings-cog UI in the top bar can stay as-is for now — the filter bar will be a follow-on.
This comment captures the direction for the next iteration so contributors can build toward it.
Hi @mekarpeles, so for the next few weeks, I will focus on modifying the frontend and fixing some leftover bugs from our new code review. I look forward to seeing this current version tested on prod and I will keep you updated with the new version soon!
PR merged in so I think this can be closed. If anyone thinks otherwise please reopen