diff --git a/web/CXM_form.anubis b/web/CXM_form.anubis index fa478bd..03ffb1e 100644 --- a/web/CXM_form.anubis +++ b/web/CXM_form.anubis @@ -67,14 +67,14 @@ public type CXM_Form_Field: //--- text area field ----------------------------------------------------------------- text_area( - List(TextAreaOption) options, - HTML_Label label, - HTML_Id id, - WebArgName web_arg_name, - InitialValue init_value, - Width width, - Int height, - Mandatory mandatory + List(TextAreaOption) options, + HTML_Label label, + HTML_Id id, + WebArgName web_arg_name, + InitialValue init_value, + Width width, + Int height, + Mandatory mandatory ), //--- password input field ------------------------------------------------------------ @@ -87,6 +87,28 @@ public type CXM_Form_Field: Width width, Mandatory mandatory), + //--- phone field ------------------------------------------------------------ + phone_input( + List(CoreAttrs) icon_options, + List(CoreAttrs) options, + HTML_Label label, + HTML_Id id, + WebArgName web_arg_name, + InitialValue init_value, + Width width, + Mandatory mandatory), + + //--- phone field ------------------------------------------------------------ + email_input( + List(CoreAttrs) icon_options, + List(CoreAttrs) options, + HTML_Label label, + HTML_Id id, + WebArgName web_arg_name, + InitialValue init_value, + Width width, + Mandatory mandatory), + //--- hidden field ------------------------------------------------------------ hidden( HTML_Id id, @@ -489,7 +511,19 @@ public define HTML_In_Form password_input(options, _label, id, name, init, w, mand) then password_input([class("in") . options], star(_label, mand), id, name, init, pixels(w)), - + + phone_input(icon_options, options, _label, id, wan, default, w, mand) then + sequence([ + image(icon_options, "/icons/16x16/phone.png", ""), + text_input([class("in") . options], star(_label, mand), id, wan, init(get_String(lwa, wan.name, default.value)), pixels(w)), + ]), + + email_input(icon_options, options, _label, id, wan, default, w, mand) then + sequence([ + image(icon_options, "/icons/16x16/email_edit.png", ""), + text_input([class("in") . options], star(_label, mand), id, wan, init(get_String(lwa, wan.name, default.value)), pixels(w)), + ]) + hidden(id, name, init) then hidden(id, name, init), @@ -707,7 +741,7 @@ public define HTML_In_Form )= to_HTML_In_Form(fields, [], _class, b_with_label). -public + public define HTML_Off_Form cxm_form diff --git a/web/CXM_making_a_web_site.anubis b/web/CXM_making_a_web_site.anubis index 54725eb..3cf5a77 100644 --- a/web/CXM_making_a_web_site.anubis +++ b/web/CXM_making_a_web_site.anubis @@ -328,6 +328,10 @@ public type WEB_Controller_Result: ), ajax( HTTP_Answer http_answer + ), + ajax( + WEB_Session session, //modified session + HTTP_Answer http_answer //http answer ) . @@ -759,30 +763,7 @@ public type HTML_Size: percentage(Int). -public type Text_Option: - size(Int), // size of character font to use - font(String), // name of character font to use (such as "helvetica",...) - color(RGB), // color to be used for characters - italic, - oblique, - small_capitals, - bold, - underlined, - left_justified, - right_justified, - justified, // justified on both sides - line_through, - nowrap, - class(String), //CSS class - id(String), - style(String), - title(String), - attr(String, String). - -public define Text_Option - tooltip(String s) = title(s). - - A list of 'Text_Option' must be given with each text you want to put in your page. + This indicate the way of reading text. public type Reading_Way: @@ -882,11 +863,38 @@ public type InputAttrs: public define InputAttrs attr(String name, Bool value) = attr(name, if value then "true" else "false"). +public type Text_Option: + core_attrs(List(CoreAttrs)), + size(Int), // size of character font to use + font(String), // name of character font to use (such as "helvetica",...) + color(RGB), // color to be used for characters + italic, + oblique, + small_capitals, + bold, + underlined, + left_justified, + right_justified, + justified, // justified on both sides + line_through, + nowrap, + class(String), //CSS class + id(String), + style(String), + title(String), + attr(String, String). + +public define Text_Option + tooltip(String s) = title(s). + + A list of 'Text_Option' must be given with each text you want to put in your page. + public define CoreAttrs tooltip(String s) = title(s). public define InputAttrs tooltip(String s) = title(s). + public type I18n: lang (String), dir (Reading_Way). @@ -1339,9 +1347,9 @@ public type HTML_In_Form: literal_pt (Printable_tree), literal (String), sequence (List(HTML_In_Form) items), - text (List(Text_Option), String the_text), + text (List(CoreAttrs), String the_text), preformated (List(Text_Option), String), - paragraph (List(Text_Option), HTML_In_Form content), + paragraph (List(Text_Option), List(HTML_In_Form) content), image (List(CoreAttrs), String url, String alternate), image (List(CoreAttrs), String url, String alternate, Int width, Int height), table (List(Table_Option), HTML_Header_Row(HTML_In_Form), List(HTML_Row(HTML_In_Form)), HTML_Footer_Row(HTML_In_Form)), @@ -1374,16 +1382,16 @@ public type HTML_In_Form: radio_button_r (List(CoreAttrs), HTML_Label label, HTML_Id id, WebArgName name, WebArgValue value, Bool checked), check_box (List(CoreAttrs), HTML_Label label, HTML_Id id, WebArgName name, WebArgValue value, Bool checked), check_box_r (List(CoreAttrs), HTML_Label label, HTML_Id id, WebArgName name, WebArgValue value, Bool checked), - div (List(CoreAttrs), HTML_In_Form content), + div (List(CoreAttrs), List(HTML_In_Form) content), div_empty (List(CoreAttrs)), hidden (HTML_Id id, WebArgName name, WebArgValue value), partial (HTML_Partial_Content), br, progress (List(CoreAttrs), Int value, Int max), - ol (List(CoreAttrs), HTML_In_Form content), - ul (List(CoreAttrs), HTML_In_Form content), - li (List(CoreAttrs), HTML_In_Form content), - button (List(CoreAttrs), HTML_In_Form content), + ol (List(CoreAttrs), List(HTML_In_Form) content), + ul (List(CoreAttrs), List(HTML_In_Form) content), + li (List(CoreAttrs), List(HTML_In_Form) content), + button (List(CoreAttrs), List(HTML_In_Form) content), i (List(CoreAttrs), String text), span (List(CoreAttrs), String text), hr (List(CoreAttrs)) @@ -1457,13 +1465,13 @@ public define HTML_In_Form . public define HTML_In_Form - actioner - ( - Actioner_Connection conn, - Actioner_Target targ, - Actioner_Aspect asp, - ) = - actioner(conn, targ, asp, action_name(""), [], []). + actioner + ( + Actioner_Connection conn, + Actioner_Target targ, + Actioner_Aspect asp, + )= + actioner(conn, targ, asp, action_name(""), [], []). public define HTML_In_Form @@ -1542,12 +1550,12 @@ public define HTML_In_Form public define HTML_In_Form - text - ( - List(Text_Option) lto, - Int i - ) = - text(lto, to_decimal(i)). + text + ( + List(CoreAttrs) l, + Int i + ) = + text(l, to_decimal(i)). public define HTML_In_Form text @@ -1566,6 +1574,23 @@ public define HTML_In_Form . public define HTML_In_Form + div + ( + HTML_In_Form element + )= + div([], [element]) +. + +public define HTML_In_Form + div + ( + List(CoreAttrs) attrs, + HTML_In_Form element + )= + div(attrs, [element]) +. + +public define HTML_In_Form span ( String s @@ -1613,9 +1638,9 @@ public type HTML_Off_Form: literal_pt (Printable_tree), literal (String), sequence (List(HTML_Off_Form) items), - text (List(Text_Option), String the_text), + text (List(CoreAttrs), String the_text), preformated (List(Text_Option), String), - paragraph (List(Text_Option), HTML_Off_Form content), + 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), table (List(Table_Option), HTML_Header_Row(HTML_Off_Form), List(HTML_Row(HTML_Off_Form)), HTML_Footer_Row(HTML_Off_Form)), @@ -1638,12 +1663,12 @@ public type HTML_Off_Form: private_download (String abs_path, String name, String extra_ext, Maybe((String,List((String,String)))) action), label (String name), - form (HTML_Id form_id, List(CoreAttrs), HTML_In_Form content), + form (HTML_Id form_id, List(CoreAttrs), List(HTML_In_Form) content), form (HTML_Id form_id, List(CoreAttrs), WEB_Action_Name action, List((String,String)) extra_ops, - HTML_In_Form content), + List(HTML_In_Form) content), in_form (HTML_Id form_id, HTML_In_Form content), - div (List(CoreAttrs), HTML_Off_Form content), + div (List(CoreAttrs), List(HTML_Off_Form) content), div (List(CoreAttrs), HTML_Partial_Content p_content), div_empty (List(CoreAttrs)), iframe (List(CoreAttrs), @@ -1654,10 +1679,10 @@ public type HTML_Off_Form: partial (HTML_Partial_Content), br, progress (List(CoreAttrs), Int value, Int max), - ol (List(CoreAttrs), HTML_Off_Form content), - ul (List(CoreAttrs), HTML_Off_Form content), - li (List(CoreAttrs), HTML_Off_Form content), - button (List(CoreAttrs), HTML_Off_Form content), + 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), hr (List(CoreAttrs)) @@ -1667,7 +1692,7 @@ public type HTML_Off_Form: public define HTML_Off_Form image(String url) = image([], url, url). - +public define HTML_Off_Form image(List(CoreAttrs) attrs, String url) = image(attrs, url, url). public define HTML_Off_Form image(String url, Int width, Int height) = image([], url, url, width, height). public define HTML_Off_Form @@ -1677,7 +1702,16 @@ public define HTML_Off_Form List(CoreAttrs) options, HTML_In_Form content ) = - form(html_Id(form_name), options, content). + form(html_Id(form_name), options, [content]). + +public define HTML_Off_Form + form + ( + String form_name, + List(CoreAttrs) options, + List(HTML_In_Form) contents + ) = + form(html_Id(form_name), options, contents). public define HTML_Off_Form form @@ -1688,19 +1722,52 @@ public define HTML_Off_Form List((String,String)) extra_ops, HTML_In_Form content ) = - form(html_Id(form_name), options, action, extra_ops, content). + form(html_Id(form_name), options, action, extra_ops, [content]). public define HTML_Off_Form form ( + HTML_Id form_id, + List(CoreAttrs) options, + WEB_Action_Name action, + List((String,String)) extra_ops, + HTML_In_Form content + ) = + form(form_id, options, action, extra_ops, [content]). + +public define HTML_Off_Form + form + ( + String form_name, + List(CoreAttrs) options, + WEB_Action_Name action, + List((String,String)) extra_ops, + List(HTML_In_Form) contents + ) = + form(html_Id(form_name), options, action, extra_ops, contents). + +public define HTML_Off_Form + form + ( String form_name, List(CoreAttrs) options, String action, List((String,String)) extra_ops, HTML_In_Form content ) = - form(html_Id(form_name), options, action_name(action), extra_ops, content). - + form(html_Id(form_name), options, action_name(action), extra_ops, [content]). + +public define HTML_Off_Form + form + ( + String form_name, + List(CoreAttrs) options, + String action, + List((String,String)) extra_ops, + List(HTML_In_Form) contents + ) = + form(html_Id(form_name), options, action_name(action), extra_ops, contents). + public define HTML_Off_Form literal(Printable_tree t) = literal_pt(t). public define HTML_Off_Form fixed_size(HTML_Size width, HTML_Size height, String name_of_HTML_file) = fixed_size_2(width,height,name_of_HTML_file). @@ -1728,6 +1795,15 @@ public define HTML_Off_Form actioner(conn,targ,asp,action,extra_ops,[]). public define HTML_Off_Form + actioner + ( + Actioner_Aspect asp, + WEB_Action_Name action, + List((String,String)) extra_ops + ) = + actioner(same, same, asp, action, extra_ops, []). + +public define HTML_Off_Form /* Older call with String as action instead of WEB_Action_Name. * This function exists only for compatibility with older project. * Please condiser to use above function instead @@ -1852,13 +1928,13 @@ public define HTML_Off_Form private_download(abs_path,name,extra_ext,success((action_name,args))). public define HTML_Off_Form - text - ( - List(Text_Option) lto, - Int i - ) = - text(lto,to_decimal(i)). - + text + ( + List(CoreAttrs) lto, + Int i + )= + text(lto, to_decimal(i)) +. public define HTML_Off_Form text @@ -1875,9 +1951,133 @@ public define HTML_Off_Form )= text([], s) . - - +public define HTML_Off_Form + div + ( + HTML_Off_Form element + )= + div([], [element]) +. + +public define HTML_Off_Form + div + ( + List(CoreAttrs) attrs, + HTML_Off_Form element + )= + div(attrs, [element]) +. + +public define HTML_Off_Form + div + ( + List(HTML_Off_Form) elements + )= + div([], elements) +. + + +public define HTML_Off_Form + li + ( + List(HTML_Off_Form) elements + )= + li([], elements) +. + +public define HTML_Off_Form + li + ( + List(CoreAttrs) attrs, + HTML_Off_Form element + )= + li(attrs, [element]) +. + +public define HTML_Off_Form + li + ( + HTML_Off_Form element + )= + li([], [element]) +. + +public define HTML_Off_Form + ul + ( + List(HTML_Off_Form) elements + )= + ul([], elements) +. + +public define HTML_Off_Form + ul + ( + List(CoreAttrs) attrs, + HTML_Off_Form element + )= + ul(attrs, [element]) +. + +public define HTML_Off_Form + ul + ( + HTML_Off_Form element + )= + ul([], [element]) +. + +public define HTML_Off_Form + ol + ( + List(HTML_Off_Form) elements + )= + ol([], elements) +. + +public define HTML_Off_Form + ol + ( + List(CoreAttrs) attrs, + HTML_Off_Form element + )= + ol(attrs, [element]) +. + +public define HTML_Off_Form + ol + ( + HTML_Off_Form element + )= + ol([], [element]) +. + +public define HTML_Off_Form + paragraph + ( + List(HTML_Off_Form) elements + )= + paragraph([], elements) +. + +public define HTML_Off_Form + paragraph + ( + List(Text_Option) attrs, + HTML_Off_Form element + )= + paragraph(attrs, [element]) +. + +public define HTML_Off_Form + paragraph + ( + HTML_Off_Form element + )= + paragraph([], [element]) +. + public define HTML_Off_Form span ( @@ -1906,38 +2106,87 @@ public define HTML_In_Form hr([]) . +public define HTML_In_Form + button + ( + List(HTML_In_Form) elements + )= + button([], elements) +. + +public define HTML_In_Form + button + ( + List(CoreAttrs) attrs, + HTML_In_Form element + )= + button(attrs, [element]) +. + +public define HTML_In_Form + button + ( + HTML_In_Form element + )= + button([], [element]) +. + +public define HTML_Off_Form + button + ( + List(HTML_Off_Form) elements + )= + button([], elements) +. + +public define HTML_Off_Form + button + ( + List(CoreAttrs) attrs, + HTML_Off_Form element + )= + button(attrs, [element]) +. + +public define HTML_Off_Form + button + ( + HTML_Off_Form element + )= + button([], [element]) +. - Cell a gap between two other cells : public define HTML_Cell(HTML_Off_Form) - width_gap - ( - Int w - ) = - cell([width(w)],text([],"")). + width_gap + ( + Int w + )= + cell([width(w)], empty). public define HTML_Cell(HTML_In_Form) - width_gap - ( - Int w - ) = - cell([width(w)],text([],"")). - - + width_gap + ( + Int w + )= + cell([width(w)],empty) +. - Row a gap between two other rows : public define HTML_Row(HTML_Off_Form) - height_gap - ( - Int h - ) = - row([],[cell([height(h)],text([],""))]). + height_gap + ( + Int h + )= + row([],[cell([height(h)],empty)]). public define HTML_Row(HTML_In_Form) - height_gap - ( - Int h - ) = - row([],[cell([height(h)],text([],""))]). + height_gap + ( + Int h + )= + row([],[cell([height(h)],empty)]) +. Notice that the two types have alternatives in common (same name, same arguments types, @@ -3017,11 +3266,11 @@ define HTTP_Answer // content of page sequence([ - text([size(16)], "Anubis Web Server 1.14"), + preformated([size(16)], "Anubis Web Server 1.14"), br, - text([size(16)],"Error "+to_String(http_status)), + preformated([size(16)],"Error "+to_String(http_status)), br, - text([], "Internal message :"+message), + preformated([size(14)],"Internal message :"+message), br,br, in_form(html_Id(""),text_area(wan(""), init(dump(_session)), 120, 60)) ]) @@ -3100,10 +3349,12 @@ define Maybe(WEB_Controller) )= if controllers is { - [] then failure, + [] then + println("Can't find controller ["+controller_name+"]"); + failure, [h . t] then if h.name = controller_name then - + println("Controller ["+controller_name+"] found"); success(h) else get_controller(controller_name, t) @@ -3177,6 +3428,8 @@ define (Maybe(WEB_Session), HTTP_Answer) apply_controller_action(new_controller, controllers, web_session(lang, entries, previous, previous), failure, initial_session), }, ajax(answer) then (failure, answer), + //ajax with modified session that must be saved + ajax(session, answer) then (success(session), answer), } } . @@ -3494,9 +3747,9 @@ public define One parameter $T becomes either 'HTML_Off_Form' or 'HTML_In_Form'. type HTML_Any($T): - any_text (List(Text_Option), String the_text), + any_text (List(CoreAttrs), String the_text), any_preformated (List(Text_Option), String), - any_paragraph (List(Text_Option), $T content), + any_paragraph (List(Text_Option), List($T) content), any_image (List(CoreAttrs), String url, String alternate), any_image (List(CoreAttrs), String url, String alternate, Int width, Int height), any_table (List(Table_Option), HTML_Header_Row($T), List(HTML_Row($T)), HTML_Footer_Row($T)), @@ -3519,13 +3772,13 @@ type HTML_Any($T): any_foreign_link (List(Text_Option), String url, String name), any_private_download (String abs_path, String name, String extra_ext, Maybe((String,List((String,String))))), - any_div (List(CoreAttrs), $T element), + any_div (List(CoreAttrs), List($T) element), any_div_empty (List(CoreAttrs)), any_coreattrs (List(CoreAttrs)), - any_ol (List(CoreAttrs), $T content), - any_ul (List(CoreAttrs), $T content), - any_li (List(CoreAttrs), $T content), - any_button (List(CoreAttrs), $T element), + any_ol (List(CoreAttrs), List($T) content), + any_ul (List(CoreAttrs), List($T) content), + any_li (List(CoreAttrs), List($T) content), + any_button (List(CoreAttrs), List($T) element), any_i (List(CoreAttrs), String text), any_span (List(CoreAttrs), String text), any_hr (List(CoreAttrs)) @@ -3850,6 +4103,8 @@ define List(Text_Option) get_text_options(t) else if h is title(_) then get_text_options(t) + else if h is core_attrs(_) then + get_text_options(t) else [ h . get_text_options(t) ] @@ -3884,6 +4139,24 @@ define List(CoreAttrs) get_css_class(t) } . + + +define List(CoreAttrs) + get_core_attrs + ( + List(Text_Option) l + ) + = + if l is + { + [] then [], + [h . t ] then + if h is core_attrs(attrs) then + attrs + get_core_attrs(t) + else + get_core_attrs(t) + } + . define Printable_tree format @@ -4065,18 +4338,11 @@ define String ) = with text_options = get_text_options(l), - css_classes = get_css_class(l), - if text_options is - { - [] then "", - [_ . _] then " style=\"" + format(text_options) + "\" " - } - + - if css_classes is - { - [] then "", - [_ . _] then format_attrs(css_classes) - }. + core_attrs = get_css_class(l) + get_core_attrs(l), + (if length(text_options)= 0 then "" else " style=\"" + format(text_options) + "\" ") + + + (if length(core_attrs) = 0 then "" else format_attrs(core_attrs)) + . //define String // _format @@ -4246,11 +4512,20 @@ define Printable_tree link(opt, text, mb_name) then with name_tag = if mb_name is success(n) then " name=\"" + n + "\"" else "", - [ - "", - text, - "" - ], + with action_name = if action is { + no_action then "" + controller_action(_, an) then an, + action_name(an) then an, + url(_) then "" + }, + if action_name = "" then + ["", text, "" ] + else + ["", + text, + "" + ], img_link(options, img, alt_text) then //if action name is empty, format options on image because maybe there onclick action with action_name = if action is { @@ -4627,6 +4902,7 @@ define String [ ] then "", [h . t] then if h is { + core_attrs(core_attr_list) then format_attrs(core_attr_list), size(n) then "font-size:"+n+"pt", font(fn) then "font-family:"+fn, color(c) then if c is rgb(r,g,b) then @@ -4871,13 +5147,13 @@ define Printable_tree if opts is { [] then [t], - [_ . _] then ["",t,""] + [_ . _] then ["",t,""] }, any_preformated(opts,s) then ["
",s,"
"], //["
",s,"
"], - any_paragraph(opts,e) then - ["",format_element(e),"

\n"], + any_paragraph(opts,l) then + ["", flat(map(($T e) |-> format_element(e), l)),"

\n"], any_image(opts, url, _alt) then with alt = if _alt = "" then "" else "alt=\""+_alt+"\"", [""], @@ -4918,20 +5194,20 @@ define Printable_tree ["",name,""], any_private_download(url,name,extra_ext,action) then format_private_download(cinfo,url,name,extra_ext,action), - any_div(options, e) then - [format_div_option(options), format_element(e),"\n"], + any_div(options, l) then + [format_div_option(options), flat(map(($T e) |-> format_element(e), l)),"\n"], any_div_empty(options) then [format_div_option(options), "\n"], any_coreattrs(attributs) then [format_attrs(attributs)], - any_ol(opts,e) then - ["",format_element(e),"\n"], - any_ul(opts,e) then - ["",format_element(e),"\n"], - any_li(opts,e) then - ["",format_element(e),"\n"], - any_button(options, e) then - [[""], format_element(e),"\n"], + any_ol(opts, l) then + ["", flat(map(($T e) |-> format_element(e), l)),"\n"], + any_ul(opts, l) then + ["", flat(map(($T e) |-> format_element(e), l)),"\n"], + any_li(opts, l) then + ["", flat(map(($T e) |-> format_element(e), l)),"\n"], + any_button(options, l) then + [[""], flat(map(($T e) |-> format_element(e), l)),"\n"], any_i(opts,t) then if t = "" then ["\n"] @@ -5188,17 +5464,17 @@ define Printable_tree define Bool - contains_an_upload - ( - HTML_In_Form form_content - ). + contains_an_upload + ( + HTML_In_Form form_content + ). define Bool - contains_an_upload - ( - HTML_Row(HTML_In_Form) row - ) = - mapor(contains_an_upload, + contains_an_upload + ( + HTML_Row(HTML_In_Form) row + ) = + mapor(contains_an_upload, map(content,cells(row))). define Bool @@ -5224,10 +5500,10 @@ define Bool empty then false, literal_pt(t) then false, literal(t) then false, - sequence(l) then mapor(contains_an_upload,l) + sequence(l) then mapor(contains_an_upload,l), text(o,t) then false, preformated(o,s) then false, - paragraph(o,t) then false, + paragraph(o,l) then mapor(contains_an_upload,l), image(o,u,a) then false, image(o,u,a,w,h) then false, table(o,_,rows,f_row) then if mapor(contains_an_upload,rows) then true @@ -5253,15 +5529,15 @@ define Bool radio_button_r(o,_,_,n,v,c) then false, check_box(o,_,_,n,v,c) then false, check_box_r(o,_,_,n,v,c) then false, - div(o,c) then contains_an_upload(c), + div(o,l) then mapor(contains_an_upload,l), //contains_an_upload(c), div_empty(o) then false, hidden(_,_,_) then false, partial(_) then false, br then false, progress(_,_,_) then false, - ol(_,_) then false, - ul(_,_) then false, - li(_,_) then false, + ol(_,l) then mapor(contains_an_upload,l), + ul(_,l) then mapor(contains_an_upload,l), + li(_,l) then mapor(contains_an_upload,l), button(_,_) then false, i(_,_) then false, span(_,_) then false, @@ -5271,12 +5547,14 @@ define Bool define String enctype - ( - HTML_In_Form form_content - ) = - if contains_an_upload(form_content) - then " enctype=\"multipart/form-data\"" - else "". + ( + List(HTML_In_Form) form_contents + )= + if mapor(contains_an_upload, form_contents) then + " enctype=\"multipart/form-data\"" + else + "" +. @@ -5333,29 +5611,29 @@ define Printable_tree private_download(url,name,extra,action) then format(cinfo,ic_v,any_private_download(url,name,extra,action),format_element,is_https, action_count, head_tags), label(n) then [""], - form(fn,attributs, c) then + form(fn,attributs, l) then [ "
", // action is set dynamically by // the actioner using JavaScript if fn is html_Id(id) then - format(cinfo,id,ic_v,c,is_https, action_count, head_tags), + flat(map((HTML_In_Form e) |-> format(cinfo,id,ic_v,e,is_https, action_count, head_tags), l)), "
" ] - form(fn,attributs, action, extra_ops, c) then + form(fn,attributs, action, extra_ops, l) then with url = make_actioner_url(cinfo, same, same, action, extra_ops, is_https), [ "
", // " action=\"http", // if is_https then "s" else "", @@ -5363,7 +5641,7 @@ define Printable_tree // action is set dynamically by // the actioner using JavaScript if fn is html_Id(id) then - format(cinfo,id,ic_v,c,is_https, action_count, head_tags), + flat(map((HTML_In_Form e) |-> format(cinfo,id,ic_v,e,is_https, action_count, head_tags),l)), "
" ], in_form(fn, content) then @@ -5374,7 +5652,7 @@ define Printable_tree div(options, p_content) then if p_content is partial_content(tags, html_elements) then head_tags <- *head_tags +tags; - format(cinfo, ic_v, any_div(options, html_elements), format_element, is_https, action_count, head_tags), + format(cinfo, ic_v, any_div(options, [html_elements]), format_element, is_https, action_count, head_tags), div_empty(options) then format(cinfo, ic_v, any_div_empty(options), format_element, is_https, action_count, head_tags), iframe(options, css_styles, css_files, js_files, body) then diff --git a/web/CXM_multihost_http_server.anubis b/web/CXM_multihost_http_server.anubis index 5f21c5c..5cb71b0 100644 --- a/web/CXM_multihost_http_server.anubis +++ b/web/CXM_multihost_http_server.anubis @@ -1020,17 +1020,6 @@ define Result(Error,String) else read_string(connection,[c . so_far]) }. - - - - - - - - - - - *** [2.7] Converting web arguments to ASCII. The function 'web_to_ascii' gets a character string and replaces web encoding by normal @@ -1044,42 +1033,47 @@ define Result(Error,String) define Word8 - web_decode - ( - Word8 x1, - Word8 x2 - ) = - with n1 = if x1 +=< '9' then (x1 - '0') else if x1 +=< 'F' then (x1 - 'A' + 10) else (x1 - 'a' + 10), + web_decode + ( + Word8 x1, + Word8 x2 + ) = + with n1 = if x1 +=< '9' then (x1 - '0') else if x1 +=< 'F' then (x1 - 'A' + 10) else (x1 - 'a' + 10), n2 = if x2 +=< '9' then (x2 - '0') else if x2 +=< 'F' then (x2 - 'A' + 10) else (x2 - 'a' + 10), (n1 << 4) + n2. define String - web_to_ascii - ( - String web_string, - Int n, // current position in web_string - List(Word8) so_far - ) = - if nth(n,web_string) is - { - failure then implode(reverse(so_far)), - success(c) then - if c = '+' - then web_to_ascii(web_string,n+1,[' ' . so_far]) - else if c = '%' - then if nth(n+1,web_string) is - { - failure then implode(reverse(so_far)), - success(x1) then if nth(n+2,web_string) is - { - failure then implode(reverse(so_far)), - success(x2) then web_to_ascii(web_string,n+3,[web_decode(x1,x2) . so_far]) - } - } - else web_to_ascii(web_string,n+1,[c . so_far]) - }. + web_to_ascii + ( + String web_string, + Int n, // current position in web_string + List(Word8) so_far + ) = + if nth(n,web_string) is + { + failure then implode(reverse(so_far)), + success(c) then + if c = '+' then + web_to_ascii(web_string, n+1, [' ' . so_far]) + else if c = '%' then + //println("=== % ==="); + if nth(n+1, web_string) is + { + failure then implode(reverse(so_far)), + success(x1) then + //println("=== % 1 === ["+x1+"]"); + if nth(n+2, web_string) is + { + failure then implode(reverse(so_far)), + success(x2) then + //println("=== % 2 === ["+x2+"]"); + web_to_ascii(web_string,n+3,[web_decode(x1,x2) . so_far]) + } + } + else web_to_ascii(web_string,n+1,[c . so_far]) + }. @@ -1547,48 +1541,55 @@ define Bool either the end of the string or the first '&' or '='. define String - read_name_or_value - ( - String s, - Int start, - Int i - ) = - if nth(i,s) is - { - failure then substr(s,start,i - start), - success(c) then - if is_ampersand_or_equal(c) - then substr(s,start,i-start) // the separator is not included - else read_name_or_value(s,start,i+1) - }. + read_name_or_value + ( + String s, + Int start, + Int i + ) = + if nth(i,s) is + { + failure then substr(s,start,i - start), + success(c) then + if is_ampersand_or_equal(c) then + substr(s, start, i-start) // the separator is not included + else + read_name_or_value(s,start,i+1) + } +. define List(Web_arg) - read_www_url_encoded_web_args - ( - String s, - Int start, - ) = - with first = read_name_or_value(s,start,start), - if first = "" - then [] - else with i = start+length(first), - if nth(i,s) is - { - failure then [web_arg(first,"")], - success(c) then - if c = '&' - then [web_arg(first,"") . read_www_url_encoded_web_args(s,i+1)] - else if c = '=' - then with second1 = read_name_or_value(s,i+1,i+1), - // print("\""+second1+"\"\n"); - with second = web_to_ascii(second1,0,[]), - //println("first ["+first+"] second ["+second+"]"); - with _first = if substr(first,0,4) = "amp;" then substr(first, 4, length(first) - 4) else first, - [web_arg(_first,second) . read_www_url_encoded_web_args(s,i+length(second1)+2)] - else print("**** ALERT **** badly formatted argument [" + s + "]!!!\n"); - [] - }. + read_www_url_encoded_web_args + ( + String s, //url_encoded string + Int start //current position in string + ) = + with first = read_name_or_value(s, start, start), + with name = web_to_ascii(first, 0, []), + if first = "" then + [] + else + with i = start + length(first), //jump to end of first word + if nth(i,s) is + { + failure then [web_arg(name, "")], + success(c) then + if c = '&' then + [web_arg(name, "") . read_www_url_encoded_web_args(s,i+1)] + else if c = '=' then + with second = read_name_or_value(s, i+1, i+1), + // print("\""+second1+"\"\n"); + with value = web_to_ascii(second, 0, []), + //println("first ["+first+"] => name ["+name+"] second ["+second+"] => value ["+value+"]"); + //here check the name starting with amp; which means it was "&" encoded and it must be removed + with _name = if substr(name, 0, 4) = "amp;" then substr(name, 4, length(name) - 4) else name, + [web_arg(_name, value) . read_www_url_encoded_web_args(s, i+length(value)+2)] + else + print("**** ALERT **** badly formatted argument [" + s + "]!!!\n"); + [] + } +. @@ -1618,9 +1619,9 @@ public define Result(Error, HTTP_RequestLine) HTTP_BufferedConnection connection ) = if read_word(connection) is - { - error(msg) then error(msg), - ok(get_or_post) then + { + error(msg) then error(msg), + ok(get_or_post) then if read_word(connection) is { error(msg) then error(msg), @@ -1630,7 +1631,7 @@ public define Result(Error, HTTP_RequestLine) ok(http_version) then if read_new_line(connection) is { error(msg) then error(msg), - ok(_) then if separate_uri_from_query_string(uri_and_query_string,0) is + ok(_) then if separate_uri_from_query_string(uri_and_query_string,0) is (uri,query_string) then if identify_get_or_post(get_or_post) is { error(msg) then error(msg), diff --git a/web/CXM_page_message.anubis b/web/CXM_page_message.anubis index d7caa0a..76ae222 100644 --- a/web/CXM_page_message.anubis +++ b/web/CXM_page_message.anubis @@ -141,7 +141,7 @@ public define HTML_In_Form String txt, Alignment align ) = - div(get_info_line_attrbs(html_class, align), sequence([partial(partial_content(hide_info_line_btn)), partial(partial_content(literal(txt)))])). + div(get_info_line_attrbs(html_class, align), [partial(partial_content(hide_info_line_btn)), partial(partial_content(literal(txt)))]). public define HTML_Off_Form display_info_line diff --git a/web/CXM_web_arg_utils.anubis b/web/CXM_web_arg_utils.anubis index 8bdacaa..2346816 100644 --- a/web/CXM_web_arg_utils.anubis +++ b/web/CXM_web_arg_utils.anubis @@ -106,6 +106,26 @@ public define String success(value) then value }. +public define List(String) + get_String_list + ( + 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 . get_String_list(t, name)] + else + get_String_list(t, name) + else + get_String_list(t, name) + } +. + public define Maybe(String) get_Password ( diff --git a/web/widgets/button.anubis b/web/widgets/button.anubis index 5f12a16..88d4ae7 100644 --- a/web/widgets/button.anubis +++ b/web/widgets/button.anubis @@ -52,7 +52,7 @@ public define HTML_Partial_Content WEB_Action_Name url, List((String, String)) extra_ops )= - partial_content(actioner(same, same, img_link(core_attrs+[style("cursor: pointer")], img_path, ""), url, extra_ops)). + partial_content(actioner(same, target, img_link(core_attrs+[style("cursor: pointer")], img_path, ""), url, extra_ops)). public define HTML_Partial_Content @@ -64,7 +64,7 @@ public define HTML_Partial_Content String url, List((String, String)) extra_ops )= - partial_content(actioner(same, same, img_link(core_attrs+[style("cursor: pointer")], img_path, ""), action_name(url), extra_ops)). + partial_content(actioner(same, target, img_link(core_attrs+[style("cursor: pointer")], img_path, ""), action_name(url), extra_ops)). public define HTML_Partial_Content img_button diff --git a/web/widgets/menu.anubis b/web/widgets/menu.anubis index 5b1af16..b1ee908 100644 --- a/web/widgets/menu.anubis +++ b/web/widgets/menu.anubis @@ -169,7 +169,7 @@ define List(HTML_Off_Form) if is_empty(_sub_menu) then empty else - (HTML_Off_Form)ul([class("submenu")], sequence(generate_menu(_T, _sub_menu, [], level+1))) + (HTML_Off_Form)ul([class("submenu")], generate_menu(_T, _sub_menu, [], level+1)) ])), generate_menu(_T, t, [current_li . so_far], level), @@ -179,7 +179,7 @@ define List(HTML_Off_Form) with current_li = (HTML_Off_Form)li([],partial(_content)), generate_menu(_T, t, [current_li . so_far], level), menu_separator then - with current_li = (HTML_Off_Form)li([],text("--- SEPARATOR ---")), + with current_li = (HTML_Off_Form)li([class("cxm_menu_sep")],text("--- SEPARATOR ---")), generate_menu(_T, t, [current_li . so_far], level) } @@ -209,7 +209,7 @@ define List(HTML_Off_Form) String direction )= [literal("")]. -- libgit2 0.21.4