src/Pure/Thy/html.ML
changeset 9415 daa2296f23ea
parent 9045 a5bfcd4c2a5e
child 9963 6342d9c7fe46
equal deleted inserted replaced
9414:1463576f3968 9415:daa2296f23ea
     1 (*  Title:      Pure/Thy/HTML.ML
     1 (*  Title:      Pure/Thy/HTML.ML
     2     ID:         $Id$
     2     ID:         $Id$
     3     Author:     Markus Wenzel, TU Muenchen
     3     Author:     Markus Wenzel and Stefan Berghofer, TU Muenchen
     4     License:    GPL (GNU GENERAL PUBLIC LICENSE)
     4     License:    GPL (GNU GENERAL PUBLIC LICENSE)
     5 
     5 
     6 HTML presentation primitives.
     6 HTML presentation elements.
     7 *)
     7 *)
     8 
     8 
     9 signature HTML =
     9 signature HTML =
    10 sig
    10 sig
    11   val output: string -> string
    11   val output: string -> string
    24   val preform: text -> text
    24   val preform: text -> text
    25   val verbatim: string -> text
    25   val verbatim: string -> text
    26   val begin_index: Url.T * string -> Url.T * string -> Url.T option
    26   val begin_index: Url.T * string -> Url.T * string -> Url.T option
    27     -> Url.T option -> Url.T -> text
    27     -> Url.T option -> Url.T -> text
    28   val end_index: text
    28   val end_index: text
    29   val applet_pages: string -> Url.T * string -> bool -> (string * string) list
    29   val applet_pages: string -> Url.T * string -> (string * string) list
    30   val theory_entry: Url.T * string -> text
    30   val theory_entry: Url.T * string -> text
    31   val session_entries: (Url.T * string) list -> text
    31   val session_entries: (Url.T * string) list -> text
    32   val verbatim_source: Symbol.symbol list -> text
    32   val verbatim_source: Symbol.symbol list -> text
    33   val begin_theory: Url.T * string -> string -> (Url.T option * string) list ->
    33   val begin_theory: Url.T * string -> string -> (Url.T option * string) list ->
    34     (Url.T option * Url.T * bool option) list -> text -> text
    34     (Url.T option * Url.T * bool option) list -> text -> text
   166 val end_index = end_document;
   166 val end_index = end_document;
   167 
   167 
   168 fun choice chs s = space_implode " " (map (fn (s', lnk) =>
   168 fun choice chs s = space_implode " " (map (fn (s', lnk) =>
   169   enclose "[" "]" (if s = s' then keyword s' else href_name lnk s')) chs);
   169   enclose "[" "]" (if s = s' then keyword s' else href_name lnk s')) chs);
   170 
   170 
   171 fun applet_pages session back alt_graph =
   171 fun applet_pages session back =
   172   let
   172   let
   173     val choices = [("none", "small",  "small.html"),
   173     val sizes =
   174                    ("none", "medium", "medium.html"),
   174      [("small", "small.html", ("500", "400")),
   175                    ("none", "large",  "large.html"),
   175       ("medium", "medium.html", ("650", "520")),
   176                    ("all",  "small",  "small_all.html"),
   176       ("large", "large.html", ("800", "640"))];
   177                    ("all",  "medium", "medium_all.html"),
   177 
   178                    ("all",  "large",  "large_all.html")];
   178     fun applet_page (size, name, (width, height)) =
   179 
       
   180     val sizes = [("small",  ("500", "400")),
       
   181                  ("medium", ("650", "520")),
       
   182                  ("large",  ("800", "640"))];
       
   183 
       
   184     fun applet_page (gtype, size, name) =
       
   185       let
   179       let
   186         val (width, height) = the (assoc (sizes, size));
       
   187         val subsessions =
       
   188           if alt_graph then
       
   189             "View subsessions: " ^ choice (map (fn (x, _, z) => (x, z))
       
   190               (filter (fn (_, y, _) => y = size) choices)) gtype ^ "<br>\n"
       
   191           else "";
       
   192         val browser_size = "Set browser size: " ^
   180         val browser_size = "Set browser size: " ^
   193           choice (map (fn (_, y, z) => (y, z)) (filter (fn (x, _, _) => x = gtype) choices)) size;
   181           choice (map (fn (y, z, _) => (y, z)) sizes) size;
   194       in
   182       in
   195         (name, begin_document ("Theory dependencies of " ^ session) ^
   183         (name, begin_document ("Theory dependencies of " ^ session) ^
   196           back_link back ^
   184           back_link back ^
   197           para (subsessions ^ browser_size) ^
   185           para browser_size ^
   198           "\n<hr>\n<applet code=\"GraphBrowser/GraphBrowser.class\" \
   186           "\n<hr>\n<applet code=\"GraphBrowser/GraphBrowser.class\" \
   199           \width=" ^ width ^ " height=" ^ height ^ ">\n\
   187           \width=" ^ width ^ " height=" ^ height ^ ">\n\
   200           \<param name=\"graphfile\" value=\"" ^
   188           \<param name=\"graphfile\" value=\"" ^ "session.graph" ^ "\">\n\
   201           (if gtype = "all" then "all_sessions.graph" else "session.graph") ^ "\">\n\
       
   202           \</applet>\n<hr>" ^ end_document)
   189           \</applet>\n<hr>" ^ end_document)
   203       end;
   190       end;
   204   in map applet_page (take (if alt_graph then 6 else 3, choices)) end;
   191   in map applet_page sizes end;
   205 
   192 
   206 
   193 
   207 fun entry (p, s) = "<li>" ^ href_path p (plain s) ^ "\n";
   194 fun entry (p, s) = "<li>" ^ href_path p (plain s) ^ "\n";
   208 
   195 
   209 val theory_entry = entry;
   196 val theory_entry = entry;