let i = ref 0 in
let newid () = incr i; ("node" ^ string_of_int !i) in
+ let basedir = (Helm_registry.get "matita.rt_base_dir") ^ "/users/" ^ uid in
+
let branch text acc =
let id = newid () in
- "<span class=\"trigger\" onClick=\"showBranch(" ^ id ^ ")\">\n" ^
+ let name = Filename.basename text in
+ let name = if name <> "." then name else "cic:/matita" in
+ "<span class=\"trigger\" onClick=\"showBranch('" ^ id ^ "')\">\n" ^
"<img src=\"treeview/closed.gif\" id=\"I" ^ id ^ "\"/>\n" ^
- text ^ "<br/></span>\n" ^
+ name ^ "<br/></span>\n" ^
"<span class=\"branch\" id=\"" ^ id ^ "\">\n" ^
acc ^ "\n</span>"
in
- let leaf text link =
+ let leaf text =
"<img src=\"treeview/doc.gif\"/>\n" ^
- "<a href=\"" ^ link ^ "\">" ^ text ^ "</a><br/>"
+ "<a href=\"javascript:retrieveFile('" ^ text ^ "')\">" ^
+ (Filename.basename text) ^ "</a><br/>"
in
let rec aux path =
- let dirlist = Array.to_list (Sys.readdir path) in
- let subdirs = List.filter (fun x -> Sys.is_directory (path ^ "/" ^ x)) dirlist in
+ let lpath filename = path ^ "/" ^ filename in
+ let gpath filename = basedir ^ "/" ^ path ^ "/" ^ filename in
+ let dirlist =
+ List.filter (fun x -> String.sub x 0 1 <> ".")
+ (Array.to_list (Sys.readdir (basedir ^ "/" ^ path))) in
+ let subdirs = List.filter (fun x -> Sys.is_directory (gpath x)) dirlist in
let scripts =
List.filter (fun x ->
try
let i = String.rindex x '.' in
- not (Sys.is_directory (path ^ "/" ^ x)) && (String.sub x i 3 = ".ma")
+ let len = String.length x - i in
+ not (Sys.is_directory (gpath x)) &&
+ (String.sub x 0 1 <> ".") && (String.sub x i len = ".ma")
with Not_found | Invalid_argument _ -> false) dirlist in
let subdirtags =
- String.concat "\n" (List.map (fun x -> aux (path ^ "/" ^ x)) subdirs) in
+ String.concat "\n" (List.map (fun x -> aux (lpath x)) subdirs) in
let scripttags =
String.concat "\n"
- (List.map (fun x -> leaf x (path ^ "/" ^ x)) scripts)
+ (List.map (fun x -> leaf (lpath x)) scripts)
in
- branch (Filename.basename path) (subdirtags ^ "\n" ^ scripttags)
+ branch path (subdirtags ^ "\n" ^ scripttags)
in
- let basedir = (Helm_registry.get "matita.rt_base_dir") ^ "/users/" ^ uid ^ "/" in
- let res = aux basedir in
+ let res = aux "." in
prerr_endline "BEGIN TREE";prerr_endline res;prerr_endline "END TREE";
res
;;
+
+let reset_lib () =
+ let to_be_removed = (Helm_registry.get "matita.rt_base_dir") ^ "/users/*" in
+ ignore (Sys.command ("rm -rf " ^ to_be_removed))
+;;