summaryrefslogtreecommitdiff
path: root/src/cjr_print.sml
diff options
context:
space:
mode:
Diffstat (limited to 'src/cjr_print.sml')
-rw-r--r--src/cjr_print.sml20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/cjr_print.sml b/src/cjr_print.sml
index 8c3c3d86..06f9f5ca 100644
--- a/src/cjr_print.sml
+++ b/src/cjr_print.sml
@@ -1800,6 +1800,10 @@ fun p_decl env (dAll as (d, _) : decl) =
string "}"]
+ | DJavaScript s => box [string "static char jslib[] = \"",
+ string (String.toString s),
+ string "\";"]
+
datatype 'a search =
Found of 'a
| NotFound
@@ -2048,6 +2052,10 @@ fun p_file env (ds, ps) =
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 @@ fun p_file env (ds, ps) =
inputsVar,
string ", uw_unit_v);",
newline,
+ string "uw_write(ctx, \"</html>\");",
+ newline,
string "return;",
newline,
string "}",
@@ -2374,6 +2384,16 @@ fun p_file env (ds, ps) =
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\");",