annotate demo/cookie.ur @ 1739:c414850f206f

Add support for -boot flag, which allows in-tree execution of Ur/Web The boot flag rewrites most hardcoded paths to point to the build directory, and also forces static compilation. This is convenient for developing Ur/Web, or if you cannot 'sudo make install' Ur/Web. The following changes were made: * Header files were moved to include/urweb instead of include; this lets FFI users point their C_INCLUDE_PATH at this directory at write <urweb/urweb.h>. For internal Ur/Web executables, we simply pass -I$PATH/include/urweb as normal. * Differentiate between LIB and SRCLIB; SRCLIB is Ur and JavaScript source files, while LIB is compiled products from libtool. For in-tree compilation these live in different places. * No longer reference Config for paths; instead use Settings; these settings can be changed dynamically by Compiler.enableBoot () (TODO: add a disableBoot function.) * config.h is now generated directly in include/urweb/config.h, for consistency's sake (especially since it gets installed along with the rest of the headers!) * All of the autotools build products got updated. * The linkStatic field in protocols now only contains the name of the build product, and not the absolute path. Future users have to be careful not to reference the Settings files to early, lest they get an old version (this was the source of two bugs during development of this patch.)
author Edward Z. Yang <ezyang@mit.edu>
date Wed, 02 May 2012 17:17:57 -0400
parents 93315ac00394
children
rev   line source
adamc@464 1 cookie c : {A : string, B : float, C : int}
adamc@464 2
adamc@464 3 fun set r =
adamc@1050 4 setCookie c {Value = {A = r.A, B = readError r.B, C = readError r.C},
adamc@1050 5 Expires = None,
adamc@1050 6 Secure = False};
adamc@464 7 return <xml>Cookie set.</xml>
adamc@464 8
adamc@1050 9 fun setExp r =
adamc@1050 10 setCookie c {Value = {A = r.A, B = readError r.B, C = readError r.C},
adamc@1050 11 Expires = Some (readError "2012-11-6 00:00:00"),
adamc@1050 12 Secure = False};
adamc@1050 13 return <xml>Cookie set robustly.</xml>
adamc@1050 14
adamc@1050 15 fun delete () =
adamc@1050 16 clearCookie c;
adamc@1050 17 return <xml>Cookie cleared.</xml>
adamc@1050 18
adamc@464 19 fun main () =
adamc@464 20 ro <- getCookie c;
adamc@465 21 return <xml><body>
adamc@465 22 {case ro of
adamc@465 23 None => <xml>No cookie set.</xml>
adamc@1050 24 | Some v => <xml>
adamc@1050 25 Cookie: A = {[v.A]}, B = {[v.B]}, C = {[v.C]}<br/>
adamc@1050 26 <form><submit value="Delete" action={delete}/></form>
adamc@1050 27 </xml>}
adamc@465 28 <br/><br/>
adamc@464 29
adamc@465 30 <form>
adamc@465 31 A: <textbox{#A}/><br/>
adamc@465 32 B: <textbox{#B}/><br/>
adamc@465 33 C: <textbox{#C}/><br/>
adamc@465 34 <submit action={set}/>
adamc@1050 35 </form><br/>
adamc@1050 36
adamc@1050 37 <form>
adamc@1050 38 <b>Version that expires on November 6, 2012:</b><br/>
adamc@1050 39 A: <textbox{#A}/><br/>
adamc@1050 40 B: <textbox{#B}/><br/>
adamc@1050 41 C: <textbox{#C}/><br/>
adamc@1050 42 <submit action={setExp}/>
adamc@465 43 </form>
adamc@465 44 </body></xml>