diff options
| author | Marius Peter <marius.peter@tutanota.com> | 2025-05-28 21:19:29 +0200 | 
|---|---|---|
| committer | Marius Peter <marius.peter@tutanota.com> | 2025-05-28 21:19:29 +0200 | 
| commit | 378d9f24bd19855b7aa59936d7104ab1203c42f3 (patch) | |
| tree | 9025b81b710079f2be4dfaea84ed1d9465e14d60 /lib | |
| parent | 0a46c9b495557f4634a543c43cdc8fb920c76303 (diff) | |
Improve page title.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/views.ml | 80 | 
1 files changed, 42 insertions, 38 deletions
| diff --git a/lib/views.ml b/lib/views.ml index b204674..986aa35 100644 --- a/lib/views.ml +++ b/lib/views.ml @@ -4,8 +4,6 @@ open Dream_html  open Git_presenters  open Config -type head_data = { page_title : string } -  type body_data = {    title : string;    subtitle : string; @@ -58,14 +56,12 @@ module Page = struct      let footer_text = Printf.sprintf "Copyright %s %s" year config.user in      footer [] [ txt "%s" footer_text ] -  let default_head_data = { page_title = "Ogit" } - -  let render ?(head_data = default_head_data) body_data = +  let render ?(page_title = "Ogit") body_data =      html []        [          head []            [ -            title [] "%s" head_data.page_title; +            title [] "%s" page_title;              link [ rel "stylesheet"; href "/static/styles.css" ];              link                [ rel "icon"; type_ "image/x-icon"; href "/static/git_icon.svg" ]; @@ -102,6 +98,8 @@ let root () =    Page.render body_data  module Repo = struct +  let page_title repo = Printf.sprintf "%s — %s" repo (repo_description repo) +    let summary repo branches commits authors =      let li_of_branch branch =        HTML.(li [] [ a [ href "%s" branch.name ] [ txt "%s" branch.name ] ]) @@ -132,10 +130,10 @@ module Repo = struct            ul [] (List.map li_of_author authors);          ]      in -    Page.render +    Page.render ~page_title:(page_title repo)        {          title = repo; -        subtitle = Git_presenters.repo_description repo; +        subtitle = repo_description repo;          topnav = Components.topnav repo;          content;        } @@ -144,15 +142,16 @@ module Repo = struct      let li_of_branch branch =        HTML.(li [] [ a [ href "%s" branch.name ] [ txt "%s" branch.name ] ])      in -    Page.render -      HTML. -        { -          title = repo; -          subtitle = Git_presenters.repo_description repo; -          topnav = Components.topnav repo; -          content = -            [ h3 [] [ txt "Branches" ]; ul [] (List.map li_of_branch branches) ]; -        } +    let content = +      HTML.[ h3 [] [ txt "Branches" ]; ul [] (List.map li_of_branch branches) ] +    in +    Page.render ~page_title:(page_title repo) +      { +        title = repo; +        subtitle = repo_description repo; +        topnav = Components.topnav repo; +        content; +      }    let log repo commits =      let li_of_commit commit = @@ -167,34 +166,39 @@ module Repo = struct                ])        | None -> HTML.(li [] [ a [ href "" ] [ txt "caca!!" ] ])      in -    Page.render +    let content =        HTML. -        { -          title = repo; -          subtitle = Git_presenters.repo_description repo; -          topnav = Components.topnav repo; -          content = -            [ -              h3 [] [ txt "All commits" ]; ul [] (List.map li_of_commit commits); -            ]; -        } +        [ h3 [] [ txt "All commits" ]; ul [] (List.map li_of_commit commits) ] +    in +    Page.render ~page_title:(page_title repo) +      { +        title = repo; +        subtitle = repo_description repo; +        topnav = Components.topnav repo; +        content; +      }    let tree repo = -    Page.render -      HTML. -        { -          title = repo; -          subtitle = Git_presenters.repo_description repo; -          topnav = Components.topnav repo; -          content = [ null [] ]; -        } +    let content = HTML.[ null [] ] in +    Page.render ~page_title:(page_title repo) +      { +        title = repo; +        subtitle = repo_description repo; +        topnav = Components.topnav repo; +        content; +      }    let commit repo commit =      let message = match commit.message with Some msg -> msg | None -> "" in -    let content = HTML.[ h3 [] [ txt "%s" message ] ] in      let title = Printf.sprintf "%s : %s" repo commit.short_hash in -    Page.render -      { title; subtitle = ""; topnav = Components.topnav repo; content } +    let content = HTML.[ h3 [] [ txt "%s" message ] ] in +    Page.render ~page_title:(page_title repo) +      { +        title; +        subtitle = repo_description repo; +        topnav = Components.topnav repo; +        content; +      }  end  let error_page message = | 
