jb/src/app.ml
2025-01-03 20:49:15 +01:00

47 lines
1.1 KiB
OCaml

module App_id = struct
let qualifier = "org"
let organization = "jb"
let application = "jb"
end
include Drame.Server.Make (App_id)
let path_to_images =
match Scfg.Query.get_dir "path_to_images" config with
| None -> Fmt.failwith "missing path_to_images in configuration"
| Some dir -> (
match Fpath.of_string @@ Scfg.Query.get_param_exn 0 dir with
| Error (`Msg s) -> Fmt.failwith "%s" s
| Ok v -> v )
(* check existence of image files at startup *)
let () =
let f_s s =
let file = Fpath.(path_to_images / s) in
match Bos.OS.File.exists file with
| Error (`Msg s) -> Fmt.failwith "%s" s
| Ok false -> Fmt.failwith "Image file: %s not found." s
| Ok true -> ()
in
let f img = f_s img.Lang.name in
(* projects *)
List.iter
(fun Projects.{ home_logo; main_img; more_img; _ } ->
f main_img;
Option.iter f home_logo;
List.iter f more_img )
Projects.projects;
(* services *)
List.iter
(fun Services_data.{ img_left; img_right; _ } ->
f img_left;
f img_right )
Services_data.services;
(* misc. *)
f_s "home.gif";
f_s "me.png";
f_s "favicon.png";
()