This commit is contained in:
parent
3f17260d53
commit
ef2aa1ddd7
1 changed files with 35 additions and 26 deletions
|
|
@ -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,26 +50,34 @@ 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
|
||||||
if List.is_empty lang_l then Fmt.failwith "no language supported";
|
List.iter
|
||||||
if List.is_empty ext_l then Fmt.failwith "no mimetype supported";
|
(fun path ->
|
||||||
if not @@ List.mem Assets_config.default_lang lang_l then
|
let etag' = Fpath.to_string (Fpath.rem_ext (Fpath.base path)) in
|
||||||
Fmt.failwith "default language `%s` files not found"
|
if not @@ String.equal etag etag' then
|
||||||
Assets_config.default_lang;
|
Fmt.failwith
|
||||||
if not @@ List.mem ".txt" ext_l then
|
"filename of file `%s` does not match configuration ETAG value `%s`"
|
||||||
Fmt.failwith "plain text file not found";
|
(Fpath.to_string Fpath.(prefix // path))
|
||||||
if not @@ List.mem ".md" ext_l then Fmt.failwith "markdown file not found";
|
etag)
|
||||||
List.iter
|
path_l;
|
||||||
(fun dir ->
|
if List.is_empty lang_l then Fmt.failwith "no language supported";
|
||||||
if String.length dir <> 2 then
|
if List.is_empty ext_l then Fmt.failwith "no mimetype supported";
|
||||||
Fmt.failwith "language directory with invalid name: `%s`" dir)
|
if not @@ List.mem Assets_config.default_lang lang_l then
|
||||||
lang_l;
|
Fmt.failwith "default language `%s` files not found"
|
||||||
if List.length path_l <> List.length ext_l * List.length lang_l then
|
Assets_config.default_lang;
|
||||||
Fmt.failwith
|
if not @@ List.mem ".txt" ext_l then
|
||||||
"invalid folder structure, all supported language must provide the \
|
Fmt.failwith "plain text file not found";
|
||||||
same set of file mimetype"
|
if not @@ List.mem ".md" ext_l then Fmt.failwith "markdown file not found";
|
||||||
in
|
List.iter
|
||||||
(lang_l, ext_l)
|
(fun dir ->
|
||||||
|
if String.length dir <> 2 then
|
||||||
|
Fmt.failwith "language directory with invalid name: `%s`" dir)
|
||||||
|
lang_l;
|
||||||
|
if List.length path_l <> List.length ext_l * List.length lang_l then
|
||||||
|
Fmt.failwith
|
||||||
|
"invalid folder structure, all supported language must provide the \
|
||||||
|
same set of file mimetype"
|
||||||
|
else (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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue