summaryrefslogtreecommitdiff
path: root/demo
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-05-03 12:49:47 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-05-03 12:49:47 -0400
commitddac92a3d792b7e7342e4003862cd5ff5c1f0ab8 (patch)
tree2e285d15430f628b73456a233c5f3d79ea740307 /demo
parent4be41963bba445bb3bb26d5e05883f7eb72a9a22 (diff)
upload demo
Diffstat (limited to 'demo')
-rw-r--r--demo/prose6
-rw-r--r--demo/upload.ur11
-rw-r--r--demo/upload.urp5
-rw-r--r--demo/upload.urs1
4 files changed, 23 insertions, 0 deletions
diff --git a/demo/prose b/demo/prose
index 4eb5fe93..2d4f5ea3 100644
--- a/demo/prose
+++ b/demo/prose
@@ -74,6 +74,12 @@ css.urp
<p>Ur/Web supports a structured approach to Cascading Style Sheets, where each style is a first-class value within a module. This demo shows the importing of an external style sheet with one style. By default, like other Ur/Web entities, the name of the style would be <tt>Css_quote</tt>. We use the <tt>rewrite</tt> directive in the <tt>.urp</tt> file to specify an alternate name for a particular canonical module path. The external style sheet contains a definition of a style with the alternate name that we give.</p>
+upload.urp
+
+<p>HTTP file upload is made convenient, via the abstract types <tt>blob</tt> and <tt>file</tt> in the standard library. A <tt>blob</tt> is a binary sequence, and a <tt>file</tt> combines a <tt>blob</tt> with MIME type information. An <tt>upload</tt> form input can be used to accept <tt>file</tt>s from the user.</p>
+
+<p>In the <tt>.urp</tt> file for this example, we give a whitelist of MIME types to be accepted. The application will echo back to the user any file he uploads as one of those types. You can try submitting other kinds of files to verify that they are rejected.</p>
+
listShop.urp
<p>This example shows off algebraic datatypes, parametric polymorphism, and functors.</p>
diff --git a/demo/upload.ur b/demo/upload.ur
new file mode 100644
index 00000000..505a1ae4
--- /dev/null
+++ b/demo/upload.ur
@@ -0,0 +1,11 @@
+fun echo r =
+ if blobSize (fileData r.File) > 100000 then
+ return <xml>Whoa! That one's too big.</xml>
+ else
+ returnBlob (fileData r.File) (blessMime (fileMimeType r.File))
+
+fun main () = return <xml><body>
+ <h1>The Amazing File Echoer!</h1>
+
+ <form>Upload a file: <upload{#File}/> <submit action={echo}/></form>
+</body></xml>
diff --git a/demo/upload.urp b/demo/upload.urp
new file mode 100644
index 00000000..60519aaa
--- /dev/null
+++ b/demo/upload.urp
@@ -0,0 +1,5 @@
+allow mime text/plain
+allow mime image/png
+allow mime image/gif
+
+upload
diff --git a/demo/upload.urs b/demo/upload.urs
new file mode 100644
index 00000000..6ac44e0b
--- /dev/null
+++ b/demo/upload.urs
@@ -0,0 +1 @@
+val main : unit -> transaction page