ocaml
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

factor out html page template

+40 -36
+40 -36
lib/frontend/Html_client.ml
··· 370 370 ]; 371 371 ] 372 372 373 - let render_page ~forest (tree : _ T.article) : P.node = 374 - let reserved = [{prefix = ""; xmlns = "http://www.w3.org/1999/xhtml"}] in 375 - let env = 376 - { 377 - forest; 378 - section_depth = 0; 379 - scope = tree.frontmatter.uri; 380 - loops = Loop_detection.empty; 381 - xmlns = Xmlns.init ~reserved; 382 - } 383 - in 384 - let ttl = 385 - match tree.frontmatter.title with 386 - | None -> H.null [] 387 - | Some _ -> 388 - let title = 389 - State.get_expanded_title ?scope:env.scope tree.frontmatter env.forest 390 - in 391 - H.title [] "%s" @@ Plain_text_client.string_of_content ~forest:env.forest title 392 - in 373 + let page_template ~is_root ~title:ttl c = 393 374 let open H in 394 375 html [] 395 376 [ ··· 401 382 link [rel "stylesheet"; href "/style.css"]; 402 383 link [rel "stylesheet"; href "/katex.min.css"]; 403 384 script [type_ "module"; src "/forester.js"] ""; 404 - ttl; 385 + H.title [] "%s" ttl; 405 386 ]; 406 387 body [] 407 388 [ 408 389 P.std_tag "ninja-keys" 409 390 [placeholder "Start typing a note title or ID"] 410 391 []; 411 - (if is_root env.forest.config tree.frontmatter.uri then null [] 392 + (if is_root then null [] 412 393 else 413 394 header 414 395 [class_ "header"] ··· 421 402 [a [href "index.html"; title_ "home"] [P.txt "« Home"]]; 422 403 ]; 423 404 ]); 424 - div 425 - [id "grid-wrapper"] 426 - [ 427 - render_article ~env tree; 428 - (if should_render_toc article then 429 - nav 430 - [id "toc"] 431 - [ 432 - div 433 - [class_ "block"] 434 - [h1 [] [P.txt "Table of Contents"]; render_toc article]; 435 - ] 436 - else null []); 437 - ]; 405 + div [id "grid-wrapper"] c; 438 406 ]; 439 407 ] 408 + 409 + let render_page ~forest (tree : _ T.article) : P.node = 410 + let reserved = [{prefix = ""; xmlns = "http://www.w3.org/1999/xhtml"}] in 411 + let env = 412 + { 413 + forest; 414 + section_depth = 0; 415 + scope = tree.frontmatter.uri; 416 + loops = Loop_detection.empty; 417 + xmlns = Xmlns.init ~reserved; 418 + } 419 + in 420 + let ttl = 421 + match tree.frontmatter.title with 422 + | None -> (* FIXME: *) "" 423 + | Some _ -> 424 + let title = 425 + State.get_expanded_title ?scope:env.scope tree.frontmatter env.forest 426 + in 427 + Plain_text_client.string_of_content ~forest:env.forest title 428 + in 429 + let open H in 430 + let is_root = is_root env.forest.config tree.frontmatter.uri in 431 + page_template ~is_root ~title:ttl 432 + [ 433 + render_article ~env tree; 434 + (if should_render_toc article then 435 + nav 436 + [id "toc"] 437 + [ 438 + div 439 + [class_ "block"] 440 + [h1 [] [P.txt "Table of Contents"]; render_toc article]; 441 + ] 442 + else null []); 443 + ]