view tests/blobOpt.ur @ 1892:907a82a44f01

Add missing inter-library dependencies This is needed, at least on recent Ubuntu, to fix these linker errors when compiling any Ur/Web application: liburweb.so: undefined reference to `lround' liburweb.so: undefined reference to `ceil' liburweb.so: undefined reference to `RAND_bytes' liburweb.so: undefined reference to `DES_fcrypt' liburweb.so: undefined reference to `SHA256_Init' liburweb.so: undefined reference to `SHA256_Final' liburweb.so: undefined reference to `SHA256_Update' Signed-off-by: Anders Kaseorg <andersk@mit.edu> --- src/c/Makefile.am | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
author Anders Kaseorg <andersk@mit.edu>
date Thu, 21 Nov 2013 14:32:11 -0500
parents cd67c3a942e3
children
line wrap: on
line source
sequence s
table t : { Id : int, Data : option blob, Typ : string }

fun view id =
    r <- oneRow (SELECT t.Data, t.Typ FROM t WHERE t.Id = {[id]});
    case r.T.Data of
        None => return <xml>This one's empty.</xml>
      | Some data => returnBlob data (blessMime r.T.Typ)

fun save r =
    id <- nextval s;
    dml (INSERT INTO t (Id, Data, Typ)
         VALUES ({[id]}, {[Some (fileData r.Data)]}, {[fileMimeType r.Data]}));
    main ()

and saveEmpty () =
    id <- nextval s;
    dml (INSERT INTO t (Id, Data, Typ)
         VALUES ({[id]}, {[None]}, "bogus"));
    main ()

and main () =
    ls <- queryX (SELECT t.Id FROM t)
          (fn r => <xml><li><a link={view r.T.Id}>{[r.T.Id]}</a></li></xml>);
    return <xml><body>
      {ls}

      <br/>

      <form>
        <upload{#Data}/>
        <submit action={save}/>
      </form>

      <form>
        <submit action={saveEmpty}/>
      </form>
    </body></xml>