From 3919c7c06c57c6d65edcbe44bd697a1f4b946ee3 Mon Sep 17 00:00:00 2001 From: yekolia Date: Thu, 23 Aug 2012 17:58:24 +0000 Subject: [PATCH] New : - web/CXM_jquery.anubis : Make start of jQuery support in Anubis --- calexium_lib/web/CXM_dojo.anubis | 25 ++++++++++++++++++++++++- calexium_lib/web/CXM_jquery.anubis | 36 ++++++++++++++++++++++++++++++++++++ calexium_lib/web/CXM_making_a_web_site.anubis | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- calexium_lib/web/CXM_multihost_http_server.anubis | 78 +++++++++++++++++++++++++++++++++++++++--------------------------------------- 4 files changed, 207 insertions(+), 43 deletions(-) create mode 100644 calexium_lib/web/CXM_jquery.anubis diff --git a/calexium_lib/web/CXM_dojo.anubis b/calexium_lib/web/CXM_dojo.anubis index 3c7ee13..329b8fc 100644 --- a/calexium_lib/web/CXM_dojo.anubis +++ b/calexium_lib/web/CXM_dojo.anubis @@ -805,5 +805,28 @@ public define Maybe(String) } } }. + +public define List(HTML_Head_Tag) + dojo_defaults + = + [ + // js(js_file("js/dojo/dojo.js", [attr("djConfig", "parseOnLoad: true, isDebug: " + (if debug_mode then "true" else "false") + ", usePlainJson: true")])), + js(js_file("js/dojo/dojo/dojo.js", [attr("djConfig", "parseOnLoad: true, isDebug: false, usePlainJson: true")])), + js(js_file("js/dojo/dijit/dijit.js")), + css(css_file("js/dojo/dojo/resources/dojo.css")) + ]. + - +public define List(HTML_Head_Tag) + dojo_init + ( + String web_dir, + String theme_name + ) + = + with theme_name = + if file_exists(web_dir+"js/dojo/dijit/themes/"+theme_name+"/"+theme_name+".css")then theme_name else "claro", + [ css(css_file("js/dojo/dijit/themes/"+theme_name+"/"+theme_name+".css")) . + [ css(css_file("js/dojo/dijit/themes/"+theme_name+"/"+theme_name+"_rtl.css")) . dojo_defaults ] + ] + . diff --git a/calexium_lib/web/CXM_jquery.anubis b/calexium_lib/web/CXM_jquery.anubis new file mode 100644 index 0000000..c23b708 --- /dev/null +++ b/calexium_lib/web/CXM_jquery.anubis @@ -0,0 +1,36 @@ +/* + * Created by PyramIDE. + * User: Jeremy + * Date: 21/08/2012 + * Time: 16:52 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +read calexium_lib/web/CXM_making_a_web_site.anubis +read tools/printable_tree.anubis +read tools/basis.anubis + +public define List(HTML_Head_Tag) + jquery_defaults + = + [ + js(js_file("js/jquery/jquery-1.8.0.min.js")), + js(js_file("js/jquery/jquery-ui-1.8.23.custom.min.js")), + ]. + +/* Initialize jQuery in compatiblity mode with jQueryUI */ +public define List(HTML_Head_Tag) + jquery_init + ( + String web_dir, + String theme_name + ) + = + if file_exists(web_dir+"/css/jquery/"+theme_name+"/jquery-ui-1.8.23.custom.css") then + [ css(css_file("css/jquery/"+theme_name+"/jquery-ui-1.8.23.custom.css")) . jquery_defaults ] + else + [ css(css_file(web_dir+"/css/jquery/redmond/jquery-ui-1.8.23.custom.css")) . jquery_defaults ] + . + + diff --git a/calexium_lib/web/CXM_making_a_web_site.anubis b/calexium_lib/web/CXM_making_a_web_site.anubis index 2fb9b36..3df0cd8 100644 --- a/calexium_lib/web/CXM_making_a_web_site.anubis +++ b/calexium_lib/web/CXM_making_a_web_site.anubis @@ -1020,6 +1020,30 @@ public define JS_File ) = js_file(file_name, []). +public type HTML_Meta:... + +public type HTML_Off_Form:... + +public type HTML_Head_Tag: + meta(HTML_Meta), + title(String), + js(JS_File), + js_inline(Script), + css(CSS_File), + css_inline(String css_styles) /* Note: tags are not necessaries */ + . + + /* It contains + * - a List of HTML_Head_Tag representing necessaries head tags for the content. ex: jquery js files, js script, css specific styles, ... + * - a HTML_Off_Form representing the HTML code for the part of the page we want to display + */ +public type HTML_Partial_Content: + partial_content + ( + List(HTML_Head_Tag), + HTML_Off_Form + ) + . public type HTML_In_Form: literal_pt (Printable_tree), @@ -1498,6 +1522,9 @@ public type HTML_Body: public type HTTP_Answer: html_page (HTTP_Status /*http_status*/, + List(HTML_Head_Tag) /*html tags*/, + HTML_Body /*body*/), + html_page (HTTP_Status /*http_status*/, String /*title*/, List(HTML_Meta) /*meta_tags*/, List(CSS_Style) /*styles*/, @@ -2228,7 +2255,7 @@ public define Printable_tree HTTP_Answer page, Bool is_https, String charset - ). + ). define Printable_tree @@ -4294,6 +4321,27 @@ define Printable_tree " />\n"], literal(s) then [s] }. + +define Printable_tree // c'est le nôtre et c'est meilleur + format + ( + HTML_Meta m, + ) = + if m is + { + keywords(l) then ["\n"], + refresh(co,ta,an,delay) then + [" "], // TODO + refresh(url,delay) then + ["\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] + }. define Printable_tree @@ -4311,9 +4359,53 @@ define Printable_tree "text/html; charset="+charset),is_https)], [h . t] then [format(cinfo,state_name,h,is_https) . format(cinfo,state_name,t,is_https,charset)] - }. - + }. + +define Printable_tree + _format_html_head + ( + List(HTML_Head_Tag) lwf, + Printable_tree so_far + ) + = + if lwf is + { + [] then reverse(so_far), + [ h . t] then + if h is + { + meta(meta) then + [format(meta) . _format_html_head(t, so_far)], + title(title) then + [""+title+"" . _format_html_head(t, so_far)], + js(jsf) then + ["" . _format_html_head(t, so_far)], + js_inline(jsi) then + ["" . _format_html_head(t, so_far)], + css(cssf) then + ["" . _format_html_head(t, so_far)], + css_inline(cssi) then + ["" . _format_html_head(t, so_far)] + } + } + . +public define Printable_tree + format_html_head + ( + List(HTML_Head_Tag) lwf, + String charset + ) + = + with lwf = (List(HTML_Head_Tag))[ meta(http_equiv("content-type", "text/html; charset="+charset)) . lwf], + if lwf is + { + [] then + [], + [ h . t] then + _format_html_head(lwf, []) + } + . define Printable_tree format @@ -4329,6 +4421,19 @@ define Printable_tree with ic_v = var((Int)0), if page is { + html_page(status, head_tags, body) then + if body is body(options,element) then + if format(status) is (status_string, status_headers) then + [doctype_w3c_header, + html_header, + + format_html_head(head_tags, charset), + + "", // format body options + format(cinfo,state_name,ic_v,element,is_https), + "\n", + + ""], html_page(status, title, metas, css_styles, css_files, js_files, script, body) then if body is body(options,element) then if format(status) is (status_string, status_headers) then diff --git a/calexium_lib/web/CXM_multihost_http_server.anubis b/calexium_lib/web/CXM_multihost_http_server.anubis index b3404b6..9ec144c 100644 --- a/calexium_lib/web/CXM_multihost_http_server.anubis +++ b/calexium_lib/web/CXM_multihost_http_server.anubis @@ -493,50 +493,50 @@ public define One *** (10) HTTP Errors public type HTTP_Status: - http_continue, - http_switching_protocol, + http_continue, // 100 + http_switching_protocol, // 101 - http_ok, - http_created, - http_accepted, - http_non_authoritative_info, - http_no_content, - http_reset_content, - http_partial_content, + http_ok, // 200 + http_created, // 201 + http_accepted, // 202 + http_non_authoritative_info, // 203 + http_no_content, // 204 + http_reset_content, // 205 + http_partial_content, // 206 http_multiple_choices, - http_moved_permanently(String location), - http_moved_temporarily(String location), - http_see_other(String location), - http_not_modified, - http_use_proxy(String location), - http_temporary_redirect(String location), + http_moved_permanently(String location), // 301 + http_moved_temporarily(String location), // 302 + http_see_other(String location), // 303 + http_not_modified, // 304 + http_use_proxy(String location), // 305 + http_temporary_redirect(String location), // 307 - http_bad_request, - http_unauthorized, - http_payment_required, - http_forbidden, - http_not_found, - http_method_not_allowed, - http_not_acceptable, - http_proxy_authentification_required, - http_request_timeout, - http_conflict, - http_gone, - http_length_required, - http_precondition_failed, - http_request_entity_too_large, - http_request_uri_too_long, - http_unsupported_media_type, - http_request_range_unsatisfiable, - http_expectation_failed, + http_bad_request, // 400 + http_unauthorized, // 401 + http_payment_required, // 402 + http_forbidden, // 403 + http_not_found, // 404 + http_method_not_allowed, // 405 + http_not_acceptable, // 406 + http_proxy_authentification_required, // 407 + http_request_timeout, // 408 + http_conflict, // 409 + http_gone, // 410 + http_length_required, // 411 + http_precondition_failed, // 412 + http_request_entity_too_large, // 413 + http_request_uri_too_long, // 414 + http_unsupported_media_type, // 415 + http_request_range_unsatisfiable, // 416 + http_expectation_failed, // 417 - http_internal_server_error, - http_not_implemented, - http_bad_gateway, - http_service_unavailable, - http_gateway_timeout, - http_version_not_supported, + http_internal_server_error, // 500 + http_not_implemented, // 501 + http_bad_gateway, // 502 + http_service_unavailable, // 503 + http_gateway_timeout, // 504 + http_version_not_supported, // 505 http_error(Int /*code*/, String /*message*/). -- libgit2 0.21.4