zapashcanon
3 years ago
4 changed files with 57 additions and 34 deletions
@ -1,21 +1,56 @@ |
|||
let gen in_path out_path = |
|||
let out_path = Fpath.to_string out_path in |
|||
let in_path = Fpath.to_string in_path in |
|||
let common_path = |
|||
Utils.strings_common_suffix |
|||
(Filename.dirname @@ Fpath.to_string in_path) |
|||
(Filename.dirname @@ Fpath.to_string out_path) |
|||
Utils.strings_common_suffix (Filename.dirname in_path) |
|||
(Filename.dirname out_path) |
|||
in |
|||
|
|||
let bread_crumb = String.split_on_char '/' common_path in |
|||
|
|||
let buff = Buffer.create 16 in |
|||
let buff = Buffer.create 512 in |
|||
let fmt = Format.formatter_of_buffer buff in |
|||
|
|||
let bread_crumb = |
|||
List.map |
|||
(fun name -> |
|||
let path_to_root = Buffer.contents buff in |
|||
Buffer.add_string buff "../"; |
|||
(name, path_to_root) ) |
|||
(List.rev bread_crumb) |
|||
in |
|||
if bread_crumb <> [ "." ] then |
|||
let buff = Buffer.create 16 in |
|||
|
|||
let bread_crumb = |
|||
List.map |
|||
(fun name -> |
|||
let path = Buffer.contents buff in |
|||
Buffer.add_string buff "../"; |
|||
(name, path) ) |
|||
(List.rev bread_crumb) |
|||
in |
|||
|
|||
let bread_crumb = List.rev bread_crumb in |
|||
|
|||
let root_name = |
|||
List.fold_left (fun acc _el -> Filename.dirname acc) out_path bread_crumb |
|||
in |
|||
|
|||
let bread_crumb = |
|||
match bread_crumb with |
|||
| [] -> assert false |
|||
| [ (_name, path) ] -> [ (root_name, path) ] |
|||
| [ _h1; (_name, path) ] -> [ (root_name, path) ] |
|||
| (_name, path) :: t -> (root_name, path) :: t |
|||
in |
|||
|
|||
List.iter |
|||
(fun (name, path) -> |
|||
Format.fprintf fmt {| <a href="%sindex.html">%s</a> /|} |
|||
(Html.url_encode path) (Html.sanitize name) ) |
|||
bread_crumb |
|||
else begin |
|||
Format.printf "TODO"; |
|||
Format.printf "lol" |
|||
end; |
|||
|
|||
Format.fprintf fmt {| %s|} (Html.sanitize (Filename.basename out_path)); |
|||
|
|||
Format.fprintf fmt "<br />"; |
|||
|
|||
Format.pp_print_flush fmt (); |
|||
|
|||
List.rev bread_crumb |
|||
Buffer.contents buff |
|||
|
Loading…
Reference in new issue