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
Paginate the Package Search Results #1588
Comments
Hey! @sabine I'd love to work on this issue! 😄 |
@godplayer56 have you completed the setup and are you applying to the GUI project? For the setup, could you please post a screenshot? |
Hey i would like to work on this, could you please assign this to me? |
@Girish-Jangam have you completed the setup and are you applying to the GUI project? For the setup, could you please post a screenshot? |
I just want to make my first contribution, regardless of any project. I thinking this issue is very interesting and challenging & it's good for me, Talking about set-up, Yes I'm stack? It'll take some time to up and running |
You are now assigned to this issue @Girish-Jangam. Have fun! 🙂 |
Thanks! I do my best |
Hey @sabine I was working on this issue but due to some trouble at home I wasn't able to share my progress 😞 I tried using paginate function like this - let packages_search t req =
match Dream.query req "q" with
| Some search ->
let packages =
Ocamlorg_package.search ~is_author_match ~sort_by_popularity:true t
search
in
let page, current_items, number_of_pages =
paginate ~req ~n:10 packages
in
let total = List.length packages in
let results = List.map (Package_helper.frontend_package t) packages in
let search = Dream.from_percent_encoded search in
Dream.html (Ocamlorg_frontend.packages_search ~total ~search ~page:page ~current_items:current_items ~number_of_pages:number_of_pages results)
| None -> Dream.redirect req Url.packages but vs code is showing error that Ocamlorg_frontend.packages_search takes too many arguments I also edited the let render ~total ~search ~page ~current_items ~number_of_pages (packages : Package.package list) and also where should I add the pagination component in the eml file? |
Hey, i'm working on this, I'll commit asap! |
Sure @Girish-Jangam , I just wanted to share my progress with @sabine 👍 @sabine should I work on some other issue? I have already completed the setup as mentioned for outreachy applicants(I can share the progress with you if necessary). I am thinking of working on an outreachy medium issue since all the beginner issues have been assigned 😞 |
let packages_search t req =
| None -> Dream.redirect req Url.packages It uses paginate function let paginate ~req ~n items = <%s! Pagination.render ~total_page_count:number_of_pages ~page_number:page ~base_url:base_url %> Error is shown in video, 20231015114057.mp4 |
This bug looks like it might be coming from the way you define |
@SaySayo, Hello! It's giving me following URL, I had tried this once http://localhost:8080/packages/search?q=base&p=**?p=2** Dream.query from paginate function appends ?p=number every time when i navigate through pages done on pagination. 20231015153150.mp4 |
@Girish-Jangam it will be easier to comment on the current state (and for us to try and run it) if you open a Draft PR @godplayer56 maybe you can solve #1640 and then be assigned a medium issue? |
Sure @sabine I'll work on it👍 |
Note: this has been selected as an Outreachy issue. To be assigned, you must have completed the instructions in #1553.
Please only request to be assigned this issue if you are applying for the GUI project
Task
Currently, all the entries of the package search results page are displayed on a single HTML page. E.g. at https://ocaml.org/packages/search?q=irmin.
Since there are a lot of entries, it makes sense to add pagination:
As an example of how to do pagination (and for possible code sharing), look at how it is done for the Blog:
handler.ml
, the list of entries is paginated according to a query parameter "p" from the URL:ocaml.org/src/ocamlorg_web/lib/handler.ml
Lines 191 to 218 in 6a36190
ocaml.org/src/ocamlorg_frontend/pages/blog.eml
Line 67 in 6a36190
--
What you need to do:
packages_search
inhandler.ml
to paginate the list of changelog entries into pages that have at most 50 entriespackages_search.eml
to render the pagination componentThe text was updated successfully, but these errors were encountered: