diff --git a/web/CXM_making_a_web_site.anubis b/web/CXM_making_a_web_site.anubis index 5a149f9..aab9062 100644 --- a/web/CXM_making_a_web_site.anubis +++ b/web/CXM_making_a_web_site.anubis @@ -118,17 +118,17 @@ transmit calexium_lib/web/types/web_action_name.anubis The next picture shows the structure we have in mind: - request +---------+ HTML page (with a hidden state name) + request +---------+ HTML page (with state name in cookie) .-------------------| client |<--------------. | .-----------------| | | - | | previous state +---------+ | - | | name (if any) | + | | session +---------+ | + | | in cookie | | | | client side ............................................................................ | | | server side | | | | | .-------------------. | - | | | previous state | | + | | | previous session | | V V V | | +---------------+ +---------------+ +--------------+ | compute state | | server's disk | | compute page | @@ -327,65 +327,128 @@ public type WEB_Controller_Result: Var(List(WEB_Session_Field)) fields ), ajax( - HTTP_Answer http_answer - ), - ajax( - WEB_Session session, //modified session - HTTP_Answer http_answer //http answer - ), - ajax( - HTML_Partial_Content content, - String additional_script + Maybe(WEB_Session) mb_session, //modified session if success else failure + HTTP_Answer http_answer //http answer ), ajax( - WEB_Session session, //modified session + Maybe(WEB_Session) mb_session, //modified session if success else failure HTML_Partial_Content content, String additional_script ), ajax( - Printable_tree content, - String additional_script - ), - ajax( - WEB_Session session, //modified session + Maybe(WEB_Session) mb_session, //modified session if success else failure Printable_tree content, String additional_script ), send_file( String full_path //full path with file name of the file to send + ), + renderer_content( + Maybe(WEB_Session) mb_session, //modified session if success else failure + String title, + HTML_Partial_Content content, ) . public define WEB_Controller_Result ajax ( + HTTP_Answer http_answer + )= + ajax(failure, http_answer) +. + +public define WEB_Controller_Result + ajax + ( + WEB_Session session, //modified session + HTTP_Answer http_answer + )= + ajax(success(session), http_answer) +. + +public define WEB_Controller_Result + ajax + ( HTML_Partial_Content content )= - ajax(content, ""). + ajax(failure, content, ""). public define WEB_Controller_Result ajax ( + HTML_Partial_Content content, + String additional_script + )= + ajax(failure, content, additional_script). + +public define WEB_Controller_Result + ajax + ( WEB_Session session, //modified session HTML_Partial_Content content )= - ajax(session, content, ""). + ajax(success(session), content, ""). + +public define WEB_Controller_Result + ajax + ( + WEB_Session session, //modified session + HTML_Partial_Content content, + String additional_script + )= + ajax(success(session), content, additional_script). public define WEB_Controller_Result ajax ( Printable_tree content )= - ajax(content, ""). + ajax(failure, content, ""). public define WEB_Controller_Result ajax ( + Printable_tree content, + String additional_script + )= + ajax(failure, content, additional_script). + +public define WEB_Controller_Result + ajax + ( WEB_Session session, //modified session Printable_tree content )= - ajax(session, content, ""). + ajax(success(session), content, ""). +public define WEB_Controller_Result + ajax + ( + WEB_Session session, //modified session + Printable_tree content, + String additional_script + )= + ajax(success(session), content, additional_script). + +public define WEB_Controller_Result + renderer_content( + String title, + HTML_Partial_Content content, + )= + renderer_content(failure, title, content) +. + +public define WEB_Controller_Result + renderer_content( + WEB_Session session, //modified session if success else failure + String title, + HTML_Partial_Content content, + )= + renderer_content(success(session), title, content) +. + + public type WEB_Action_Allowed_Protocol: http, https, @@ -408,6 +471,14 @@ public type WEB_Controller: ) . +public type WEB_Page_Renderer: + web_page_renderer( + String name, //renderer name + (WEB_Session _session, String title, HTML_Partial_Content _content) -> HTTP_Answer page_layout //call back for rendering page + ) +. + + define List(HTTP_header) make_session_cookie_headers ( @@ -949,17 +1020,7 @@ public define InputAttrs public type I18n: lang (String), dir (Reading_Way). - -//public type DIV_Option: -// id (String), -// class (String), -// style (String), -// tooltip (String), -// lang (String), -// dir (Reading_Way), -// attr (String, String), -// event (HtmlEvents, String). -// + A list of 'DIV_Option' must be given with each DIV you want to put in your page. @@ -970,24 +1031,24 @@ define String event_name if e is { // Form element events - onchange then "onchange", - onsubmit then "onsubmit", + onchange then "onchange", + onsubmit then "onsubmit", onreset then "onreset", - onselect then "onselect", - onblur then "onblur", + onselect then "onselect", + onblur then "onblur", onfocus then "onfocus", // Keyboard events onkeydown then "onkeydown", - onkeypress then "onkeypress", + onkeypress then "onkeypress", onkeyup then "onkeyup", // Mouse events onclick then "onclick", - ondblclick then "ondblclick", - onmousedown then "onmousedown", - onmousemove then "onmousemove", + ondblclick then "ondblclick", + onmousedown then "onmousedown", + onmousemove then "onmousemove", onmouseout then "onmouseout", - onmouseover then "onmouseover", - onmouseup then "onmouseup" + onmouseover then "onmouseover", + onmouseup then "onmouseup" }. public type Table_Option: @@ -1029,13 +1090,13 @@ public type Cell_Option: base_line, // align the content vertically according to base lines background_color(RGB), background_image(String url, BackgroundOption), - width(Int), // sets a minimal width for the cell + width(Int), // sets a minimal width for the cell percentage_width(Int), - height(Int), // sets a minimal height for the cell - columns(Int), // lets the cell span over several columns - rows(Int), // lets the cell span over several rows + height(Int), // sets a minimal height for the cell + columns(Int), // lets the cell span over several columns + rows(Int), // lets the cell span over several rows nowrap, // do not allow text wrapping within the cell - style(String), // in case nothing above is suitable + style(String), // in case nothing above is suitable class(String class_name). A list of 'Cell_Option' must be given with each cell and each row in a table. Options @@ -1743,10 +1804,7 @@ public type HTML_Off_Form: literal (String), sequence (List(HTML_Off_Form) items), text (List(CoreAttrs), String the_text), - preformated (List(Text_Option), String), - paragraph (List(Text_Option), List(HTML_Off_Form) content), - image (List(CoreAttrs), String url, String alternate), - image (List(CoreAttrs), String url, String alternate, Int width, Int height), + preformated (List(Text_Option), String), table (List(Table_Option), HTML_Header_Row(HTML_Off_Form), List(HTML_Row(HTML_Off_Form)), HTML_Footer_Row(HTML_Off_Form)), center (HTML_Off_Form), mail_to (String email, HTML_Off_Form element), @@ -1772,34 +1830,24 @@ public type HTML_Off_Form: WEB_Action_Name action, List((String,String)) extra_ops, List(HTML_In_Form) content), in_form (HTML_Id form_id, HTML_In_Form content), - div (List(CoreAttrs), List(HTML_Off_Form) content), div (List(CoreAttrs), List(HTML_Partial_Content) p_content), - div_empty (List(CoreAttrs)), iframe (List(CoreAttrs), List(CSS_Style) /*styles*/, List(CSS_File) /*css_files*/, List(JS_File) /*js_files*/, HTML_Body /*body*/), partial (HTML_Partial_Content), - br, progress (List(CoreAttrs), Int value, Int max), - ol (List(CoreAttrs), List(HTML_Off_Form) content), - ul (List(CoreAttrs), List(HTML_Off_Form) content), - li (List(CoreAttrs), List(HTML_Off_Form) content), - button (List(CoreAttrs), List(HTML_Off_Form) content), i (List(CoreAttrs), String text), - span (List(CoreAttrs), String text), - strong (List(CoreAttrs), List(HTML_Off_Form) content), - hr (List(CoreAttrs)), - h1 (List(CoreAttrs), List(HTML_Off_Form) content), - h2 (List(CoreAttrs), List(HTML_Off_Form) content), - h3 (List(CoreAttrs), List(HTML_Off_Form) content), - h4 (List(CoreAttrs), List(HTML_Off_Form) content), - h5 (List(CoreAttrs), List(HTML_Off_Form) content), - h6 (List(CoreAttrs), List(HTML_Off_Form) content) + html_tag (String tag_name, List(CoreAttrs), List(HTML_Off_Form) content), + html_void_tag (String tag_name, List(CoreAttrs)) . 'HTML_Off_Form' defines all the elements you may put outside any form. + +public define HTML_Off_Form text(List(CoreAttrs) lto, Int i) = text(lto, to_decimal(i)). +public define HTML_Off_Form text(Int i) = text([], i). +public define HTML_Off_Form text(String s) = text([], s). public define HTML_Off_Form a(A_href _href) = a([], _href, _self, []). public define HTML_Off_Form a(List(CoreAttrs) attrs, A_href _href) = a(attrs, _href, _self, []). @@ -1808,38 +1856,149 @@ public define HTML_Off_Form a(List(CoreAttrs) attrs, A_href _href, List(HTML_Off public define HTML_Off_Form a(A_href _href, HTML_Off_Form content) = a([], _href, _self, [content]). public define HTML_Off_Form a(A_href _href, List(HTML_Off_Form) content) = a([], _href, _self, content). - -public define HTML_Off_Form strong(HTML_Off_Form content) = strong([], [content]). -public define HTML_Off_Form strong(List(HTML_Off_Form) content) = strong([], content). -public define HTML_Off_Form strong(List(CoreAttrs) attrs, HTML_Off_Form content) = strong(attrs, [content]). - -public define HTML_Off_Form h1(HTML_Off_Form content) = h1([], [content]). -public define HTML_Off_Form h1(List(HTML_Off_Form) content) = h1([], content). -public define HTML_Off_Form h1(List(CoreAttrs) attrs, HTML_Off_Form content) = h1(attrs, [content]). - -public define HTML_Off_Form h2(HTML_Off_Form content) = h2([], [content]). -public define HTML_Off_Form h2(List(HTML_Off_Form) content) = h2([], content). -public define HTML_Off_Form h2(List(CoreAttrs) attrs, HTML_Off_Form content) = h2(attrs, [content]). - -public define HTML_Off_Form h3(HTML_Off_Form content) = h3([], [content]). -public define HTML_Off_Form h3(List(HTML_Off_Form) content) = h3([], content). -public define HTML_Off_Form h3(List(CoreAttrs) attrs, HTML_Off_Form content) = h3(attrs, [content]). - -public define HTML_Off_Form h4(HTML_Off_Form content) = h4([], [content]). -public define HTML_Off_Form h4(List(HTML_Off_Form) content) = h4([], content). -public define HTML_Off_Form h4(List(CoreAttrs) attrs, HTML_Off_Form content) = h4(attrs, [content]). - -public define HTML_Off_Form h5(HTML_Off_Form content) = h5([], [content]). -public define HTML_Off_Form h5(List(HTML_Off_Form) content) = h5([], content). -public define HTML_Off_Form h5(List(CoreAttrs) attrs, HTML_Off_Form content) = h5(attrs, [content]). + //
+public define HTML_Off_Form article(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("article", attrs, content). +public define HTML_Off_Form article(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("article", attrs, [content]). +public define HTML_Off_Form article(List(HTML_Off_Form) content) = html_tag("article", [], content). +public define HTML_Off_Form article(HTML_Off_Form content) = html_tag("article", [], [content]). + + //