T399974: Results Pagination

Summary: This MR enhances the search functionality in the application by implementing pagination for search results and improving user feedback when search results exceed the API limit.

Changes Made:

Pagination for Search Results:

  • Added page-based navigation to results() in app.py.
  • Users can now view results page by page.
  • The template displays Page X of Y at both the top and bottom of the results page.
  • If one wants to go to a specific page, they can type it in the browser's search bar.
  • Prevents "Page not found" errors when navigating beyond available results.

Updated Warning Message for Large Result Sets:

  • The complete flag from search.py is used to determine if all results are returned from the Wikidata API.

Updated warning message in results.html reads:

"Your search returned too many results. All results are not being shown. Please refine your search.": This informs users when only a partial set of results is displayed due to API limitations.

Safe Handling of Empty or Invalid Pages:

Ensures that users navigating to a page number beyond the available results are redirected safely to the first page, avoiding 404 errors.

Template Updates:

  • results.html now shows pagination controls and Page X of Y information at both top and bottom.

  • Works seamlessly for both author and work searches.

Impact:

  • Improves user experience by making large search results manageable.
  • Prevents confusion and broken pages caused by navigating to non-existent pages.
  • Provides clear feedback when the API cannot return all results.

Testing:

Verified search results for both authors and works.

Authors and Works

image

image

Tested page navigation for other pages other than the first one. image

Confirmed that the new warning message appears only when results exceed the API limit. image

Edited by Kimondorose

Merge request reports

Loading