Custom configuration options

It is not convenient to have to edit the code to change some configurations, like the location where are saved the favorite images (see: Saving favorite pictures). Fortunately Ocsigen provides a mechanism to extend its configuration file.

let static_dir =
  match Eliom_config.get_config () with
    | [Simplexmlparser.Element
     ("staticdir", [], [Simplexmlparser.PCData dir])] ->
        dir
    | [] ->
      raise (Ocsigen_extensions.Error_in_config_file
               ("staticdir must be configured"))
    | _ ->
      raise (Ocsigen_extensions.Error_in_config_file
               ("Unexpected content inside config"))

This will add a mandatory child to the eliom tag in the configuration file:

<eliom module="path/to/your/module.cma">
  <staticdir>/tmp/static</staticdir>
</eliom>