- "failure while reloading all stylesheets: exception %s"
- (Printexc.to_string e)));
- Mutex.unlock styles_mutex
- | keys ->
- List.iter
- (fun key -> (* reload a single stylesheet *)
- Mutex.lock styles_mutex;
- log#log (sprintf "reloading stylesheet %s" key);
- (try
- styles#reload key
- with e ->
- log#log
- (sprintf
- "failure while reloading stylesheet %s: exception %s"
- key (Printexc.to_string e)));
- Mutex.unlock styles_mutex)
- keys);
- Http_daemon.respond ~body:log#asHtml outchan)
- | "/apply" ->
- (let logger = new Uwobo_logger.processingLogger () in
- let xmluri = req#param "xmluri" in
- let keys = Pcre.split ~pat:"," (req#param "keys") in
- (* notation: "local" parameters are those defined on a per-stylesheet
- pasis (i.e. param.key.param=value), "global" parameters are those
- defined for all stylesheets (i.e. param.param=value) *)
- let is_global_param x = Pcre.pmatch ~pat:"^param(\\.[^.]+){1}$" x in
- let is_local_param x = Pcre.pmatch ~pat:"^param(\\.[^.]+){2}$" x in
- let is_property x = Pcre.pmatch ~pat:"^prop\\.[^.]+$" x in
- let (params, props) =
- List.fold_left
- (fun (old_params, old_properties) (name, value) ->
- match name with
- | name when is_global_param name ->
- let name = Pcre.replace ~pat:"^param\\." name in
- ((fun x -> (old_params x) @ [name, value]),
- old_properties)
- | name when is_local_param name ->
- let pieces = Pcre.extract ~pat:"^param\\.([^.]+)\\.(.*)" name in
- let (key, name) = (pieces.(1), pieces.(2)) in
- ((function
- | x when x = key -> [name, value] @ (old_params x)
- | x -> old_params x),
- old_properties)
- | name when is_property name ->
- let name = Pcre.replace ~pat:"^prop\\." name in
- (old_params, ((name, value) :: old_properties))
- | _ -> (old_params, old_properties))
- ((fun _ -> []), []) (* no parameters, no properties *)
- req#params
- in
- Uwobo_engine.apply
- ~logger ~styles ~keys ~input:xmluri ~params ~props outchan)