File: htmlout.ml

package info (click to toggle)
misery 0.2-1.1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 380 kB
  • ctags: 298
  • sloc: ml: 1,295; xml: 180; makefile: 94
file content (23 lines) | stat: -rw-r--r-- 794 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
(* Utility functions for HTML output. *)

let create_page filename title =
  let root = Misc.get_root_directory () in
  let path = root ^ "/html/" ^ filename ^ ".html" in
  try
    let channel = open_out path in
      output_string channel "<html><head><title>";
      output_string channel title;
      output_string channel "</title>";
      output_string channel "<link rel=\"stylesheet\" type=\"text/css\" ";
      output_string channel "href=\"accounts.css\" />";
      output_string channel "</head>\n<body>";
      output_string channel "<h1>";
      output_string channel title;
      output_string channel "</h1>";
      channel
  with Sys_error _ -> Misc.fail ("Could not create file " ^ path)

let finish_page channel =
  output_string channel "</body></html>";
  close_out channel