Commit 3919c7c06c57c6d65edcbe44bd697a1f4b946ee3

Authored by yekolia
1 parent af1c6a96

New :

- web/CXM_jquery.anubis : Make start of jQuery support in Anubis

Modifications:
  - web/CXM_making_a_web_site.anubis : Adding new types to handle Tag inclusion in head from some partial content construction => very useful when you need jQuery or other javascript Framework in some parts or web pages.
  - web/CXM_dojo.anubis : adding dojo_init to include JS and CSS files in head tag according to new type in web/CXM_making_a_web_site.anubis
calexium_lib/web/CXM_dojo.anubis
@@ -805,5 +805,28 @@ public define Maybe(String) @@ -805,5 +805,28 @@ public define Maybe(String)
805 } 805 }
806 } 806 }
807 }. 807 }.
  808 +
  809 +public define List(HTML_Head_Tag)
  810 + dojo_defaults
  811 + =
  812 + [
  813 + // js(js_file("js/dojo/dojo.js", [attr("djConfig", "parseOnLoad: true, isDebug: " + (if debug_mode then "true" else "false") + ", usePlainJson: true")])),
  814 + js(js_file("js/dojo/dojo/dojo.js", [attr("djConfig", "parseOnLoad: true, isDebug: false, usePlainJson: true")])),
  815 + js(js_file("js/dojo/dijit/dijit.js")),
  816 + css(css_file("js/dojo/dojo/resources/dojo.css"))
  817 + ].
  818 +
808 819
809 - 820 +public define List(HTML_Head_Tag)
  821 + dojo_init
  822 + (
  823 + String web_dir,
  824 + String theme_name
  825 + )
  826 + =
  827 + with theme_name =
  828 + if file_exists(web_dir+"js/dojo/dijit/themes/"+theme_name+"/"+theme_name+".css")then theme_name else "claro",
  829 + [ css(css_file("js/dojo/dijit/themes/"+theme_name+"/"+theme_name+".css")) .
  830 + [ css(css_file("js/dojo/dijit/themes/"+theme_name+"/"+theme_name+"_rtl.css")) . dojo_defaults ]
  831 + ]
  832 + .
calexium_lib/web/CXM_jquery.anubis 0 → 100644
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: Jeremy
  4 + * Date: 21/08/2012
  5 + * Time: 16:52
  6 + *
  7 + * To change this template use Tools | Options | Coding | Edit Standard Headers.
  8 + */
  9 +
  10 +read calexium_lib/web/CXM_making_a_web_site.anubis
  11 +read tools/printable_tree.anubis
  12 +read tools/basis.anubis
  13 +
  14 +public define List(HTML_Head_Tag)
  15 + jquery_defaults
  16 + =
  17 + [
  18 + js(js_file("js/jquery/jquery-1.8.0.min.js")),
  19 + js(js_file("js/jquery/jquery-ui-1.8.23.custom.min.js")),
  20 + ].
  21 +
  22 +/* Initialize jQuery in compatiblity mode with jQueryUI */
  23 +public define List(HTML_Head_Tag)
  24 + jquery_init
  25 + (
  26 + String web_dir,
  27 + String theme_name
  28 + )
  29 + =
  30 + if file_exists(web_dir+"/css/jquery/"+theme_name+"/jquery-ui-1.8.23.custom.css") then
  31 + [ css(css_file("css/jquery/"+theme_name+"/jquery-ui-1.8.23.custom.css")) . jquery_defaults ]
  32 + else
  33 + [ css(css_file(web_dir+"/css/jquery/redmond/jquery-ui-1.8.23.custom.css")) . jquery_defaults ]
  34 + .
  35 +
  36 +
calexium_lib/web/CXM_making_a_web_site.anubis
@@ -1020,6 +1020,30 @@ public define JS_File @@ -1020,6 +1020,30 @@ public define JS_File
1020 ) = 1020 ) =
1021 js_file(file_name, []). 1021 js_file(file_name, []).
1022 1022
  1023 +public type HTML_Meta:...
  1024 +
  1025 +public type HTML_Off_Form:...
  1026 +
  1027 +public type HTML_Head_Tag:
  1028 + meta(HTML_Meta),
  1029 + title(String),
  1030 + js(JS_File),
  1031 + js_inline(Script),
  1032 + css(CSS_File),
  1033 + css_inline(String css_styles) /* Note: <style> and </style> tags are not necessaries */
  1034 + .
  1035 +
  1036 + /* It contains
  1037 + * - a List of HTML_Head_Tag representing necessaries head tags for the content. ex: jquery js files, js script, css specific styles, ...
  1038 + * - a HTML_Off_Form representing the HTML code for the part of the page we want to display
  1039 + */
  1040 +public type HTML_Partial_Content:
  1041 + partial_content
  1042 + (
  1043 + List(HTML_Head_Tag),
  1044 + HTML_Off_Form
  1045 + )
  1046 + .
1023 1047
1024 public type HTML_In_Form: 1048 public type HTML_In_Form:
1025 literal_pt (Printable_tree), 1049 literal_pt (Printable_tree),
@@ -1498,6 +1522,9 @@ public type HTML_Body: @@ -1498,6 +1522,9 @@ public type HTML_Body:
1498 1522
1499 public type HTTP_Answer: 1523 public type HTTP_Answer:
1500 html_page (HTTP_Status /*http_status*/, 1524 html_page (HTTP_Status /*http_status*/,
  1525 + List(HTML_Head_Tag) /*html <head> tags*/,
  1526 + HTML_Body /*body*/),
  1527 + html_page (HTTP_Status /*http_status*/,
1501 String /*title*/, 1528 String /*title*/,
1502 List(HTML_Meta) /*meta_tags*/, 1529 List(HTML_Meta) /*meta_tags*/,
1503 List(CSS_Style) /*styles*/, 1530 List(CSS_Style) /*styles*/,
@@ -2228,7 +2255,7 @@ public define Printable_tree @@ -2228,7 +2255,7 @@ public define Printable_tree
2228 HTTP_Answer page, 2255 HTTP_Answer page,
2229 Bool is_https, 2256 Bool is_https,
2230 String charset 2257 String charset
2231 - ). 2258 + ).
2232 2259
2233 2260
2234 define Printable_tree 2261 define Printable_tree
@@ -4294,6 +4321,27 @@ define Printable_tree @@ -4294,6 +4321,27 @@ define Printable_tree
4294 " />\n"], 4321 " />\n"],
4295 literal(s) then [s] 4322 literal(s) then [s]
4296 }. 4323 }.
  4324 +
  4325 +define Printable_tree // c'est le nôtre et c'est meilleur
  4326 + format
  4327 + (
  4328 + HTML_Meta m,
  4329 + ) =
  4330 + if m is
  4331 + {
  4332 + keywords(l) then ["<meta name=\"keywords\" content=\"",format_keywords(l),"\" />\n"],
  4333 + refresh(co,ta,an,delay) then
  4334 + ["<!-- TODO refresh(co,ta,an,delay) --> "], // TODO
  4335 + refresh(url,delay) then
  4336 + ["<meta http-equiv=\"Refresh\" content=\"",delay,"; URL=",url,"\" />\n"],
  4337 + meta(n,c) then ["<meta name=\"",n,"\" content=\"",c,"\" />\n"],
  4338 + http_equiv(n,c) then ["<meta http-equiv=\"",n,"\" content=\"",c,"\" />\n"],
  4339 + generic_meta(l) then ["<meta ",
  4340 + flat(map(((String,String) p) |-> if p is (n,v) then [n,"=\"",v,"\" "],
  4341 + l)),
  4342 + " />\n"],
  4343 + literal(s) then [s]
  4344 + }.
4297 4345
4298 4346
4299 define Printable_tree 4347 define Printable_tree
@@ -4311,9 +4359,53 @@ define Printable_tree @@ -4311,9 +4359,53 @@ define Printable_tree
4311 "text/html; charset="+charset),is_https)], 4359 "text/html; charset="+charset),is_https)],
4312 [h . t] then [format(cinfo,state_name,h,is_https) 4360 [h . t] then [format(cinfo,state_name,h,is_https)
4313 . format(cinfo,state_name,t,is_https,charset)] 4361 . format(cinfo,state_name,t,is_https,charset)]
4314 - }.  
4315 - 4362 + }.
  4363 +
  4364 +define Printable_tree
  4365 + _format_html_head
  4366 + (
  4367 + List(HTML_Head_Tag) lwf,
  4368 + Printable_tree so_far
  4369 + )
  4370 + =
  4371 + if lwf is
  4372 + {
  4373 + [] then reverse(so_far),
  4374 + [ h . t] then
  4375 + if h is
  4376 + {
  4377 + meta(meta) then
  4378 + [format(meta) . _format_html_head(t, so_far)],
  4379 + title(title) then
  4380 + ["<title>"+title+"</title>" . _format_html_head(t, so_far)],
  4381 + js(jsf) then
  4382 + ["<script src=\""+file_name(jsf)+"\"></script>" . _format_html_head(t, so_far)],
  4383 + js_inline(jsi) then
  4384 + ["<script>"+content(jsi)+"</script>" . _format_html_head(t, so_far)],
  4385 + css(cssf) then
  4386 + ["<link rel=\"stylesheet\" type=\"text/css\" href=\""+file_name(cssf)+"\">" . _format_html_head(t, so_far)],
  4387 + css_inline(cssi) then
  4388 + ["<style>"+cssi+"</style>" . _format_html_head(t, so_far)]
  4389 + }
  4390 + }
  4391 + .
4316 4392
  4393 +public define Printable_tree
  4394 + format_html_head
  4395 + (
  4396 + List(HTML_Head_Tag) lwf,
  4397 + String charset
  4398 + )
  4399 + =
  4400 + with lwf = (List(HTML_Head_Tag))[ meta(http_equiv("content-type", "text/html; charset="+charset)) . lwf],
  4401 + if lwf is
  4402 + {
  4403 + [] then
  4404 + [],
  4405 + [ h . t] then
  4406 + _format_html_head(lwf, [])
  4407 + }
  4408 + .
4317 4409
4318 define Printable_tree 4410 define Printable_tree
4319 format 4411 format
@@ -4329,6 +4421,19 @@ define Printable_tree @@ -4329,6 +4421,19 @@ define Printable_tree
4329 with ic_v = var((Int)0), 4421 with ic_v = var((Int)0),
4330 if page is 4422 if page is
4331 { 4423 {
  4424 + html_page(status, head_tags, body) then
  4425 + if body is body(options,element) then
  4426 + if format(status) is (status_string, status_headers) then
  4427 + [doctype_w3c_header,
  4428 + html_header,
  4429 +
  4430 + format_html_head(head_tags, charset),
  4431 +
  4432 + "<body ", format(options), ">", // format body options
  4433 + format(cinfo,state_name,ic_v,element,is_https),
  4434 + "</body>\n",
  4435 +
  4436 + "</html>"],
4332 html_page(status, title, metas, css_styles, css_files, js_files, script, body) then 4437 html_page(status, title, metas, css_styles, css_files, js_files, script, body) then
4333 if body is body(options,element) then 4438 if body is body(options,element) then
4334 if format(status) is (status_string, status_headers) then 4439 if format(status) is (status_string, status_headers) then
calexium_lib/web/CXM_multihost_http_server.anubis
@@ -493,50 +493,50 @@ public define One @@ -493,50 +493,50 @@ public define One
493 *** (10) HTTP Errors 493 *** (10) HTTP Errors
494 494
495 public type HTTP_Status: 495 public type HTTP_Status:
496 - http_continue,  
497 - http_switching_protocol, 496 + http_continue, // 100
  497 + http_switching_protocol, // 101
498 498
499 - http_ok,  
500 - http_created,  
501 - http_accepted,  
502 - http_non_authoritative_info,  
503 - http_no_content,  
504 - http_reset_content,  
505 - http_partial_content, 499 + http_ok, // 200
  500 + http_created, // 201
  501 + http_accepted, // 202
  502 + http_non_authoritative_info, // 203
  503 + http_no_content, // 204
  504 + http_reset_content, // 205
  505 + http_partial_content, // 206
506 506
507 http_multiple_choices, 507 http_multiple_choices,
508 - http_moved_permanently(String location),  
509 - http_moved_temporarily(String location),  
510 - http_see_other(String location),  
511 - http_not_modified,  
512 - http_use_proxy(String location),  
513 - http_temporary_redirect(String location), 508 + http_moved_permanently(String location), // 301
  509 + http_moved_temporarily(String location), // 302
  510 + http_see_other(String location), // 303
  511 + http_not_modified, // 304
  512 + http_use_proxy(String location), // 305
  513 + http_temporary_redirect(String location), // 307
514 514
515 - http_bad_request,  
516 - http_unauthorized,  
517 - http_payment_required,  
518 - http_forbidden,  
519 - http_not_found,  
520 - http_method_not_allowed,  
521 - http_not_acceptable,  
522 - http_proxy_authentification_required,  
523 - http_request_timeout,  
524 - http_conflict,  
525 - http_gone,  
526 - http_length_required,  
527 - http_precondition_failed,  
528 - http_request_entity_too_large,  
529 - http_request_uri_too_long,  
530 - http_unsupported_media_type,  
531 - http_request_range_unsatisfiable,  
532 - http_expectation_failed, 515 + http_bad_request, // 400
  516 + http_unauthorized, // 401
  517 + http_payment_required, // 402
  518 + http_forbidden, // 403
  519 + http_not_found, // 404
  520 + http_method_not_allowed, // 405
  521 + http_not_acceptable, // 406
  522 + http_proxy_authentification_required, // 407
  523 + http_request_timeout, // 408
  524 + http_conflict, // 409
  525 + http_gone, // 410
  526 + http_length_required, // 411
  527 + http_precondition_failed, // 412
  528 + http_request_entity_too_large, // 413
  529 + http_request_uri_too_long, // 414
  530 + http_unsupported_media_type, // 415
  531 + http_request_range_unsatisfiable, // 416
  532 + http_expectation_failed, // 417
533 533
534 - http_internal_server_error,  
535 - http_not_implemented,  
536 - http_bad_gateway,  
537 - http_service_unavailable,  
538 - http_gateway_timeout,  
539 - http_version_not_supported, 534 + http_internal_server_error, // 500
  535 + http_not_implemented, // 501
  536 + http_bad_gateway, // 502
  537 + http_service_unavailable, // 503
  538 + http_gateway_timeout, // 504
  539 + http_version_not_supported, // 505
540 540
541 http_error(Int /*code*/, String /*message*/). 541 http_error(Int /*code*/, String /*message*/).
542 542