Convert FullTextSuggestions partial to Jinja
This is a good first issue. Comment that you'd like to work on it — don't wait to be assigned — then open a PR referencing this issue. Anyone may open a PR, but please don't open one if another PR is already open for this issue.
Part of #13566. See the epic for the full pattern, playbook, and test steps.
Convert 3 files: openlibrary/macros/FulltextSearchSuggestion.html (34 lines), openlibrary/macros/FulltextSearchSuggestionItem.html (90 lines), openlibrary/macros/FulltextSuggestionSnippet.html (26 lines). Bridge (do not convert) LoadingIndicator (shared). Use the Jinja icon global where the old code calls macros.icon. Render from FullTextSuggestionsPartial. Keep the has_error return flag exact.
Test GET /partials/FulltextSearchSuggestion.json while logged in. Keep the parsed DOM identical. No new tests.
Context
- Target files confirmed present:
openlibrary/macros/FulltextSearchSuggestion.html(34 lines),FulltextSearchSuggestionItem.html(90 lines),FulltextSuggestionSnippet.html(26 lines) — line counts match the epic breakdown exactly. - Handler lives in
openlibrary/plugins/openlibrary/partials.py#L423-L439(FullTextSuggestionsPartialResult,FullTextSuggestionsPartial.generate_async), routed fromopenlibrary/fastapi/partials.py#L108-L123(GET /partials/FulltextSearchSuggestion.json).has_erroris set from"error" in data— the flag to preserve exactly. - Directly reusable pattern: the just-merged #13563 (
MyBooksDropperListsPartial) shows the shape to follow — a.jinjatemplate rendered viaget_jinja_env().get_template(...).render(...), withjson_encodepassed in as a render kwarg rather than added as a global. Seedropper_lists.html.jinjaand the handler atpartials.py#L74-L94. LoadingIndicatorbridge target confirmed atopenlibrary/macros/LoadingIndicator.html; theiconJinja global is already registered (env.globals["icon"]) inopenlibrary/core/jinja.py#L113.FulltextSearchSuggestionItem.htmlbranches on 4 shapes ofdoc(infogami_work,infogami_edition,solr_work,solr_edition) via a$codeblock mixinghasattr/.get()— this is the "2 data shapes need care in Jinja" case the epic playbook calls out. It also callsmacros.BookByline, which is not part of this task's file list.- No open or closed PR yet references this file set, and no duplicate open issue exists for this task.
Issue Assessment
Action items
- [x] Which macro handles the shared author-byline rendering, and is it in scope? (Answer:
openlibrary/macros/BookByline.html, called fromFulltextSearchSuggestionItem.html— it is not listed in this task's file set, so it should be bridged withrender_templetor_template, the same treatment asLoadingIndicator.) - [x] Does a Jinja
iconglobal already exist for themacros.iconcalls? (Answer: yes, registered inopenlibrary/core/jinja.py#L113, same helper used by prior conversions.)
Stakeholders
🔔 Stakeholders
@cdrini — tagged per Theme: Search/frontend-performance ownership; this partial renders Search Inside suggestions on search result pages.
Full triage checklist
- [x] Triage — correct labels applied or removed
- [x] Problem / opportunity — problem is clear, audience identified, actionable
- [x] Scope — issue is well-scoped; does not try to do too many things
- [x] Justification — reasoning and impact stated; sufficient for leads to prioritize
- [x] Success & testing criteria — defines what "done" looks like, verifiable by a contributor
- [x] Proposal & breakdown — concrete plan present; checklist actionable for a contributor
- [ ] If bug: environment & repro steps — n/a, not a bug report
- [x] Risks, concerns, open questions — identified and surfaced
- [x] Richy context — relevant code, commits, PRs reviewed; no duplicate found
- [x] References — screenshots, designs, docs, and links present where needed
[!NOTE] This comment was automatically generated by Richy, Open Library's issue enrichment assistant, on behalf of @mekarpeles. This is NOT a sign-off. This issue needs lead review before work begins.
Hi! I'd like to work on this issue. I can take the FullTextSuggestions partial migration to Jinja, preserve the existing DOM output, and verify the endpoint behavior as described. I'll open a PR referencing this issue
If someone would like to work on this please be sure to take into account the feedback given here. Also please try to follow the practices closely that we have in other partials now.
https://github.com/internetarchive/openlibrary/pull/13575#pullrequestreview-5127812060
Hi, I am going through the requirements and would like to work on this issue. Can you please assign this to me?
Please read the issue. Especially the first line
Hi @RayBB , I’d like to work on this issue.
My proposed approach is:
Review the conversion pattern and testing playbook documented in #13566. Convert FulltextSearchSuggestion.html, FulltextSearchSuggestionItem.html, and FulltextSuggestionSnippet.html from the existing template syntax to Jinja. Keep LoadingIndicator as an unconverted bridge and use the Jinja icon global where the existing templates call macros.icon. Preserve the exact has_error return behavior and continue rendering through FullTextSuggestionsPartial. Compare the parsed DOM before and after the migration using GET /partials/FulltextSearchSuggestion.json while logged in. Run the relevant formatting, linting, and existing test suites documented by the project.
I’ll keep the PR limited to the three files specified in this issue and avoid unrelated formatting or refactoring.
I noticed that #13575 is already open for this issue, so I won’t open a competing PR. If the current contributor is no longer working on it and you would like someone to take it over, I’d be happy to help address the requested changes. Otherwise, I’m also happy to pick up another unclaimed subtask from #13566 .
Give it a shot!