~ assets
This commit is contained in:
parent
5342a1281f
commit
1cb610988f
4 changed files with 39 additions and 33 deletions
|
|
@ -9,7 +9,22 @@
|
|||
https://docs.taler.net/manpages/taler-exchange.conf.5.html
|
||||
https://docs.taler.net/design-documents/003-tos-rendering.html *)
|
||||
|
||||
type kind = Terms | Privacy
|
||||
(* todo: maybe move this type to config.ml *)
|
||||
type t = Terms | Privacy
|
||||
|
||||
let etag = function
|
||||
| Terms -> Config.terms_etag
|
||||
| Privacy -> Config.privacy_etag
|
||||
|
||||
let legal_version = function
|
||||
| Terms -> Config.terms_legal_version
|
||||
| Privacy -> Config.privacy_legal_version
|
||||
|
||||
let base_dir = function
|
||||
| Terms -> Config.terms_dir
|
||||
| Privacy -> Config.privacy_dir
|
||||
|
||||
let path ~lang ~ext t = Fpath.((base_dir t / lang / etag t) + ext)
|
||||
|
||||
(* TODO
|
||||
better use of Fmt to have error prefix or smthing
|
||||
|
|
@ -22,13 +37,9 @@ let supported_lang_arr, supported_ext_arr =
|
|||
| Error (`Msg e) -> Fmt.failwith "%s" e
|
||||
| Ok x -> x
|
||||
in
|
||||
let aux kind =
|
||||
let base_dir =
|
||||
match kind with
|
||||
| Terms -> Config.terms_dir
|
||||
| Privacy -> Config.privacy_dir
|
||||
in
|
||||
let path_l = path_l |> List.filter_map (Fpath.rem_prefix base_dir) in
|
||||
let aux t =
|
||||
let prefix = base_dir t in
|
||||
let path_l = path_l |> List.filter_map (Fpath.rem_prefix prefix) in
|
||||
let ext_l =
|
||||
path_l |> List.map Fpath.get_ext |> List.sort_uniq String.compare
|
||||
in
|
||||
|
|
@ -87,14 +98,8 @@ let supported_lang_arr, supported_ext_arr =
|
|||
let is_supported_lang lang = Array.mem lang supported_lang_arr
|
||||
let is_supported_ext ext = Array.mem ext supported_ext_arr
|
||||
|
||||
let get_content ~lang ~ext kind =
|
||||
let path =
|
||||
let open Config in
|
||||
match kind with
|
||||
| Terms -> Fpath.((terms_dir / lang / terms_etag) + ext)
|
||||
| Privacy -> Fpath.((privacy_dir / lang / privacy_etag) + ext)
|
||||
in
|
||||
let path_str = Fpath.to_string path in
|
||||
match Assets_crunch.read path_str with
|
||||
| None -> Fmt.error "static file not found: `%s`" path_str
|
||||
let get_content ~lang ~ext t =
|
||||
let path = Fpath.to_string (path ~lang ~ext t) in
|
||||
match Assets_crunch.read path with
|
||||
| None -> Fmt.error "static file not found: `%s`" path
|
||||
| Some data -> Ok data
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue