1 (* Copyright (C) 2004-2011, HELM Team.
3 * This file is part of HELM, an Hypertextual, Electronic
4 * Library of Mathematics, developed at the Computer Science
5 * Department, University of Bologna, Italy.
7 * HELM is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * HELM is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with HELM; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 * For details, see the HELM World-Wide-Web page,
23 * http://helm.cs.unibo.it/
26 exception SvnError of string;;
28 let exec_process cmd =
29 let (stdout, stdin, stderr) as chs = Unix.open_process_full cmd [||] in
30 let outlines = ref [] in
31 let errlines = ref [] in
34 outlines := input_line stdout :: !outlines;
40 errlines := input_line stderr :: !errlines;
44 match (Unix.close_process_full chs) with
45 | Unix.WEXITED errno ->
46 let output = "std out =\n" ^ String.concat "\n" (List.rev !outlines) in
47 let errors = "std err =\n" ^ String.concat "\n" (List.rev !errlines) in
48 errno, output ^ "\n\n" ^ errors
52 let rt_dir = Helm_registry.get "matita.rt_base_dir" in
53 let repo = Helm_registry.get "matita.weblib" in
55 let errno, outstr = exec_process
56 ("svn co " ^ repo ^ " " ^ rt_dir ^ "/users/" ^ user ^ "/")
59 else raise (SvnError outstr)
61 let html_of_library uid =
63 let newid () = incr i; ("node" ^ string_of_int !i) in
67 "<span class=\"trigger\" onClick=\"showBranch(" ^ id ^ ")\">\n" ^
68 "<img src=\"treeview/closed.gif\" id=\"I" ^ id ^ "\"/>\n" ^
69 text ^ "<br/></span>\n" ^
70 "<span class=\"branch\" id=\"" ^ id ^ "\">\n" ^
74 "<img src=\"treeview/doc.gif\"/>\n" ^
75 "<a href=\"" ^ link ^ "\">" ^ text ^ "</a><br/>"
79 let dirlist = Array.to_list (Sys.readdir path) in
80 let subdirs = List.filter (fun x -> Sys.is_directory (path ^ "/" ^ x)) dirlist in
84 let i = String.rindex x '.' in
85 not (Sys.is_directory (path ^ "/" ^ x)) && (String.sub x i 3 = ".ma")
86 with Not_found | Invalid_argument _ -> false) dirlist in
88 String.concat "\n" (List.map (fun x -> aux (path ^ "/" ^ x)) subdirs) in
91 (List.map (fun x -> leaf x (path ^ "/" ^ x)) scripts)
93 branch (Filename.basename path) (subdirtags ^ "\n" ^ scripttags)
96 let basedir = (Helm_registry.get "matita.rt_base_dir") ^ "/users/" ^ uid ^ "/" in
97 let res = aux basedir in
98 prerr_endline "BEGIN TREE";prerr_endline res;prerr_endline "END TREE";