summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2010-01-02 14:54:15 -0500
committerGravatar Adam Chlipala <adamc@hcoop.net>2010-01-02 14:54:15 -0500
commitd777d7da78fccb8f15eccff680deca36ae57314b (patch)
tree96967222b55ddf2e8ab94d78bbb13cf84fd1ddd4
parent547adaccb0b29cc02ff89013f84ae6446665144d (diff)
JavaScript urlification; more lenient export pattern in Corify; only include scripts in pages that use JavaScript
-rw-r--r--lib/js/urweb.js4
-rw-r--r--src/cjr_print.sml22
-rw-r--r--src/corify.sml19
-rw-r--r--src/jscomp.sml13
4 files changed, 38 insertions, 20 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js
index 8d7f6e40..a5713bf0 100644
--- a/lib/js/urweb.js
+++ b/lib/js/urweb.js
@@ -691,6 +691,10 @@ function xhrFinished(xhr) {
inFlight = remove(xhr, inFlight);
}
+function unurlify(parse, s) {
+ return parse(s);
+}
+
function rc(prefix, uri, parse, k, needsSig) {
uri = cat(prefix, uri);
uri = flattenLocal(uri);
diff --git a/src/cjr_print.sml b/src/cjr_print.sml
index 2cfd0663..8c5a24b4 100644
--- a/src/cjr_print.sml
+++ b/src/cjr_print.sml
@@ -2591,15 +2591,19 @@ fun p_file env (ds, ps) =
val scripts =
case side of
ServerOnly => ""
- | _ => "<script src=\\\""
- ^ OS.Path.joinDirFile {dir = Settings.getUrlPrefix (),
- file = "app.js"}
- ^ "\\\"></script>\\n"
-
- val scripts = foldl (fn (x, scripts) =>
- scripts
- ^ "<script src=\\\"" ^ x ^ "\\\"></script>\\n")
- scripts (Settings.getScripts ())
+ | _ =>
+ let
+ val scripts =
+ "<script src=\\\""
+ ^ OS.Path.joinDirFile {dir = Settings.getUrlPrefix (),
+ file = "app.js"}
+ ^ "\\\"></script>\\n"
+ in
+ foldl (fn (x, scripts) =>
+ scripts
+ ^ "<script src=\\\"" ^ x ^ "\\\"></script>\\n")
+ scripts (Settings.getScripts ())
+ end
in
string scripts
end,
diff --git a/src/corify.sml b/src/corify.sml
index a1a5c745..2720f8db 100644
--- a/src/corify.sml
+++ b/src/corify.sml
@@ -964,16 +964,15 @@ fun corifyDecl mods (all as (d, loc : EM.span), st) =
fun wrapSgi ((sgi, _), (wds, eds)) =
case sgi of
L.SgiVal (s, _, t as (L.TFun (dom, ran), _)) =>
- (case (#1 dom, #1 ran) of
- (L.TRecord _,
- L.CApp ((L.CModProj (basis, [], "transaction"), _),
- ran' as
- (L.CApp
- ((L.CApp
- ((L.CApp ((L.CModProj (basis', [], "xml"), _),
- (L.CRecord (_, [((L.CName "Html", _),
- _)]), _)), _), _),
- _), _), _))) =>
+ (case #1 ran of
+ L.CApp ((L.CModProj (basis, [], "transaction"), _),
+ ran' as
+ (L.CApp
+ ((L.CApp
+ ((L.CApp ((L.CModProj (basis', [], "xml"), _),
+ (L.CRecord (_, [((L.CName "Html", _),
+ _)]), _)), _), _),
+ _), _), _)) =>
let
val ran = (L.TRecord (L.CRecord ((L.KType, loc), []), loc), loc)
val ranT = (L.CApp ((L.CModProj (basis, [], "transaction"), loc),
diff --git a/src/jscomp.sml b/src/jscomp.sml
index ca20e71d..11d75a3a 100644
--- a/src/jscomp.sml
+++ b/src/jscomp.sml
@@ -869,10 +869,21 @@ fun process file =
| EDml _ => unsupported "DML"
| ENextval _ => unsupported "Nextval"
| ESetval _ => unsupported "Nextval"
- | EUnurlify _ => unsupported "EUnurlify"
| EReturnBlob _ => unsupported "EUnurlify"
| ERedirect _ => unsupported "ERedirect"
+ | EUnurlify (e, t) =>
+ let
+ val (e, st) = jsE inner (e, st)
+ val (e', st) = unurlifyExp loc (t, st)
+ in
+ (strcat [str ("{c:\"f\",f:\"unurlify\",a:cons({c:\"c\",v:function(s){var t=s.split(\"/\");var i=0;return "
+ ^ e' ^ "}},cons("),
+ e,
+ str ",null))}"],
+ st)
+ end
+
| ESignalReturn e =>
let
val (e, st) = jsE inner (e, st)