From: Wilmer Ricciotti Date: Wed, 22 Jun 2011 09:06:32 +0000 (+0000) Subject: Added viewlib to matitaweb. X-Git-Tag: make_still_working~2419 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=16c004ddeff5cb72e1d58e16e85f039e3e2f8573;p=helm.git Added viewlib to matitaweb. --- diff --git a/matitaB/matita/matitaAuthentication.ml b/matitaB/matita/matitaAuthentication.ml index 8b23cc948..ad6bec47d 100644 --- a/matitaB/matita/matitaAuthentication.ml +++ b/matitaB/matita/matitaAuthentication.ml @@ -39,6 +39,8 @@ exception UsernameCollision of string let lookup_user uid = List.assoc uid !user_tbl +let user_of_session sid = let res,_,_ = List.assoc sid !session_tbl in res + let create_session uid = let status = new MatitaEngine.status (Some uid) "cic:/matita" in let history = [status] in diff --git a/matitaB/matita/matitaAuthentication.mli b/matitaB/matita/matitaAuthentication.mli index 3bd1bc0aa..e47df783c 100644 --- a/matitaB/matita/matitaAuthentication.mli +++ b/matitaB/matita/matitaAuthentication.mli @@ -29,6 +29,8 @@ exception UsernameCollision of string val lookup_user : string -> (string * session_id option) +val user_of_session : session_id -> string + val create_session : string -> session_id val get_session_owner : session_id -> string diff --git a/matitaB/matita/matitadaemon.ml b/matitaB/matita/matitadaemon.ml index 744034e06..b9aed4be8 100644 --- a/matitaB/matita/matitadaemon.ml +++ b/matitaB/matita/matitadaemon.ml @@ -403,6 +403,25 @@ let retract (cgi : Netcgi1_compat.Netcgi_types.cgi_activation) = ;; +let viewLib (cgi : Netcgi1_compat.Netcgi_types.cgi_activation) = + let cgi = Netcgi1_compat.Netcgi_types.of_compat_activation cgi in + let env = cgi#environment in + + let sid = Uuidm.of_string (Netcgi.Cookie.value (env#cookie "session")) in + let sid = HExtlib.unopt sid in + cgi # set_header + ~cache:`No_cache + ~content_type:"text/xml; charset=\"utf-8\"" + (); + let uid = MatitaAuthentication.user_of_session sid in + + let html = MatitaFilesystem.html_of_library uid in + cgi#out_channel#output_string + ("" ^ html ^ ""); + cgi#out_channel#commit_work() + +;; + open Netcgi1_compat.Netcgi_types;; (**********************************************************************) @@ -487,6 +506,13 @@ let start() = dyn_translator = (fun _ -> ""); (* not needed *) dyn_accept_all_conditionals = false; } in + let do_viewlib = + { Nethttpd_services.dyn_handler = (fun _ -> viewLib); + dyn_activation = Nethttpd_services.std_activation `Std_activation_buffered; + dyn_uri = None; (* not needed *) + dyn_translator = (fun _ -> ""); (* not needed *) + dyn_accept_all_conditionals = false; + } in let nethttpd_factory = Nethttpd_plex.nethttpd_factory @@ -496,7 +522,8 @@ let start() = ; "open", retrieve ; "register", do_register ; "login", do_login - ; "logout", do_logout ] + ; "logout", do_logout + ; "viewlib", do_viewlib] () in MatitaInit.initialize_all (); MatitaAuthentication.deserialize (); diff --git a/matitaB/matita/netplex.conf b/matitaB/matita/netplex.conf index 52178dee4..a270765e9 100644 --- a/matitaB/matita/netplex.conf +++ b/matitaB/matita/netplex.conf @@ -81,6 +81,13 @@ netplex { handler = "logout"; } }; + uri { + path = "/viewlib"; + service { + type = "dynamic"; + handler = "viewlib"; + } + }; }; }; workload_manager {