diff src/cjr_print.sml @ 569:162d5308e34f

Successfully generated a page element from a signal
author Adam Chlipala <adamc@hcoop.net>
date Sat, 20 Dec 2008 16:19:26 -0500
parents ae03d09043c1
children 889dc9fceb3a
line wrap: on
line diff
--- a/src/cjr_print.sml	Sat Dec 20 15:46:48 2008 -0500
+++ b/src/cjr_print.sml	Sat Dec 20 16:19:26 2008 -0500
@@ -1800,6 +1800,10 @@
              
              string "}"]
 
+      | DJavaScript s => box [string "static char jslib[] = \"",
+                              string (String.toString s),
+                              string "\";"]
+
 datatype 'a search =
          Found of 'a
        | NotFound
@@ -2048,6 +2052,10 @@
                      newline,
                      string "if (*request == '/') ++request;",
                      newline,
+                     string "uw_write_header(ctx, \"Content-type: text/html\\r\\n\");",
+                     newline,
+                     string "uw_write(ctx, \"<html>\");",
+                     newline,
                      box [string "{",
                           newline,
                           box (ListUtil.mapi (fn (i, t) => box [p_typ env t,
@@ -2070,6 +2078,8 @@
                           inputsVar,
                           string ", uw_unit_v);",
                           newline,
+                          string "uw_write(ctx, \"</html>\");",
+                          newline,
                           string "return;",
                           newline,
                           string "}",
@@ -2374,6 +2384,16 @@
              newline,
              string "void uw_handle(uw_context ctx, char *request) {",
              newline,
+             string "if (!strcmp(request, \"/app.js\")) {",
+             newline,
+             box [string "uw_write_header(ctx, \"Content-type: text/javascript\\r\\n\");",
+                  newline,
+                  string "uw_write(ctx, jslib);",
+                  newline,
+                  string "return;",
+                  newline],
+             string "}",
+             newline,
              p_list_sep newline (fn x => x) pds',
              newline,
              string "uw_error(ctx, FATAL, \"Unknown page\");",