This commit is contained in:
swrup 2026-02-12 09:03:13 +01:00
parent 3f17260d53
commit 04528d98a5

View file

@ -1,4 +1,6 @@
(* doc: https://docs.taler.net/design-documents/003-tos-rendering.html (* https://docs.taler.net/design-documents/003-tos-rendering.html
https://docs.taler.net/design-documents/003-tos-rendering.html
must support `text/plain` and `text/markdown` *) must support `text/plain` and `text/markdown` *)
type t = type t =
@ -13,16 +15,15 @@ module Assets_config = struct
let default_encoding : [< `Identity | `DEFLATE | `Gzip ] = `Identity let default_encoding : [< `Identity | `DEFLATE | `Gzip ] = `Identity
let base_dir = function Terms -> "terms" | Privacy -> "privacy" let base_dir = function Terms -> "terms" | Privacy -> "privacy"
(* TODO (* TODO this should be in the config like terms_etag *)
how to update ToS version?
where to get it? *)
let terms_legal_version = "0" let terms_legal_version = "0"
let privacy_legal_version = "0" let privacy_legal_version = "0"
end end
(* TODO etag = filename *)
let etag k = let etag k =
let etag = match k with Terms -> "0" | Privacy -> "0" in let etag =
match k with Terms -> Config.terms_etag | Privacy -> Config.privacy_etag
in
etag |> Headers_lib.Etag.of_crockford32 |> Result.get_ok etag |> Headers_lib.Etag.of_crockford32 |> Result.get_ok
let legal_version = function let legal_version = function
@ -49,7 +50,16 @@ let supported_lang_arr, supported_ext_arr =
path_l path_l
in in
let lang_l = List.sort_uniq String.compare lang_l in let lang_l = List.sort_uniq String.compare lang_l in
let () = let etag = Headers_lib.Etag.to_raw_string (etag t) in
List.iter
(fun path ->
let etag' = Fpath.to_string (Fpath.rem_ext (Fpath.base path)) in
if not @@ String.equal etag etag' then
Fmt.failwith
"filename of file `%s` does not match configuration ETAG value `%s`"
(Fpath.to_string Fpath.(prefix // path))
etag)
path_l;
if List.is_empty lang_l then Fmt.failwith "no language supported"; if List.is_empty lang_l then Fmt.failwith "no language supported";
if List.is_empty ext_l then Fmt.failwith "no mimetype supported"; if List.is_empty ext_l then Fmt.failwith "no mimetype supported";
if not @@ List.mem Assets_config.default_lang lang_l then if not @@ List.mem Assets_config.default_lang lang_l then
@ -67,8 +77,7 @@ let supported_lang_arr, supported_ext_arr =
Fmt.failwith Fmt.failwith
"invalid folder structure, all supported language must provide the \ "invalid folder structure, all supported language must provide the \
same set of file mimetype" same set of file mimetype"
in else (lang_l, ext_l)
(lang_l, ext_l)
in in
let lang_l, ext_l = aux Terms in let lang_l, ext_l = aux Terms in
let lang_l', ext_l' = aux Privacy in let lang_l', ext_l' = aux Privacy in