summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--demo/more/dragList.ur26
-rw-r--r--demo/more/dragList.urp3
-rw-r--r--demo/more/out/dragList.css18
-rw-r--r--demo/more/prose4
-rw-r--r--lib/ur/monad.ur4
-rw-r--r--lib/ur/monad.urs3
-rw-r--r--src/c/urweb.c3
7 files changed, 49 insertions, 12 deletions
diff --git a/demo/more/dragList.ur b/demo/more/dragList.ur
index ddb50e82..efdafc8a 100644
--- a/demo/more/dragList.ur
+++ b/demo/more/dragList.ur
@@ -10,11 +10,12 @@ fun draggableList title items =
onmouseover={di <- get draggingItem;
case di of
None => return ()
- | Some di => item1 <- get di;
- item2 <- get itemSource;
- set di item2;
- set itemSource item1}>
- <dyn signal={s <- signal itemSource; return <xml>{[s]}</xml>}/>
+ | Some di => original <- get di;
+ movedOver <- get itemSource;
+ set di movedOver;
+ set itemSource original;
+ set draggingItem (Some itemSource)}>
+ <dyn signal={Monad.mp (fn s => <xml>{[s]}</xml>) (signal itemSource)}/>
</li></xml>) itemSources}
</ul>
</xml>
@@ -26,8 +27,13 @@ fun main () =
:: "Sus scrofa ussuricus"
:: "Sus scrofa cristatus"
:: "Sus scrofa taiwanus" :: []);
- return <xml><body>
- {bears}
- {beers}
- {boars}
- </body></xml>
+ return <xml>
+ <head>
+ <link rel="stylesheet" type="text/css" href="../../dragList.css"/>
+ </head>
+ <body>
+ {bears}
+ {beers}
+ {boars}
+ </body>
+ </xml>
diff --git a/demo/more/dragList.urp b/demo/more/dragList.urp
index 56fb9cce..42ec5c46 100644
--- a/demo/more/dragList.urp
+++ b/demo/more/dragList.urp
@@ -1,4 +1,5 @@
-debug
+allow url ../../dragList.css
$/list
+$/monad
dragList
diff --git a/demo/more/out/dragList.css b/demo/more/out/dragList.css
new file mode 100644
index 00000000..8fd239a9
--- /dev/null
+++ b/demo/more/out/dragList.css
@@ -0,0 +1,18 @@
+ul {
+ width: 200px;
+ list-style-image: url(http://script.aculo.us/images/bullet.gif);
+}
+
+li {
+ color: #7E9E50;
+ font: 20px Georgia;
+ background-color: #ECF3E1;
+ border:1px solid #C5DEA1;
+ cursor: move;
+ margin: 0px;
+}
+
+h2 {
+ font: 42px/30px Georgia, serif;
+ color: #7E9E50;
+}
diff --git a/demo/more/prose b/demo/more/prose
index 37a79724..c2a3d281 100644
--- a/demo/more/prose
+++ b/demo/more/prose
@@ -1,3 +1,7 @@
<p>These are some extra demo applications written in <a href="http://www.impredicative.com/ur/">Ur/Web</a>. See <a href="http://www.impredicative.com/ur/demo/">the main demo</a> for a more tutorial-like progression through language and library features.</p>
+dragList.urp
+
+This is an Ur/Web version of the "draggable lists" <a href="http://groups.inf.ed.ac.uk/links/examples/">demo program from Links</a>.
+
grid1.urp
diff --git a/lib/ur/monad.ur b/lib/ur/monad.ur
index d6690839..96c46311 100644
--- a/lib/ur/monad.ur
+++ b/lib/ur/monad.ur
@@ -8,6 +8,10 @@ fun exec [m ::: Type -> Type] (_ : monad m) [ts ::: {Type}] r (fd : folder ts) =
fun ignore [m ::: Type -> Type] (_ : monad m) [t] (v : m t) = x <- v; return ()
+fun mp [m] (_ : monad m) [a] [b] f m =
+ v <- m;
+ return (f v)
+
fun foldR [K] [m] (_ : monad m) [tf :: K -> Type] [tr :: {K} -> Type]
(f : nm :: Name -> t :: K -> rest :: {K}
-> [[nm] ~ rest] =>
diff --git a/lib/ur/monad.urs b/lib/ur/monad.urs
index f64e2362..27fe255f 100644
--- a/lib/ur/monad.urs
+++ b/lib/ur/monad.urs
@@ -4,6 +4,9 @@ val exec : m ::: (Type -> Type) -> monad m -> ts ::: {Type}
val ignore : m ::: (Type -> Type) -> monad m -> t ::: Type
-> m t -> m unit
+val mp : m ::: (Type -> Type) -> monad m -> a ::: Type -> b ::: Type
+ -> (a -> b) -> m a -> m b
+
val foldR : K --> m ::: (Type -> Type) -> monad m
-> tf :: (K -> Type)
-> tr :: ({K} -> Type)
diff --git a/src/c/urweb.c b/src/c/urweb.c
index 4160fa81..8566609b 100644
--- a/src/c/urweb.c
+++ b/src/c/urweb.c
@@ -2556,6 +2556,7 @@ void uw_commit(uw_context ctx) {
char *start = strstr(ctx->page.start, "<sc>");
if (start) {
buf_check(&ctx->page, buf_used(&ctx->page) - 4 + len);
+ start = strstr(ctx->page.start, "<sc>");
memmove(start + len, start + 4, buf_used(&ctx->page) - (start - ctx->page.start) - 3);
ctx->page.front += len - 4;
memcpy(start, ctx->script_header, len);
@@ -2566,13 +2567,13 @@ void uw_commit(uw_context ctx) {
char *start = strstr(ctx->page.start, "<sc>");
if (start) {
buf_check(&ctx->page, buf_used(&ctx->page) - 4 + lenP);
+ start = strstr(ctx->page.start, "<sc>");
memmove(start + lenP, start + 4, buf_used(&ctx->page) - (start - ctx->page.start) - 3);
ctx->page.front += lenP - 4;
memcpy(start, ctx->script_header, lenH);
memcpy(start + lenH, "<script type=\"text/javascript\">", 31);
memcpy(start + lenH + 31, ctx->script.start, len);
memcpy(start + lenH + 31 + len, "</script>", 9);
- printf("start=%s\n", start);
}
}
}