diff --git a/calexium_lib/web/CXM_common.anubis b/calexium_lib/web/CXM_common.anubis index e97e460..9226de8 100644 --- a/calexium_lib/web/CXM_common.anubis +++ b/calexium_lib/web/CXM_common.anubis @@ -1,167 +1,189 @@ - - *Project* The Anubis Project - *Title* Some common stuff for the web. - - *Copyright* Copyright (c) Alain Prouté 2003. - - - - *Author* Alain Prouté - - *Public* - *Name* HTTP_header - *Description* - The type 'HTTP_header' describes HTTP headers, which are just pairs '(name,value)'. - -public type HTTP_header: - http_header(String name, - String value). - - *Name* Web_arg - *Description* - - The type 'Web_arg' describes 'web arguments'. A web argument is either a pair - '(name,value)' (for example it may be 'web_arg("password","foobar")', if the client - clicks on the submit button of a form containing a password input field named - 'password'), or an uploaded file. In this last case, it is a triplet containing the - name of the file upload input field, the value of this input field (name of the - uploaded file), and the name of the temporary file as saved by the server in its - 'upload temporary directory'; see 'web/http_server.anubis' and the 'upload' Web_item in - 'web/html.anubis'). - -public type Web_arg: - web_arg(String name, - String value), - upload (String name, // name of corresponding 'upload' Web_item - String value, // name of uploaded file - String temp_file_path). // temporary file path (relative to server directory) - - - *Name* Web_arg_value - *Description* - Of course, within the body of a 'web page' operation, you may want to recover the value - of a particular web argument. To that end, use the operation 'web_arg_value', which - takes 2 argument: - - - the list of all web arguments (the operand of the web page operation), - - the name of the argument whose value is wanted. - - This operation has the following return type: - -public type Web_arg_value: - not_found, - found(String value). - - *Name* Web_arg_value - *Description* - If the requested argument name is not found in the list, 'not_found' is - returned. Otherwise, the value returned by 'web_arg_value' has the form 'found(v)', - where 'v' is the value of the argument. - - The operation 'web_arg_value' is defined below. - -public define Web_arg_value - web_arg_value - ( - List(Web_arg) l, - String name - ) = - if l is - { - [ ] then not_found, - [h . t] then if h is - { - web_arg(n,v) then - if name=n - then found(v) - else web_arg_value(t,name), - - upload(n,v,tfn) then - if name=n - then found(v) - else web_arg_value(t,name) - } - }. - - *Ignore* - -public define Maybe((String,String)) - file_upload_value - ( - List(Web_arg) l, - String name - ) = - if l is - { - [ ] then failure, - [h . t] then if h is - { - web_arg(_,_) then file_upload_value(t,name), - upload(n,v,tfn) then - if n = name - then success((v,tfn)) - else file_upload_value(t,name) - } - }. - -public type Redirection: - redirect(String required_uri, // URI required by the client - String required_host, // value of 'Host' HTTP header sent by the client - String corresponding_uri). // URI which will be served to the client - - - - - Now, you may also want to recover web argument values which have been encoded (by - 'web_arg_encode'). In this case, use the following: - -read CXM_web_arg_encode.anubis - - -public define Maybe($T) - decode_web_arg_value - ( - List(Web_arg) l, - String name - ) = - if web_arg_value(l,name) is - { - not_found then failure, - found(v) then web_arg_decode(v) - }. - -public define List(String) - web_arg_list_values - ( - List(Web_arg) l, - String name - ) = - if l is - { - [] then [], - [h . t] then - if h is web_arg(n, v) then - if n = name then - [ v . web_arg_list_values(t, name)] - else - web_arg_list_values(t, name) - else - web_arg_list_values(t, name) - - } - . - -public define String - dump_web_arg_values - ( - List(Web_arg) l, - ) = - if l is - { - [ ] then "\n", - [h . t] then if h is - { - web_arg(n,v) then "\n["+n+"] = '"+v+"'" + dump_web_arg_values(t), - upload(n,v,tfn) then "\n["+n+"] = '"+v+"'" + dump_web_arg_values(t) - } - }. + + *Project* The Anubis Project + *Title* Some common stuff for the web. + + *Copyright* Copyright (c) Alain Prouté 2003. + + + + *Author* Alain Prouté + + *Public* + *Name* HTTP_header + *Description* + +read system/String.anubis + +/** + * The type 'HTTP_header' describes HTTP headers, which are just pairs '(name,value)'. + */ +public type HTTP_header: + http_header(String name, + String value). + + +public define Maybe(String) + http_header_value + ( + List(HTTP_header) l, + String name + ) = + if l is + { + [ ] then failure, + [h . t] then if h is + { + http_header(n, v) then //print("DEBUG: http_header_value --> HEADER = " + n + ":" + v + "\n"); + if insensitive_equal(name, n) then success(v) + else http_header_value(t, name), + } + }. + + *Name* Web_arg + *Description* + + The type 'Web_arg' describes 'web arguments'. A web argument is either a pair + '(name,value)' (for example it may be 'web_arg("password","foobar")', if the client + clicks on the submit button of a form containing a password input field named + 'password'), or an uploaded file. In this last case, it is a triplet containing the + name of the file upload input field, the value of this input field (name of the + uploaded file), and the name of the temporary file as saved by the server in its + 'upload temporary directory'; see 'web/http_server.anubis' and the 'upload' Web_item in + 'web/html.anubis'). + +public type Web_arg: + web_arg(String name, + String value), + upload (String name, // name of corresponding 'upload' Web_item + String value, // name of uploaded file + String temp_file_path). // temporary file path (relative to server directory) + + + *Name* Web_arg_value + *Description* + Of course, within the body of a 'web page' operation, you may want to recover the value + of a particular web argument. To that end, use the operation 'web_arg_value', which + takes 2 argument: + + - the list of all web arguments (the operand of the web page operation), + - the name of the argument whose value is wanted. + + This operation has the following return type: + +public type Web_arg_value: + not_found, + found(String value). + + *Name* Web_arg_value + *Description* + If the requested argument name is not found in the list, 'not_found' is + returned. Otherwise, the value returned by 'web_arg_value' has the form 'found(v)', + where 'v' is the value of the argument. + + The operation 'web_arg_value' is defined below. + +public define Web_arg_value + web_arg_value + ( + List(Web_arg) l, + String name + ) = + if l is + { + [ ] then not_found, + [h . t] then if h is + { + web_arg(n,v) then + if name=n + then found(v) + else web_arg_value(t,name), + + upload(n,v,tfn) then + if name=n + then found(v) + else web_arg_value(t,name) + } + }. + + *Ignore* + +public define Maybe((String,String)) + file_upload_value + ( + List(Web_arg) l, + String name + ) = + if l is + { + [ ] then failure, + [h . t] then if h is + { + web_arg(_,_) then file_upload_value(t,name), + upload(n,v,tfn) then + if n = name + then success((v,tfn)) + else file_upload_value(t,name) + } + }. + +public type Redirection: + redirect(String required_uri, // URI required by the client + String required_host, // value of 'Host' HTTP header sent by the client + String corresponding_uri). // URI which will be served to the client + + + + + Now, you may also want to recover web argument values which have been encoded (by + 'web_arg_encode'). In this case, use the following: + +read CXM_web_arg_encode.anubis + + +public define Maybe($T) + decode_web_arg_value + ( + List(Web_arg) l, + String name + ) = + if web_arg_value(l,name) is + { + not_found then failure, + found(v) then web_arg_decode(v) + }. + +public define List(String) + web_arg_list_values + ( + List(Web_arg) l, + String name + ) = + if l is + { + [] then [], + [h . t] then + if h is web_arg(n, v) then + if n = name then + [ v . web_arg_list_values(t, name)] + else + web_arg_list_values(t, name) + else + web_arg_list_values(t, name) + + } + . + +public define String + dump_web_arg_values + ( + List(Web_arg) l, + ) = + if l is + { + [ ] then "\n", + [h . t] then if h is + { + web_arg(n,v) then "\n["+n+"] = '"+v+"'" + dump_web_arg_values(t), + upload(n,v,tfn) then "\n["+n+"] = '"+v+"'" + dump_web_arg_values(t) + } + }. diff --git a/calexium_lib/web/CXM_making_a_web_site.anubis b/calexium_lib/web/CXM_making_a_web_site.anubis index 047b354..3bf0d49 100644 --- a/calexium_lib/web/CXM_making_a_web_site.anubis +++ b/calexium_lib/web/CXM_making_a_web_site.anubis @@ -1463,8 +1463,8 @@ public define HTML_Page public define String doctype_w3c_header = - "\n". + "\n". @@ -2823,7 +2823,7 @@ define Printable_tree ( List(DIV_Option) options )= - [""] . + [""] . define Printable_tree @@ -3407,7 +3407,7 @@ define Printable_tree ["
",s,"
"], //["
",s,"
"], any_paragraph(opts,t) then - ["

",t,"

"], + ["

",t,"

\n"], any_image(url) then ["\"",url,"\""], any_image(url,w,h) then @@ -3415,7 +3415,7 @@ define Printable_tree any_table(opts,h_row, rows) then ["", format(h_row,format_element), - format(rows,format_element),"
"], + format(rows,format_element),"\n"], any_center(e) then ["
",format_element(e),"
"], any_mail_to(email,elem) then @@ -3442,9 +3442,9 @@ define Printable_tree any_private_download(url,name,extra_ext,action) then format_private_download(cinfo,sn,url,name,extra_ext,action), any_div(options, e) then - [format_div_option(options), format_element(e),""], + [format_div_option(options), format_element(e),"\n"], any_div_empty(options) then - [format_div_option(options), ""], + [format_div_option(options), "\n"], any_coreattrs(attributs) then [format_coreattrs(attributs)] }. @@ -3723,16 +3723,16 @@ define Printable_tree ) = if m is { - keywords(l) then [""], + keywords(l) then ["\n"], refresh(co,ta,an,delay) then [""], - meta(n,c) then [""], - http_equiv(n,c) then [""], + make_actioner_url(cinfo,co,ta,state_name,an,[],is_https),"\">\n"], + meta(n,c) then ["\n"], + http_equiv(n,c) then ["\n"], generic_meta(l) then [" if p is (n,v) then [n,"=\"",v,"\" "], l)), - ">"], + ">\n"], literal(s) then [s] }. @@ -3790,7 +3790,7 @@ define Printable_tree { [ ] then [ ], [h . t] then - [ ["\n" ] + [ ["\n" ] . add_css_files(t)] }. @@ -3818,7 +3818,7 @@ define Printable_tree [] then [], [_._] then [ "" + " -->\n" ] }. @@ -3838,12 +3838,12 @@ define Printable_tree html_page(title,metas,css_styles, css_files, js_files, body) then if body is body(options,element) then [ doctype_w3c_header, - "", - "", + "\n", + "\n", add_css_styles(css_styles), add_css_files(css_files), add_js_files(js_files), - "", + "\n", "", - "",title,"", // put title + "\n", + "",title,"\n", // put title format(cinfo,state_name,metas,is_https,charset), // format the metas - "", + "\n", "", // format body options //"
", format(cinfo,state_name,ic_v,element,is_https), //"
", - "", + "\n", "" ] }. -- libgit2 0.21.4