From b6f2b2e7ae6d76ee5c88f2c4bb2cd4d74ee577ca Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sun, 3 May 2009 12:49:47 -0400 Subject: upload demo --- demo/prose | 6 ++++++ demo/upload.ur | 11 +++++++++++ demo/upload.urp | 5 +++++ demo/upload.urs | 1 + 4 files changed, 23 insertions(+) create mode 100644 demo/upload.ur create mode 100644 demo/upload.urp create mode 100644 demo/upload.urs (limited to 'demo') diff --git a/demo/prose b/demo/prose index 4eb5fe93..2d4f5ea3 100644 --- a/demo/prose +++ b/demo/prose @@ -74,6 +74,12 @@ css.urp

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 Css_quote. We use the rewrite directive in the .urp 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.

+upload.urp + +

HTTP file upload is made convenient, via the abstract types blob and file in the standard library. A blob is a binary sequence, and a file combines a blob with MIME type information. An upload form input can be used to accept files from the user.

+ +

In the .urp 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.

+ listShop.urp

This example shows off algebraic datatypes, parametric polymorphism, and functors.

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 Whoa! That one's too big. + else + returnBlob (fileData r.File) (blessMime (fileMimeType r.File)) + +fun main () = return +

The Amazing File Echoer!

+ +
Upload a file: +
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 -- cgit v1.2.3