package forester
A tool for tending mathematical forests
Install
Dune Dependency
Authors
Maintainers
Sources
5.0.tar.gz
md5=24f4aed96a8b8af33aba13fba66f1b37
sha512=d36b896aca11858bb4a00fc704c16cc27a1f197bdb3e479d6132fd70f70d67d7158096285cb0b6fb00db14417f0f822cc27fe65d82f0971e42378fd8271ce573
doc/src/forester.compiler/Asset_router.ml.html
Source file Asset_router.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
(* * SPDX-FileCopyrightText: 2024 The Forester Project Contributors * * SPDX-License-Identifier: GPL-3.0-or-later *) open Forester_core let router : (string, URI.t) Hashtbl.t = Hashtbl.create 100 let normalize ?loc source_path = try Unix.realpath source_path with | Unix.Unix_error (e, _, m) -> Reporter.fatal ?loc (Asset_not_found (Format.asprintf "%s: %s" (Unix.error_message e) m)) let install ~(config : Config.t) ~source_path ~content = let normalized = normalize source_path in match Hashtbl.find_opt router normalized with | Some uri -> uri | None -> let hash = Result.get_ok @@ Multihash_digestif.of_cstruct `Sha3_256 (Cstruct.of_string content) in let cid = Cid.v ~version: `Cidv1 ~codec: `Raw ~base: `Base32 ~hash in let cid_str = Cid.to_string cid in let ext = Filename.extension normalized in let uri = URI_scheme.named_uri ~base: config.url (cid_str ^ ext) in Hashtbl.add router normalized uri; uri let uri_of_asset ?loc ~source_path () = let normalized = normalize ?loc source_path in match Hashtbl.find_opt router normalized with | Some uri -> uri | None -> Reporter.fatal ?loc (Asset_has_no_content_address normalized)
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>