refactor stop overloading the word page

"Page" named four things: the Components.page type identifying which repository page is shown, Repo.page rendering one, a ~page pagination index, and Ui's page_* landmarks. Repo.commits had to write ~page:page_number to escape the collision, which is the code admitting the name was overloaded. Keep page for the identity type and the landmarks, and name the other two for what they are: Repo.page becomes render_page, and the pagination index becomes page_number in Repo.commits, Components.commits_url, Ui.pagination and the handler that parses it. The "page" query parameter is unchanged, so URLs are unaffected.

Commit
d9ca5309c95e27e4f1be4e05709e84b136f67da3
Author
Claude Sonnet 4 <claude@anthropic.invalid>
Author date
Committer
Marius Peter <dev@marius-peter.com>
Committer date
Changed files
lib/handlers.ml
index 09eb91ff..f43ae818 100644..100644
@@ -217,13 +217,14 @@
217 217 let filter_type = Dream.query request "type" in
218 218 let author = Dream.query request "author" in
219 219 let committer = Dream.query request "committer" in
220 Removed: let page =
220 Added: (* The query parameter keeps its short name; the binding says what it is. *)
221 Added: let page_number =
221 222 let ( >>= ) = Option.bind in
222 223 Dream.query request "page" >>= int_of_string_opt
223 224 >>= (fun p -> if p > 0 then Some p else None)
224 225 |> Option.value ~default:1
225 226 in
226 Removed: let offset = (page - 1) * page_size in
227 Added: let offset = (page_number - 1) * page_size in
227 228 (* Fetch one beyond orphan threshold to detect whether more exist *)
228 229 let fetch_count = offset + page_size + 11 in
229 230 let predicate = commit_matches ?filter_type ?author ?committer in
@@ -243,9 +244,9 @@
243 244 in
244 245 let page_commits = List_ext.take effective_size after_offset in
245 246 let has_next = remaining > effective_size in
246 Removed: let has_prev = page > 1 in
247 Removed: Views.Repo.commits ?filter_type ?author ?committer ~page ~has_prev ~has_next
248 Removed: context page_commits
247 Added: let has_prev = page_number > 1 in
248 Added: Views.Repo.commits ?filter_type ?author ?committer ~page_number ~has_prev
249 Added: ~has_next context page_commits
249 250
250 251 let commits_branch _config repository context branch =
251 252 let* reference = Resolvers.Reference.of_id repository branch in
@@ -260,7 +261,8 @@
260 261 in
261 262 let page_commits = List_ext.take effective_size commits in
262 263 let has_next = remaining > effective_size in
263 Removed: Views.Repo.commits ~page:1 ~has_prev:false ~has_next context page_commits
264 Added: Views.Repo.commits ~page_number:1 ~has_prev:false ~has_next context
265 Added: page_commits
264 266
265 267 let commit_id repository context id =
266 268 let* commit = Resolvers.Commit.of_id repository id in
lib/views/components.ml
index 3edc6b60..c4e330d2 100644..100644
@@ -37,9 +37,9 @@
37 37 not model because it covers path-shaped routes only. Passing the filters
38 38 already in effect keeps them applied as the reader pages or switches
39 39 filters. *)
40 Removed: let commits_url ?filter_type ?author ?committer ?(page = 1) repo =
40 Added: let commits_url ?filter_type ?author ?committer ?(page_number = 1) repo =
41 41 let params =
42 Removed: (if page > 1 then [ ("page", string_of_int page) ] else [])
42 Added: (if page_number > 1 then [ ("page", string_of_int page_number) ] else [])
43 43 @ (match filter_type with Some value -> [ ("type", value) ] | None -> [])
44 44 @ (match author with Some value -> [ ("author", value) ] | None -> [])
45 45 @ match committer with Some value -> [ ("committer", value) ] | None -> []
lib/views/repo.ml
index 1fd9f0bb..248d2392 100644..100644
@@ -88,7 +88,7 @@
88 88
89 89 let page_title context = context.repo ^ " — " ^ context.description
90 90
91 Removed: let page ?heading ?(toolbar = []) context ~active content =
91 Added: let render_page ?heading ?(toolbar = []) context ~active content =
92 92 Ui.respond
93 93 @@ Layout.render context.site ~page_title:(page_title context)
94 94 {
@@ -211,7 +211,7 @@
211 211 | None -> Ui.nothing
212 212 | Some (blob : Resolvers.Blob.t) -> Components.inline_readme blob.content
213 213 in
214 Removed: page context ~active:Summary
214 Added: render_page context ~active:Summary
215 215 ~toolbar:
216 216 [
217 217 Ui.button_link
@@ -227,8 +227,8 @@
227 227 ];
228 228 ]
229 229
230 Removed: let commits ?filter_type ?author ?committer ~page:page_number ~has_prev
231 Removed: ~has_next context commits =
230 Added: let commits ?filter_type ?author ?committer ~page_number ~has_prev ~has_next
231 Added: context commits =
232 232 (* Each active filter offers a control that clears just itself, leaving the
233 233 others applied. *)
234 234 let active_filters =
@@ -276,7 +276,7 @@
276 276 ]
277 277 in
278 278 let page_url n =
279 Removed: commits_url ?filter_type ?author ?committer ~page:n context.repo
279 Added: commits_url ?filter_type ?author ?committer ~page_number:n context.repo
280 280 in
281 281 let pagination =
282 282 if not (has_prev || has_next) then []
@@ -290,7 +290,7 @@
290 290 page_number;
291 291 ]
292 292 in
293 Removed: page context ~active:Commits ~toolbar:(filters @ pagination)
293 Added: render_page context ~active:Commits ~toolbar:(filters @ pagination)
294 294 [
295 295 Ui.items_of ~id:"commit-list"
296 296 (commit_row
@@ -305,7 +305,7 @@
305 305 | None -> Ui.nothing
306 306 | Some (blob : Resolvers.Blob.t) -> Components.inline_readme blob.content
307 307 in
308 Removed: page context ~active:Files
308 Added: render_page context ~active:Files
309 309 ~toolbar:[ path_trail context.repo trail ]
310 310 [
311 311 Ui.items_of ~id:"file-tree" (tree_row context.repo) entries; readme_panel;
@@ -330,7 +330,7 @@
330 330 | Layout.Readme -> []
331 331 | _ -> [ path_trail context.repo trail ]
332 332 in
333 Removed: page context ~active ~toolbar
333 Added: render_page context ~active ~toolbar
334 334 [
335 335 raw_link;
336 336 Ui.code_listing ~id:"blob"
@@ -412,7 +412,7 @@
412 412 ("Committer date", [ timestamp commit.committer.date ]);
413 413 ]
414 414 in
415 Removed: page
415 Added: render_page
416 416 ~heading:(context.repo ^ " : " ^ Resolvers.short_hash commit.hash)
417 417 context ~active:Commits
418 418 ((Ui.heading ~level:3 [ badge; Ui.text (" " ^ title) ] :: body)
@@ -421,7 +421,7 @@
421 421 (List.map diff_file diff))
422 422
423 423 let branches context branches =
424 Removed: page context ~active:Branches
424 Added: render_page context ~active:Branches
425 425 (match branches with
426 426 | [] ->
427 427 [
@@ -432,7 +432,7 @@
432 432 [ Ui.items_of ~id:"branch-list" (branch_row context.repo) branches ])
433 433
434 434 let tags context tags =
435 Removed: page context ~active:Tags
435 Added: render_page context ~active:Tags
436 436 (match tags with
437 437 | [] ->
438 438 [
lib/views/ui.ml
index 125e9bb5..1fd3c040 100644..100644
@@ -246,7 +246,7 @@
246 246
247 247 let pagination ?(label = "Pagination") ?(previous_text = "<") ?(next_text = ">")
248 248 ?(previous_label = "Previous page") ?(next_label = "Next page")
249 Removed: ?previous_href ?next_href page =
249 Added: ?previous_href ?next_href page_number =
250 250 (* An unavailable neighbour still occupies its slot, so the page number does
251 251 not shift horizontally as the reader moves through the list. *)
252 252 let control href_opt glyph control_label =
@@ -262,7 +262,7 @@
262 262 control previous_href previous_text previous_label;
263 263 HTML.span
264 264 [ HTML.class_ "pagination-page"; Aria.current `page ]
265 Removed: [ text (string_of_int page) ];
265 Added: [ text (string_of_int page_number) ];
266 266 control next_href next_text next_label;
267 267 ]
268 268