comparison src/cjr_print.sml @ 643:aa2290c32ce2

Avoid any JavaScript when pages don't need it; update demo prose
author Adam Chlipala <adamc@hcoop.net>
date Tue, 10 Mar 2009 10:44:26 -0400
parents b98f547a6a45
children 1b571a05874c
comparison
equal deleted inserted replaced
642:4a125bbc602d 643:aa2290c32ce2
1 (* Copyright (c) 2008, Adam Chlipala 1 (* Copyright (c) 2008-2009, Adam Chlipala
2 * All rights reserved. 2 * All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met: 5 * modification, are permitted provided that the following conditions are met:
6 * 6 *
2128 val (pds, env) = ListUtil.foldlMap (fn (d, env) => 2128 val (pds, env) = ListUtil.foldlMap (fn (d, env) =>
2129 (p_decl env d, 2129 (p_decl env d,
2130 E.declBinds env d)) 2130 E.declBinds env d))
2131 env ds 2131 env ds
2132 2132
2133 val fields = foldl (fn ((ek, _, _, ts, _), fields) => 2133 val fields = foldl (fn ((ek, _, _, ts, _, _), fields) =>
2134 case ek of 2134 case ek of
2135 Core.Link => fields 2135 Core.Link => fields
2136 | Core.Rpc => fields 2136 | Core.Rpc => fields
2137 | Core.Action => 2137 | Core.Action =>
2138 case List.nth (ts, length ts - 2) of 2138 case List.nth (ts, length ts - 2) of
2249 string "-1;", 2249 string "-1;",
2250 newline, 2250 newline,
2251 string "}"] 2251 string "}"]
2252 end 2252 end
2253 2253
2254 fun p_page (ek, s, n, ts, ran) = 2254 fun p_page (ek, s, n, ts, ran, side) =
2255 let 2255 let
2256 val (ts, defInputs, inputsVar) = 2256 val (ts, defInputs, inputsVar) =
2257 case ek of 2257 case ek of
2258 Core.Link => (List.take (ts, length ts - 1), string "", string "") 2258 Core.Link => (List.take (ts, length ts - 1), string "", string "")
2259 | Core.Rpc => (List.take (ts, length ts - 1), string "", string "") 2259 | Core.Rpc => (List.take (ts, length ts - 1), string "", string "")
2344 | _ => [string "uw_write_header(ctx, \"Content-type: text/html\\r\\n\");", 2344 | _ => [string "uw_write_header(ctx, \"Content-type: text/html\\r\\n\");",
2345 newline, 2345 newline,
2346 string "uw_write_header(ctx, \"Content-script-type: text/javascript\\r\\n\");", 2346 string "uw_write_header(ctx, \"Content-script-type: text/javascript\\r\\n\");",
2347 newline, 2347 newline,
2348 string "uw_write(ctx, \"<html>\");", 2348 string "uw_write(ctx, \"<html>\");",
2349 newline,
2350 string "uw_set_script_header(ctx, \"",
2351 string (case side of
2352 ServerAndClient => "<script src=\\\"/app.js\\\"></script>\\n"
2353 | ServerOnly => ""),
2354 string "\");",
2349 newline]), 2355 newline]),
2350 box [string "{", 2356 box [string "{",
2351 newline, 2357 newline,
2352 box (ListUtil.mapi (fn (i, t) => box [p_typ env t, 2358 box (ListUtil.mapi (fn (i, t) => box [p_typ env t,
2353 space, 2359 space,