diff options
-rw-r--r-- | assets/dune | 10 | ||||
-rw-r--r-- | bin/main.ml | 7 | ||||
-rw-r--r-- | dune-project | 1 | ||||
-rw-r--r-- | wormhole.opam | 10 |
4 files changed, 19 insertions, 9 deletions
diff --git a/assets/dune b/assets/dune new file mode 100644 index 0000000..0a984cb --- /dev/null +++ b/assets/dune @@ -0,0 +1,10 @@ +(rule + (targets static.ml) + (deps (source_tree ./)) + (action + (setenv OCAMLRUNPARAM "b" + (run %{bin:ocaml-crunch} --mode=plain -o static.ml -e css -e svg -e png -e jpg -e ttf ./)) + )) + +(library (name assets) + (modules assets)) diff --git a/bin/main.ml b/bin/main.ml index 49469a3..45bd973 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -67,6 +67,11 @@ let actor_allowlist = "https://graphics.social/users/theohonohan"; ] +let loader _root path _request = + match Assets.read path with + | None -> Dream.empty `Not_Found + | Some asset -> Dream.respond asset + let () = let port = Sys.getenv_opt "PORT" |> Option.map int_of_string @@ -84,7 +89,7 @@ let () = Dream.run ~port ~interface @@ Dream.logger @@ Dream.router [ - Dream.get "/static/**" (Dream.static "./assets"); + Dream.get "/static/**" (Dream.static ~loader ""); Dream.get "/feed.xml" (fun _ -> let posts = Post.get_all () in let maybe_latest_post = Post.latest_post () in diff --git a/dune-project b/dune-project index 35a8faf..deac556 100644 --- a/dune-project +++ b/dune-project @@ -1,6 +1,7 @@ (lang dune 3.11) (name wormhole) +(version 4771982-dirty) (generate_opam_files true) diff --git a/wormhole.opam b/wormhole.opam index 46045e1..886447e 100644 --- a/wormhole.opam +++ b/wormhole.opam @@ -1,5 +1,7 @@ +version: "4771982-dirty" # This file is generated by dune, edit dune-project instead opam-version: "2.0" +version: "4771982-dirty" synopsis: "A short synopsis" description: "A longer description" maintainer: ["Maintainer Name"] @@ -11,17 +13,9 @@ doc: "https://url/to/documentation" bug-reports: "https://github.com/username/reponame/issues" depends: [ "ocaml" - "dream" "dune" {>= "3.11"} "ppx_yojson_conv" - "cohttp" - "cohttp-lwt-unix" "odoc" {with-doc} - "containers" - "calendar" - "ptime" - "mirage-crypto-rng" {>= "0.11.0"} - "mirage-crypto-rng-lwt" {>= "0.11.0"} ] build: [ ["dune" "subst"] {dev} |