diff options
| author | Marius Peter <marius.peter@tutanota.com> | 2025-07-20 16:32:52 +0200 | 
|---|---|---|
| committer | Marius Peter <marius.peter@tutanota.com> | 2025-07-20 16:32:52 +0200 | 
| commit | c366e7377b7de5f333741d1c64c49cb848cad05c (patch) | |
| tree | 3f424d442a5578fc814cdd60332cbd6cc27b7ab1 /lib | |
| parent | c0aa85cf9e4d620c582011c2b36397e6af5a201b (diff) | |
Factor out page header and body.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/views.ml | 47 | 
1 files changed, 21 insertions, 26 deletions
| diff --git a/lib/views.ml b/lib/views.ml index d2f4501..9345bf0 100644 --- a/lib/views.ml +++ b/lib/views.ml @@ -49,28 +49,29 @@ module Page = struct      let footer_text = Printf.sprintf "Copyright %s %s" year config.user in      HTML.footer [] [ txt "%s" footer_text ] -  let render ?(page_title = "Ogit") body_data = +  let head page_title = +    let open HTML in +    head [] +      [ +        title [] "%s" page_title; +        link [ rel "stylesheet"; href "/static/styles.css" ]; +        link [ rel "icon"; type_ "image/x-icon"; href "/static/git_icon.svg" ]; +      ] + +  let body bd =      let open HTML in -    let bd = body_data in -    html [] +    body []        [ -        head [] -          [ -            title [] "%s" page_title; -            link [ rel "stylesheet"; href "/static/styles.css" ]; -            link -              [ rel "icon"; type_ "image/x-icon"; href "/static/git_icon.svg" ]; -          ]; -        body [] -          [ -            page_header bd.title bd.subtitle; -            (match bd.repo with -            | None -> HTML.null [] -            | Some repo -> Components.topnav ~active:bd.active repo); -            div [ id "main" ] bd.content; -            page_footer (); -          ]; +        page_header bd.title bd.subtitle; +        (match bd.repo with +        | None -> HTML.null [] +        | Some repo -> Components.topnav ~active:bd.active repo); +        div [ id "main" ] bd.content; +        page_footer ();        ] + +  let render ?(page_title = "Ogit") body_data = +    HTML.html [] [ head page_title; body body_data ]  end  let root () = @@ -240,13 +241,7 @@ let error_page message =    respond    @@ html []         [ -         head [] -           [ -             title [] "Fatal error"; -             link [ rel "stylesheet"; href "/static/styles.css" ]; -             link -               [ rel "icon"; type_ "image/x-icon"; href "/static/git_icon.svg" ]; -           ]; +         Page.head "Fatal Error";           body []             [               h1 [] [ txt "Fatal Error" ]; | 
