diff --git a/calexium_lib/web/CXM_dojo.anubis b/calexium_lib/web/CXM_dojo.anubis index a683a3c..cf588a3 100644 --- a/calexium_lib/web/CXM_dojo.anubis +++ b/calexium_lib/web/CXM_dojo.anubis @@ -20,6 +20,10 @@ read common/language_management.anubis read tools/mf_loggers.anubis read calexium_lib/net_services_protocols/logger_service.anubis read system/logger.anubis + +public type Dojo_Grid_Data : + grid_data(String). + public define HTML_Off_Form dojo_dialog ( @@ -48,7 +52,28 @@ public define HTML_Off_Form . - +public define HTML_Off_Form + dojo_grid + ( + String id, + String colum1, + String colum2, + String colum3, + String colum4, + ) + = + literal(" +
") +. public define HTML_Off_Form diff --git a/calexium_lib/web/CXM_making_a_web_site.anubis b/calexium_lib/web/CXM_making_a_web_site.anubis index 8ff95ca..a78edee 100644 --- a/calexium_lib/web/CXM_making_a_web_site.anubis +++ b/calexium_lib/web/CXM_making_a_web_site.anubis @@ -45,6 +45,7 @@ read tools/basis.anubis +read system/string.anubis read system/logger.anubis read CXM_common.anubis read CXM_multihost_http_server.anubis @@ -330,12 +331,12 @@ public type Web_Action($SessionTicket, $State): must be sent to the client. To that end, you must provide a function (named below 'compute_page') of type: - $State -> HTML_Page + $State -> HTTP_Answer - where the type 'HTML_Page' (defined below in this file) abstractly represents HTML + where the type 'HTTP_Answer' (defined below in this file) abstractly represents HTML pages. -public type HTML_Page:... +public type HTTP_Answer:... It should be clear that states and pages are deeply linked together. Indeed, we really understand the page shown to the client as a representation of the current state of the @@ -438,7 +439,7 @@ public define Web_Site List(Web_arg), Bool is_https) -> (Maybe($SessionTicket), Maybe($State), List(HTTP_header)) ticket_lost_state, List(Web_Action($SessionTicket, $State)) actions, - (Maybe($SessionTicket), Maybe($State), List(Web_arg) lwa) -> HTML_Page compute_page, + (Maybe($SessionTicket), Maybe($State), List(Web_arg) lwa) -> HTTP_Answer compute_page, Int timeout, // seconds (todo: minutes) List(Redirection) redirections, String charset, @@ -1460,15 +1461,21 @@ public type HTML_Body: body(List(Body_Option) options, HTML_Off_Form content). -public type HTML_Page: +public type HTTP_Answer: html_page(String title, List(HTML_Meta) meta_tags, List(CSS_Style) styles, List(CSS_File) css_files, List(JS_File) js_files, - HTML_Body body). - -public define HTML_Page + HTML_Body body), + plain_text (String text), + custom_text(String mime_type, + String content), + custom_binary(String mime_type, + ByteArray content), + http_raw(Printable_tree). + +public define HTTP_Answer html_page ( String title, @@ -1477,7 +1484,7 @@ public define HTML_Page ) = html_page(title,metas,[],[],[],body). -public define HTML_Page +public define HTTP_Answer html_page ( String title, @@ -1487,7 +1494,7 @@ public define HTML_Page ) = html_page(title, metas, styles, [], [], body). - 'HTML_Page' represents the final product of the construction of a web page. + 'HTTP_Answer' represents the final product of the construction of a web page. @@ -2176,11 +2183,12 @@ type CommonInfo: public define Printable_tree format ( - CommonInfo cinfo, - String state_name, - HTML_Page page, - Bool is_https, - String charset + CommonInfo cinfo, + String state_name, + List(HTTP_header) headers, + HTTP_Answer page, + Bool is_https, + String charset ). @@ -2215,7 +2223,7 @@ public define Web_Site List(Web_arg), Bool is_https) -> (Maybe($SessionTicket), Maybe($State), List(HTTP_header)) ticket_lost_state, List(Web_Action($SessionTicket, $State)) actions, - (Maybe($SessionTicket), Maybe($State), List(Web_arg) lwa) -> HTML_Page compute_page, + (Maybe($SessionTicket), Maybe($State), List(Web_arg) lwa) -> HTTP_Answer compute_page, Int timeout, Redirections redirections, String charset, @@ -2251,7 +2259,7 @@ public define Web_Site HTTP_Info http_info, List(Web_arg) lwa, Bool is_https) |-> - ((List(HTTP_header),Printable_tree)) + (Printable_tree) if separate_web_args(lwa) is { swa(mb_previous_state,mb_action_name,operands) then @@ -2288,12 +2296,12 @@ public define Web_Site }, if state_and_headers is (session_ticket, mb_new_state, headers) then with state_name = save_state(mb_new_state), - (headers, - format(info(host_name, http_port, https_port, site_directory, secret), - state_name, - compute_page(session_ticket, mb_new_state, operands), - is_https, - charset)) + format(info(host_name, http_port, https_port, site_directory, secret), + state_name, + headers, + compute_page(session_ticket, mb_new_state, operands), + is_https, + charset) }), // // make the delete_out_of_date function @@ -4229,7 +4237,8 @@ define Printable_tree ( CommonInfo cinfo, String state_name, - HTML_Page page, + List(HTTP_header) additional_headers, + HTTP_Answer page, Bool is_https, String charset ) = @@ -4239,38 +4248,69 @@ 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", - "\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", - "" - ] + with answer_body = + [ doctype_w3c_header, + "\n", + "\n", + add_css_styles(css_styles), + add_css_files(css_files), + add_js_files(js_files), + "\n", + "\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", + "" + ], + [ "HTTP/1.1 200 OK", crlf, + format_headers(standard_headers), + format_headers(standard_headers_for("text/html", length(answer_body), success(charset))), + format_headers(additional_headers), + crlf + . answer_body + ], + + plain_text (String text) then + [ "HTTP/1.1 200 OK", crlf, + format_headers(standard_headers), + format_headers(standard_headers_for("text/plain", length(text), success(charset))), + format_headers(additional_headers), + crlf, + text . (Printable_tree)[] + ], + + custom_text(String mime_type, String content) then + [ "HTTP/1.1 200 OK", crlf, + format_headers(standard_headers), + format_headers(standard_headers_for(mime_type, length(content), success(charset))), + format_headers(additional_headers), + crlf, + content . (Printable_tree)[] + ], + custom_binary(String mime_type, ByteArray content) then + [ "HTTP/1.1 200 OK", crlf, + format_headers(standard_headers), + format_headers(standard_headers_for(mime_type, length(content), failure)), + format_headers(additional_headers), + crlf, + content . (Printable_tree)[] + ], + + http_raw(Printable_tree content) then content }. - - - - - diff --git a/calexium_lib/web/CXM_multihost_http_server.anubis b/calexium_lib/web/CXM_multihost_http_server.anubis index ae5e690..988628a 100644 --- a/calexium_lib/web/CXM_multihost_http_server.anubis +++ b/calexium_lib/web/CXM_multihost_http_server.anubis @@ -204,8 +204,7 @@ public type Web_Site_Description: (String host_name, HTTP_Info http_info, List(Web_arg) lwa, - Bool is_https) -> (List(HTTP_header), - Printable_tree) awp_handler, + Bool is_https) -> (Printable_tree) awp_handler, (List(Web_arg) lwa) -> One before_send_file). The component 'common_names' is the list of names of the site, like for example @@ -1942,7 +1941,7 @@ define Maybe(String) This is the formating for sending to the client (hence, it has nothing to do with the component 'journal_headers' in the web site description). -define Printable_tree +public define Printable_tree format_headers ( List(HTTP_header) headers @@ -2232,7 +2231,7 @@ define One Standard headers are for answering ".awp" requests. -define List(HTTP_header) +public define List(HTTP_header) standard_headers = [ @@ -2240,16 +2239,16 @@ define List(HTTP_header) http_header("Server", "Anubis Embedded Server v" + major_version_number + "." + minor_version_number) ]. -define List(HTTP_header) - standard_headers_for_html +public define List(HTTP_header) + standard_headers_for ( - Int answer_body_size, - String charset + String mime_type, + Int answer_body_size, + Maybe(String) mb_charset, ) = [ - //http_header("Content-Type","text/html"), - http_header("Content-Type","text/html; charset="+charset), - http_header("Content-length",to_decimal(answer_body_size)) + http_header("Content-Type", mime_type + if mb_charset is success(charset) then "; charset="+charset else ""), + http_header("Content-length", to_decimal(answer_body_size)) ]. @@ -2281,14 +2280,7 @@ define One all_web_args, is_SSL(connection)), //print_delta("After page generation"); - if answer_headers_body is (additional_headers,answer_body) then - forget(reliable_write(connection, - [ "HTTP/1.1 200 OK", crlf, - format_headers(standard_headers), - format_headers(standard_headers_for_html(length(answer_body),charset(desc))), - format_headers(additional_headers), - crlf . - answer_body])) + forget(reliable_write(connection, answer_headers_body)) //print_delta("After sending page") ) else (send_file(desc, @@ -2738,13 +2730,7 @@ define One http_info(ip_addr,uri,headers,generate_tt), all_web_args, is_SSL(connection)), - if answer_headers_body is (additional_headers,answer_body) then - forget(reliable_write(connection, - [ "HTTP/1.1 200 OK",crlf, - format_headers(standard_headers_for_html(length(answer_body),charset(desc))), - format_headers(additional_headers), - crlf . - answer_body]))) + forget(reliable_write(connection, answer_headers_body))) else unique }. -- libgit2 0.21.4