112 in |
112 in |
113 {name = name, ID = ID_of session name, dir = sess_name, |
113 {name = name, ID = ID_of session name, dir = sess_name, |
114 path = |
114 path = |
115 if null session then "" else |
115 if null session then "" else |
116 if is_some remote_path andalso not is_local then |
116 if is_some remote_path andalso not is_local then |
117 Url.pack (Url.append (the remote_path) (Url.file |
117 Url.pack (Url.append (the remote_path) (Url.File |
118 (Path.append (Path.make session) (html_path name)))) |
118 (Path.append (Path.make session) (html_path name)))) |
119 else Path.pack (Path.append (mk_rel_path curr_sess session) (html_path name)), |
119 else Path.pack (Path.append (mk_rel_path curr_sess session) (html_path name)), |
120 unfold = false, |
120 unfold = false, |
121 parents = |
121 parents = |
122 map (fn s => ID_of (#session (get_info (ThyInfo.theory s))) s) (ThyInfo.get_preds name)} |
122 map (fn s => ID_of (#session (get_info (ThyInfo.theory s))) s) (ThyInfo.get_preds name)} |
240 |
240 |
241 (* maintain index *) |
241 (* maintain index *) |
242 |
242 |
243 val session_entries = |
243 val session_entries = |
244 HTML.session_entries o |
244 HTML.session_entries o |
245 map (fn name => (Url.file (Path.append (Path.basic name) index_path), name)); |
245 map (fn name => (Url.File (Path.append (Path.basic name) index_path), name)); |
246 |
246 |
247 fun get_entries dir = |
247 fun get_entries dir = |
248 split_lines (File.read (Path.append dir session_entries_path)); |
248 split_lines (File.read (Path.append dir session_entries_path)); |
249 |
249 |
250 fun put_entries entries dir = |
250 fun put_entries entries dir = |
292 std_error "Warning: missing document directory\n"); (None, None)) |
292 std_error "Warning: missing document directory\n"); (None, None)) |
293 else (Some (Path.append html_prefix doc_path), Some (Path.ext doc doc_path)); |
293 else (Some (Path.append html_prefix doc_path), Some (Path.ext doc doc_path)); |
294 |
294 |
295 val parent_index_path = Path.append Path.parent index_path; |
295 val parent_index_path = Path.append Path.parent index_path; |
296 val index_up_lnk = if first_time then |
296 val index_up_lnk = if first_time then |
297 Url.append (the remote_path) (Url.file (Path.append sess_prefix parent_index_path)) |
297 Url.append (the remote_path) (Url.File (Path.append sess_prefix parent_index_path)) |
298 else Url.file parent_index_path; |
298 else Url.File parent_index_path; |
299 val readme = |
299 val readme = |
300 if File.exists readme_html_path then Some readme_html_path |
300 if File.exists readme_html_path then Some readme_html_path |
301 else if File.exists readme_path then Some readme_path |
301 else if File.exists readme_path then Some readme_path |
302 else None; |
302 else None; |
303 |
303 |
304 val index_text = HTML.begin_index (index_up_lnk, parent_name) |
304 val index_text = HTML.begin_index (index_up_lnk, parent_name) |
305 (Url.file index_path, session_name) (apsome Url.file readme) |
305 (Url.File index_path, session_name) (apsome Url.File readme) |
306 (apsome Url.file document_path) (Url.unpack "medium.html"); |
306 (apsome Url.File document_path) (Url.unpack "medium.html"); |
307 in |
307 in |
308 session_info := Some (make_session_info (name, parent_name, session_name, path, html_prefix, |
308 session_info := Some (make_session_info (name, parent_name, session_name, path, html_prefix, |
309 info, doc, doc_graph, doc_prefix1, doc_prefix2, remote_path, verbose, readme)); |
309 info, doc, doc_graph, doc_prefix1, doc_prefix2, remote_path, verbose, readme)); |
310 browser_info := init_browser_info remote_path path; |
310 browser_info := init_browser_info remote_path path; |
311 add_html_index index_text |
311 add_html_index index_text |
375 if length path > 1 then update_index parent_html_prefix name else (); |
375 if length path > 1 then update_index parent_html_prefix name else (); |
376 (case readme of None => () | Some path => File.copy path (Path.append html_prefix path)); |
376 (case readme of None => () | Some path => File.copy path (Path.append html_prefix path)); |
377 write_graph graph (Path.append html_prefix graph_path); |
377 write_graph graph (Path.append html_prefix graph_path); |
378 copy_files (Path.unpack "~~/lib/browser/GraphBrowser.jar") html_prefix; |
378 copy_files (Path.unpack "~~/lib/browser/GraphBrowser.jar") html_prefix; |
379 seq (fn (a, txt) => File.write (Path.append html_prefix (Path.basic a)) txt) |
379 seq (fn (a, txt) => File.write (Path.append html_prefix (Path.basic a)) txt) |
380 (HTML.applet_pages name (Url.file index_path, name)); |
380 (HTML.applet_pages name (Url.File index_path, name)); |
381 copy_files (Path.unpack "~~/lib/html/isabelle.css") html_prefix; |
381 copy_files (Path.unpack "~~/lib/html/isabelle.css") html_prefix; |
382 seq finish_html thys; |
382 seq finish_html thys; |
383 seq (uncurry File.write) files; |
383 seq (uncurry File.write) files; |
384 conditional verbose (fn () => |
384 conditional verbose (fn () => |
385 std_error ("Browser info at " ^ show_path html_prefix ^ "\n")))); |
385 std_error ("Browser info at " ^ show_path html_prefix ^ "\n")))); |
415 |
415 |
416 fun parent_link remote_path curr_session name = |
416 fun parent_link remote_path curr_session name = |
417 let val {name = _, session, is_local} = get_info (ThyInfo.theory name) |
417 let val {name = _, session, is_local} = get_info (ThyInfo.theory name) |
418 in (if null session then None else |
418 in (if null session then None else |
419 Some (if is_some remote_path andalso not is_local then |
419 Some (if is_some remote_path andalso not is_local then |
420 Url.append (the remote_path) (Url.file |
420 Url.append (the remote_path) (Url.File |
421 (Path.append (Path.make session) (html_path name))) |
421 (Path.append (Path.make session) (html_path name))) |
422 else Url.file (Path.append (mk_rel_path curr_session session) |
422 else Url.File (Path.append (mk_rel_path curr_session session) |
423 (html_path name))), name) |
423 (html_path name))), name) |
424 end; |
424 end; |
425 |
425 |
426 fun begin_theory name raw_parents orig_files thy = |
426 fun begin_theory name raw_parents orig_files thy = |
427 with_session thy (fn {name = sess_name, session, path, html_prefix, remote_path, ...} => |
427 with_session thy (fn {name = sess_name, session, path, html_prefix, remote_path, ...} => |
437 let |
437 let |
438 val base = Path.base path; |
438 val base = Path.base path; |
439 val base_html = html_ext base; |
439 val base_html = html_ext base; |
440 in |
440 in |
441 add_file (Path.append html_prefix base_html, |
441 add_file (Path.append html_prefix base_html, |
442 HTML.ml_file (Url.file base) (File.read path)); |
442 HTML.ml_file (Url.File base) (File.read path)); |
443 (Some (Url.file base_html), Url.file raw_path, loadit) |
443 (Some (Url.File base_html), Url.File raw_path, loadit) |
444 end |
444 end |
445 | None => (warning ("Browser info: expected to find ML file" ^ quote (Path.pack raw_path)); |
445 | None => (warning ("Browser info: expected to find ML file" ^ quote (Path.pack raw_path)); |
446 (None, Url.file raw_path, loadit))); |
446 (None, Url.File raw_path, loadit))); |
447 |
447 |
448 val files_html = map prep_file files; |
448 val files_html = map prep_file files; |
449 |
449 |
450 fun prep_html_source (tex_source, html_source, html) = |
450 fun prep_html_source (tex_source, html_source, html) = |
451 let |
451 let |
452 val txt = HTML.begin_theory (Url.file index_path, session) |
452 val txt = HTML.begin_theory (Url.File index_path, session) |
453 name parents files_html (Buffer.content html_source) |
453 name parents files_html (Buffer.content html_source) |
454 in (tex_source, Buffer.empty, Buffer.add txt html) end; |
454 in (tex_source, Buffer.empty, Buffer.add txt html) end; |
455 |
455 |
456 val entry = |
456 val entry = |
457 {name = name, ID = ID_of path name, dir = sess_name, unfold = true, |
457 {name = name, ID = ID_of path name, dir = sess_name, unfold = true, |
459 parents = map (fn s => ID_of (#session (get_info (ThyInfo.theory s))) s) raw_parents}; |
459 parents = map (fn s => ID_of (#session (get_info (ThyInfo.theory s))) s) raw_parents}; |
460 |
460 |
461 in |
461 in |
462 change_theory_info name prep_html_source; |
462 change_theory_info name prep_html_source; |
463 add_graph_entry entry; |
463 add_graph_entry entry; |
464 add_html_index (HTML.theory_entry (Url.file (html_path name), name)); |
464 add_html_index (HTML.theory_entry (Url.File (html_path name), name)); |
465 add_tex_index (Latex.theory_entry name); |
465 add_tex_index (Latex.theory_entry name); |
466 BrowserInfoData.put {name = sess_name, session = path, is_local = is_some remote_path} thy |
466 BrowserInfoData.put {name = sess_name, session = path, is_local = is_some remote_path} thy |
467 end); |
467 end); |
468 |
468 |
469 |
469 |