diff options
| author | Marius Peter <marius.peter@tutanota.com> | 2025-06-29 20:51:55 +0200 | 
|---|---|---|
| committer | Marius Peter <marius.peter@tutanota.com> | 2025-06-29 20:51:55 +0200 | 
| commit | 399101966720517d67d887129dfd6a35558804aa (patch) | |
| tree | 7d33cf6a151b2860dbe2af21c25f9cb9abf4c1aa | |
| parent | d875d02eeb8bdfe8038445fff4b3212b57485c9a (diff) | |
Add routes.
| -rw-r--r-- | lib/routes.ml | 24 | 
1 files changed, 15 insertions, 9 deletions
| diff --git a/lib/routes.ml b/lib/routes.ml index f615168..5c93ce4 100644 --- a/lib/routes.ml +++ b/lib/routes.ml @@ -3,19 +3,23 @@  type t =    | Root    | Repo of string -  | Log of string -  | Files of string -  | Refs of string +  | Commits of string    | Commit of string * string +  | Files of string    | File of string * string +  | Branches of string +  | Tags of string +  | Readme of string  let%path root_path = "/"  let%path repo_path = "/%s/summary/" -let%path log_path = "/%s/log/" -let%path files_path = "/%s/files/" -let%path refs_path = "/%s/refs/" +let%path commits_path = "/%s/commits/"  let%path commit_path = "/%s/commit/%s" +let%path files_path = "/%s/files/"  let%path file_path = "/%s/file/%s" +let%path branches_path = "/%s/branches/" +let%path tags_path = "/%s/tags/" +let%path readme_path = "/%s/README"  let link_to route ?(other_attrs = []) contents =    let open Dream_html in @@ -23,10 +27,12 @@ let link_to route ?(other_attrs = []) contents =    let path = function      | Root -> path_attr href root_path      | Repo repo -> path_attr href repo_path repo -    | Log repo -> path_attr href log_path repo -    | Files repo -> path_attr href files_path repo -    | Refs repo -> path_attr href refs_path repo +    | Commits repo -> path_attr href commits_path repo      | Commit (repo, commit) -> path_attr href commit_path repo commit +    | Files repo -> path_attr href files_path repo      | File (repo, hash) -> path_attr href file_path repo hash +    | Branches repo -> path_attr href branches_path repo +    | Tags repo -> path_attr href tags_path repo +    | Readme repo -> path_attr href readme_path repo    in    a (path route :: other_attrs) [ contents ] | 
