diff --git a/calexium_lib/web/CXM_generic_form.anubis b/calexium_lib/web/CXM_generic_form.anubis index 28d53fe..549bfc3 100644 --- a/calexium_lib/web/CXM_generic_form.anubis +++ b/calexium_lib/web/CXM_generic_form.anubis @@ -1,469 +1,469 @@ - - - - *Project* The Anubis Project - - *Title* - - *Copyright* Copyright (c) Alain Prouté 2005. - - - *Author* Alain Prouté - - - - In this file we rationalize the construction of forms. - - - -read CXM_making_a_web_site.anubis - - -public type Mandatory: // used to mark fields as mandatory. - mandatory, - non_mandatory. - -public type Width: - small, - narrow, - wide, - custom(Int32). - -public type FormFieldWidth: - auto, - custom(Int32). - - - - Sorts of fields that you can put in a form: - -public type FormField: - - //--- title field --------------------------------------------------------------------- - title (String text), - title (Int32 text_size, - String text), - title_f (List(Text_Option) -> HTML_In_Form), - - //--- message field ------------------------------------------------------------------- - message (Result(String,String) msg), - message_f (Result(List(Text_Option) -> HTML_In_Form,List(Text_Option) -> HTML_In_Form)), - - //--- text input field ---------------------------------------------------------------- - input (String web_arg_name, - String tag, - Width width, - String init_value, - Mandatory mandatory), - input (String web_arg_name, - Width width, - String init_value), - input_f (String web_arg_name, - List(Text_Option) -> HTML_In_Form tag, - Width width, - String init_value, - Mandatory mandatory), - - //--- password input field ------------------------------------------------------------ - password_input (String web_arg_name, - String tag, - Mandatory mandatory), - password_input_f (String web_arg_name, - List(Text_Option) -> HTML_In_Form tag, - Mandatory mandatory), - - //--- explanation field --------------------------------------------------------------- - explain (String text), - explain (String text, - FormFieldWidth width), - explain_f (List(Text_Option) -> HTML_In_Form), - - //--- selector field ------------------------------------------------------------------ - selector (String web_arg_name, - String tag, - List(String) items, - Maybe(String) selected, - Mandatory mandatory), - selector_f (String web_arg_name, - List(Text_Option) -> HTML_In_Form, - List(String) items, - Maybe(String) selected, - Mandatory mandatory), - selector_c (String web_arg_name, - String tag, - List((String,String)) items, - Maybe(String) selected, - Mandatory mandatory), - - - - //--- checkbox field ------------------------------------------------------------------ - checkbox (String web_arg_name, - String tag, - Bool checked, - Mandatory mandatory), - // the same one, but with the tag on the right of the checkbox - checkboxr (String web_arg_name, - String tag, - Bool checked, - Mandatory mandatory), - checkbox_f (String web_arg_name, - List(Text_Option) -> HTML_In_Form, - Bool checked, - Mandatory mandatory), - - //--- radio-button field -------------------------------------------------------------- - radio_button (String web_arg_name, - String web_arg_value, - String tag, - Bool checked, - Mandatory mandatory), - // the same one, but with the tag on the right of the radio_button - radio_buttonr (String web_arg_name, - String web_arg_value, - String tag, - Bool checked, - Mandatory mandatory), - - //--- text area field ----------------------------------------------------------------- - text_area (String web_arg_name, - String initial_text), - text_area (String web_arg_name, - String tag, - String initial_text), - text_area (String web_arg_name, - String tag, - String initial_text, - Int32 width, - Int32 height), - - //--- fields table -------------------------------------------------------------------- - fields_table (String tag, - List(FormField) fields), - - //--- fields line --------------------------------------------------------------------- - fields_line (String tag, - List(FormField) fields), - fields_line (List(FormField) fields), - - //--- preview field ------------------------------------------------------------------- - preview (String html_text), - - //--- submit button ------------------------------------------------------------------- - submit (String action_name, - Maybe(String) label, - String button_text, - List((String,String)) extra_operands). - - - Convenience functions: - -public define FormField title(List(Text_Option) -> HTML_In_Form f) = title_f(f). -public define FormField - message(Result(List(Text_Option) -> HTML_In_Form,List(Text_Option) -> HTML_In_Form) f) = message_f(f). -public define FormField input(String web_arg_name, - List(Text_Option) -> HTML_In_Form tag, - Width width, - String init_value, - Mandatory mandatory) - = input_f(web_arg_name,tag,width,init_value,mandatory). -public define FormField password_input(String web_arg_name, - List(Text_Option) -> HTML_In_Form tag, - Mandatory mandatory) - = password_input_f(web_arg_name,tag,mandatory). -public define FormField explain(List(Text_Option) -> HTML_In_Form f) = explain_f(f). -public define FormField selector(String web_arg_name, - List(Text_Option) -> HTML_In_Form f, - List(String) items, - Maybe(String) selected, - Mandatory mandatory) - = selector_f(web_arg_name,f,items,selected,mandatory). -public define FormField checkbox(String web_arg_name, - List(Text_Option) -> HTML_In_Form f, - Bool checked, - Mandatory mandatory) - = checkbox_f(web_arg_name,f,checked,mandatory). - - Make the form itself with: - -public define HTML_Off_Form - generic_form - ( - String form_name, - RGB background_color, - Int32 width, - List(FormField) fields - ). - - - - --- That's all for the public part ! -------------------------------------------------- - - -define HTML_Row(HTML_In_Form) - format_form_field - ( - FormField ff - ) = - with star = (Mandatory m) |-> (HTML_In_Form)text([color(rgb(255,0,0)),size(12)], - if m is - { - mandatory then "*", - non_mandatory then "" - }), - row( - if ff is - { - title(t) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([columns(3),h_center],text([size(16),bold,color(rgb(0,0,0))],t)) - ], - - title(s,t) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([columns(3),h_center],text([size(s),bold,color(rgb(0,0,0))],t)) - ], - - title_f(t) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([columns(3),h_center],t([size(16),bold,color(rgb(0,0,0))])) - ], - - message(r) then (List(HTML_Cell(HTML_In_Form))) if r is - { - error(msg) then [cell([columns(3),h_center], - text([size(10),color(rgb(240,0,0))],msg))] - ok(msg) then [cell([columns(3),h_center], - text([size(10),color(rgb(0,150,0))],msg))] - }, - - message_f(r) then (List(HTML_Cell(HTML_In_Form))) if r is - { - error(msg) then [cell([columns(3),h_center], - msg([size(10),color(rgb(240,0,0))]))] - ok(msg) then [cell([columns(3),h_center], - msg([size(10),color(rgb(0,150,0))]))] - }, - - input(wan,tag,w,init,mand) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right ], text([size(10)],tag)), - cell([width(7) ], star(mand)), - cell([left ], text_input("","",wan,init,if w is - { - small then 10, - narrow then 30, - wide then 70, - custom(n) then n - })) - ], - - input(wan,w,init) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([left,columns(3) ], text_input("","",wan,init,if w is - { - small then 10, - narrow then 30, - wide then 70, - custom(n) then n - })) - ], - - input_f(wan,tag,w,init,mand) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right ], tag([size(10)])), - cell([width(7) ], star(mand)), - cell([left ], text_input("","",wan,init,if w is - { - small then 15, - narrow then 30, - wide then 70, - custom(n) then n - })) - ], - - password_input(wan,tag,mand) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right ], text([size(10)],tag)), - cell([width(7) ], star(mand)), - cell([left ], password_input("","",wan,30)) - ], - - password_input_f(wan,tag,mand) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right ], tag([size(10)])), - cell([width(7) ], star(mand)), - cell([left ], password_input("","",wan,30)) - ], - - explain(t) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([columns(3),h_center], - table([nude],[row(cell([width(500)], - paragraph([/*justified,*/size(10),color(rgb(0,100,0))],t)))])) - ], - - explain(t,w) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([columns(3),h_center], - table([nude],[row(cell( - if w is - { - auto then [], - custom(i) then [width(i)] - }, - paragraph([/*justified,*/size(10),color(rgb(0,100,0))],t)))])) - ], - - explain_f(t) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([columns(3),h_center], - table([nude],[row(cell([width(500)], - t([/*justified,*/size(10),color(rgb(0,100,0))])))])) - ], - - selector(wan,tag,items,selected,mand) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right ], text([size(10)],tag)), - cell([width(7)], star(mand)), - cell([left ], if selected is - { - failure then selector(wan,1,items) - success(sel) then selector(wan,1,items,sel) - }) - ], - - selector_f(wan,tag,items,selected,mand) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right ], tag([size(10)])), - cell([width(7)], star(mand)), - cell([left ], if selected is - { - failure then selector(wan,1,items) - success(sel) then selector(wan,1,items,sel) - }) - ], - - selector_c(wan,tag,items,selected,mand) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right ], text([size(10)],tag)), - cell([width(7)], star(mand)), - cell([left ], if selected is - { - failure then selector_c(wan,1,items) - success(sel) then selector_c(wan,1,items,sel) - }) - ], - - checkbox(wan,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right ], text([size(10)],tag)), - cell([width(7)], star(mand)), - cell([left ], check_box("","",wan,checked)) - ], - - checkboxr(wan,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right ], check_box("","",wan,checked)), - cell([width(7)], star(mand)), - cell([left ], text([size(10)],tag)) - ], - - checkbox_f(wan,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right ], tag([size(10)])), - cell([width(7)], star(mand)), - cell([left ], check_box("","",wan,checked)) - ], - - radio_button(wan,wav,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right ], text([size(10)],tag)), - cell([width(7)], star(mand)), - cell([left ], radio_button("","",wan,wav,checked)) - ], - - radio_buttonr(wan,wav,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right ], radio_button("","",wan,wav,checked)), - cell([width(7)], star(mand)), - cell([left ], text([size(10)],tag)) - ], - - text_area(wan,tx) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([h_center,columns(3)],text_area([wrap_lines],wan,tx,75,10)) - ], - - text_area(wan,tag,tx) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right,top], text([size(10)],tag)), - cell([width(7)], text([],"")), - cell([h_center],text_area([wrap_lines],wan,tx,75,10)) - ], - - text_area(wan,tag,tx,w,h) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right,top], text([size(10)],tag)), - cell([width(7)], text([],"")), - cell([h_center],text_area([wrap_lines],wan,tx,w,h)) - ], - - fields_table(tag,fields) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right,top], text([size(10)],tag)), - cell([width(7)], text([],"")), - cell([left,top], table([],map((FormField ff) |-> format_form_field(ff),fields))) - ], - - fields_line(tag,fields) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([right,top], text([size(10)],tag)), - cell([width(7)], text([],"")), - cell([left,top], table([nude],[row([], //border(0,0,3,rgb(0,0,0)) - map((FormField ff) |-> cell([top],table([nude],[format_form_field(ff)])),fields))])) - ], - - fields_line(fields) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([left,top,columns(3)], table([nude],[row([], - map((FormField ff) |-> cell([top],table([nude],[format_form_field(ff)])),fields))])) - ], - - preview(html_text) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([top,left,columns(3),background_color(rgb(255,255,255))], - table([border(0,8,0,rgb(0,0,0))], - [row(cell([left,top,height(200)],literal(html_text)))])) - ], - - submit(action_name,mb_label,button_text,extra_operands) then (List(HTML_Cell(HTML_In_Form))) - [ - cell([columns(3),right],actioner(same, - if mb_label is - { - failure then same, - success(n) then same(n) - }, - link(button_text), - action_name, - extra_operands)) - ] - }). - - - -public define HTML_Off_Form - generic_form - ( - String form_name, - RGB bg_color, - Int32 w, - List(FormField) fields - ) = - table([border(0,0,5,bg_color),percentage_width(100), - background_color(bg_color)],[row(cell([h_center], - form(form_name,[],table([border(0,2,0,bg_color)], - map(format_form_field,fields)))))]). - - + + + + *Project* The Anubis Project + + *Title* + + *Copyright* Copyright (c) Alain Prouté 2005. + + + *Author* Alain Prouté + + + + In this file we rationalize the construction of forms. + + + +read CXM_making_a_web_site.anubis + + +public type Mandatory: // used to mark fields as mandatory. + mandatory, + non_mandatory. + +public type Width: + small, + narrow, + wide, + custom(Int32). + +public type FormFieldWidth: + auto, + custom(Int32). + + + + Sorts of fields that you can put in a form: + +public type FormField: + + //--- title field --------------------------------------------------------------------- + title (String text), + title (Int32 text_size, + String text), + title_f (List(Text_Option) -> HTML_In_Form), + + //--- message field ------------------------------------------------------------------- + message (Result(String,String) msg), + message_f (Result(List(Text_Option) -> HTML_In_Form,List(Text_Option) -> HTML_In_Form)), + + //--- text input field ---------------------------------------------------------------- + input (String web_arg_name, + String tag, + Width width, + String init_value, + Mandatory mandatory), + input (String web_arg_name, + Width width, + String init_value), + input_f (String web_arg_name, + List(Text_Option) -> HTML_In_Form tag, + Width width, + String init_value, + Mandatory mandatory), + + //--- password input field ------------------------------------------------------------ + password_input (String web_arg_name, + String tag, + Mandatory mandatory), + password_input_f (String web_arg_name, + List(Text_Option) -> HTML_In_Form tag, + Mandatory mandatory), + + //--- explanation field --------------------------------------------------------------- + explain (String text), + explain (String text, + FormFieldWidth width), + explain_f (List(Text_Option) -> HTML_In_Form), + + //--- selector field ------------------------------------------------------------------ + selector (String web_arg_name, + String tag, + List(String) items, + Maybe(String) selected, + Mandatory mandatory), + selector_f (String web_arg_name, + List(Text_Option) -> HTML_In_Form, + List(String) items, + Maybe(String) selected, + Mandatory mandatory), + selector_c (String web_arg_name, + String tag, + List((String,String)) items, + Maybe(String) selected, + Mandatory mandatory), + + + + //--- checkbox field ------------------------------------------------------------------ + checkbox (String web_arg_name, + String tag, + Bool checked, + Mandatory mandatory), + // the same one, but with the tag on the right of the checkbox + checkboxr (String web_arg_name, + String tag, + Bool checked, + Mandatory mandatory), + checkbox_f (String web_arg_name, + List(Text_Option) -> HTML_In_Form, + Bool checked, + Mandatory mandatory), + + //--- radio-button field -------------------------------------------------------------- + radio_button (String web_arg_name, + String web_arg_value, + String tag, + Bool checked, + Mandatory mandatory), + // the same one, but with the tag on the right of the radio_button + radio_buttonr (String web_arg_name, + String web_arg_value, + String tag, + Bool checked, + Mandatory mandatory), + + //--- text area field ----------------------------------------------------------------- + text_area (String web_arg_name, + String initial_text), + text_area (String web_arg_name, + String tag, + String initial_text), + text_area (String web_arg_name, + String tag, + String initial_text, + Int32 width, + Int32 height), + + //--- fields table -------------------------------------------------------------------- + fields_table (String tag, + List(FormField) fields), + + //--- fields line --------------------------------------------------------------------- + fields_line (String tag, + List(FormField) fields), + fields_line (List(FormField) fields), + + //--- preview field ------------------------------------------------------------------- + preview (String html_text), + + //--- submit button ------------------------------------------------------------------- + submit (String action_name, + Maybe(String) label, + String button_text, + List((String,String)) extra_operands). + + + Convenience functions: + +public define FormField title(List(Text_Option) -> HTML_In_Form f) = title_f(f). +public define FormField + message(Result(List(Text_Option) -> HTML_In_Form,List(Text_Option) -> HTML_In_Form) f) = message_f(f). +public define FormField input(String web_arg_name, + List(Text_Option) -> HTML_In_Form tag, + Width width, + String init_value, + Mandatory mandatory) + = input_f(web_arg_name,tag,width,init_value,mandatory). +public define FormField password_input(String web_arg_name, + List(Text_Option) -> HTML_In_Form tag, + Mandatory mandatory) + = password_input_f(web_arg_name,tag,mandatory). +public define FormField explain(List(Text_Option) -> HTML_In_Form f) = explain_f(f). +public define FormField selector(String web_arg_name, + List(Text_Option) -> HTML_In_Form f, + List(String) items, + Maybe(String) selected, + Mandatory mandatory) + = selector_f(web_arg_name,f,items,selected,mandatory). +public define FormField checkbox(String web_arg_name, + List(Text_Option) -> HTML_In_Form f, + Bool checked, + Mandatory mandatory) + = checkbox_f(web_arg_name,f,checked,mandatory). + + Make the form itself with: + +public define HTML_Off_Form + generic_form + ( + String form_name, + RGB background_color, + Int32 width, + List(FormField) fields + ). + + + + --- That's all for the public part ! -------------------------------------------------- + + +define HTML_Row(HTML_In_Form) + format_form_field + ( + FormField ff + ) = + with star = (Mandatory m) |-> (HTML_In_Form)text([color(rgb(255,0,0)),size(12)], + if m is + { + mandatory then "*", + non_mandatory then "" + }), + row( + if ff is + { + title(t) then (List(HTML_Cell(HTML_In_Form))) + [ + cell([columns(3),h_center],text([size(16),bold,color(rgb(0,0,0))],t)) + ], + + title(s,t) then (List(HTML_Cell(HTML_In_Form))) + [ + cell([columns(3),h_center],text([size(s),bold,color(rgb(0,0,0))],t)) + ], + + title_f(t) then (List(HTML_Cell(HTML_In_Form))) + [ + cell([columns(3),h_center],t([size(16),bold,color(rgb(0,0,0))])) + ], + + message(r) then (List(HTML_Cell(HTML_In_Form))) if r is + { + error(msg) then [cell([columns(3),h_center], + text([size(10),color(rgb(240,0,0))],msg))] + ok(msg) then [cell([columns(3),h_center], + text([size(10),color(rgb(0,150,0))],msg))] + }, + + message_f(r) then (List(HTML_Cell(HTML_In_Form))) if r is + { + error(msg) then [cell([columns(3),h_center], + msg([size(10),color(rgb(240,0,0))]))] + ok(msg) then [cell([columns(3),h_center], + msg([size(10),color(rgb(0,150,0))]))] + }, + + input(wan,tag,w,init,mand) then (List(HTML_Cell(HTML_In_Form))) + [ + cell([right ], text([size(10)],tag)), + cell([width(7) ], star(mand)), + cell([left ], text_input("","",wan,init,if w is + { + small then 10, + narrow then 30, + wide then 70, + custom(n) then n + })) + ], + + input(wan,w,init) then (List(HTML_Cell(HTML_In_Form))) + [ + cell([left,columns(3) ], text_input("","",wan,init,if w is + { + small then 10, + narrow then 30, + wide then 70, + custom(n) then n + })) + ], + + input_f(wan,tag,w,init,mand) then (List(HTML_Cell(HTML_In_Form))) + [ + cell([right ], tag([size(10)])), + cell([width(7) ], star(mand)), + cell([left ], text_input("","",wan,init,if w is + { + small then 15, + narrow then 30, + wide then 70, + custom(n) then n + })) + ], + + password_input(wan,tag,mand) then (List(HTML_Cell(HTML_In_Form))) + [ + cell([right ], text([size(10)],tag)), + cell([width(7) ], star(mand)), + cell([left ], password_input("","",wan,30)) + ], + + password_input_f(wan,tag,mand) then (List(HTML_Cell(HTML_In_Form))) + [ + cell([right ], tag([size(10)])), + cell([width(7) ], star(mand)), + cell([left ], password_input("","",wan,30)) + ], + + explain(t) then (List(HTML_Cell(HTML_In_Form))) + [ + cell([columns(3),h_center], + table([nude],[row(cell([width(500)], + paragraph([/*justified,*/size(10),color(rgb(0,100,0))],literal(t))))])) + ], + + explain(t,w) then (List(HTML_Cell(HTML_In_Form))) + [ + cell([columns(3),h_center], + table([nude],[row(cell( + if w is + { + auto then [], + custom(i) then [width(i)] + }, + paragraph([/*justified,*/size(10),color(rgb(0,100,0))], literal(t))))])) + ], + + explain_f(t) then (List(HTML_Cell(HTML_In_Form))) + [ + cell([columns(3),h_center], + table([nude],[row(cell([width(500)], + t([/*justified,*/size(10),color(rgb(0,100,0))])))])) + ], + + selector(wan,tag,items,selected,mand) then (List(HTML_Cell(HTML_In_Form))) + [ + cell([right ], text([size(10)],tag)), + cell([width(7)], star(mand)), + cell([left ], if selected is + { + failure then selector(wan,1,items) + success(sel) then selector(wan,1,items,sel) + }) + ], + + selector_f(wan,tag,items,selected,mand) then (List(HTML_Cell(HTML_In_Form))) + [ + cell([right ], tag([size(10)])), + cell([width(7)], star(mand)), + cell([left ], if selected is + { + failure then selector(wan,1,items) + success(sel) then selector(wan,1,items,sel) + }) + ], + + selector_c(wan,tag,items,selected,mand) then (List(HTML_Cell(HTML_In_Form))) + [ + cell([right ], text([size(10)],tag)), + cell([width(7)], star(mand)), + cell([left ], if selected is + { + failure then selector_c(wan,1,items) + success(sel) then selector_c(wan,1,items,sel) + }) + ], + + checkbox(wan,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form))) + [ + cell([right ], text([size(10)],tag)), + cell([width(7)], star(mand)), + cell([left ], check_box("","",wan,checked)) + ], + + checkboxr(wan,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form))) + [ + cell([right ], check_box("","",wan,checked)), + cell([width(7)], star(mand)), + cell([left ], text([size(10)],tag)) + ], + + checkbox_f(wan,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form))) + [ + cell([right ], tag([size(10)])), + cell([width(7)], star(mand)), + cell([left ], check_box("","",wan,checked)) + ], + + radio_button(wan,wav,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form))) + [ + cell([right ], text([size(10)],tag)), + cell([width(7)], star(mand)), + cell([left ], radio_button("","",wan,wav,checked)) + ], + + radio_buttonr(wan,wav,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form))) + [ + cell([right ], radio_button("","",wan,wav,checked)), + cell([width(7)], star(mand)), + cell([left ], text([size(10)],tag)) + ], + + text_area(wan,tx) then (List(HTML_Cell(HTML_In_Form))) + [ + cell([h_center,columns(3)],text_area([wrap_lines],wan,tx,75,10)) + ], + + text_area(wan,tag,tx) then (List(HTML_Cell(HTML_In_Form))) + [ + cell([right,top], text([size(10)],tag)), + cell([width(7)], text([],"")), + cell([h_center],text_area([wrap_lines],wan,tx,75,10)) + ], + + text_area(wan,tag,tx,w,h) then (List(HTML_Cell(HTML_In_Form))) + [ + cell([right,top], text([size(10)],tag)), + cell([width(7)], text([],"")), + cell([h_center],text_area([wrap_lines],wan,tx,w,h)) + ], + + fields_table(tag,fields) then (List(HTML_Cell(HTML_In_Form))) + [ + cell([right,top], text([size(10)],tag)), + cell([width(7)], text([],"")), + cell([left,top], table([],map((FormField ff) |-> format_form_field(ff),fields))) + ], + + fields_line(tag,fields) then (List(HTML_Cell(HTML_In_Form))) + [ + cell([right,top], text([size(10)],tag)), + cell([width(7)], text([],"")), + cell([left,top], table([nude],[row([], //border(0,0,3,rgb(0,0,0)) + map((FormField ff) |-> cell([top],table([nude],[format_form_field(ff)])),fields))])) + ], + + fields_line(fields) then (List(HTML_Cell(HTML_In_Form))) + [ + cell([left,top,columns(3)], table([nude],[row([], + map((FormField ff) |-> cell([top],table([nude],[format_form_field(ff)])),fields))])) + ], + + preview(html_text) then (List(HTML_Cell(HTML_In_Form))) + [ + cell([top,left,columns(3),background_color(rgb(255,255,255))], + table([border(0,8,0,rgb(0,0,0))], + [row(cell([left,top,height(200)],literal(html_text)))])) + ], + + submit(action_name,mb_label,button_text,extra_operands) then (List(HTML_Cell(HTML_In_Form))) + [ + cell([columns(3),right],actioner(same, + if mb_label is + { + failure then same, + success(n) then same(n) + }, + link(button_text), + action_name, + extra_operands)) + ] + }). + + + +public define HTML_Off_Form + generic_form + ( + String form_name, + RGB bg_color, + Int32 w, + List(FormField) fields + ) = + table([border(0,0,5,bg_color),percentage_width(100), + background_color(bg_color)],[row(cell([h_center], + form(form_name,[],table([border(0,2,0,bg_color)], + map(format_form_field,fields)))))]). + + diff --git a/calexium_lib/web/CXM_making_a_web_site.anubis b/calexium_lib/web/CXM_making_a_web_site.anubis index 3bf0d49..c5693cc 100644 --- a/calexium_lib/web/CXM_making_a_web_site.anubis +++ b/calexium_lib/web/CXM_making_a_web_site.anubis @@ -644,7 +644,8 @@ public type Text_Option: justified, // justified on both sides line_through, nowrap, - class(String). //CSS class + class(String), //CSS class + id(String). A list of 'Text_Option' must be given with each text you want to put in your page. @@ -863,7 +864,7 @@ public type HTML_In_Form: sequence (List(HTML_In_Form) items), text (List(Text_Option), String the_text), preformated (List(Text_Option), String), - paragraph (List(Text_Option), String the_text), + paragraph (List(Text_Option), HTML_In_Form content), image (String url), image (String url, Int32 width, Int32 height), table (List(Table_Option), HTML_Header_Row(HTML_In_Form), List(HTML_Row(HTML_In_Form))), @@ -996,7 +997,7 @@ public type HTML_Off_Form: sequence (List(HTML_Off_Form) items), text (List(Text_Option), String the_text), preformated (List(Text_Option), String), - paragraph (List(Text_Option), String the_text), + paragraph (List(Text_Option), HTML_Off_Form content), image (String url), image (String url, Int32 width, Int32 height), table (List(Table_Option), HTML_Header_Row(HTML_Off_Form), List(HTML_Row(HTML_Off_Form))), @@ -2218,7 +2219,7 @@ public define One type HTML_Any($T): any_text (List(Text_Option), String the_text), any_preformated (List(Text_Option), String), - any_paragraph (List(Text_Option), String the_text), + any_paragraph (List(Text_Option), $T content), any_image (String url), any_image (String url, Int32 width, Int32 height), any_table (List(Table_Option), HTML_Header_Row($T), List(HTML_Row($T))), @@ -3225,7 +3226,8 @@ define String justified then "text-align:justify", line_through then "text-decoration:line-through", nowrap then "white-space:nowrap", - class(class_name)then " class=\"" +class_name +"\"" + class(class_name)then " class=\"" +class_name +"\"", + id(id_name) then " id=\"" +id_name +"\"" } + if t is [ ] then "" else ("; "+format(t)) }. @@ -3406,8 +3408,8 @@ define Printable_tree any_preformated(opts,s) then ["
",s,"
"], //["
",s,"
"], - any_paragraph(opts,t) then - ["

",t,"

\n"], + any_paragraph(opts,e) then + ["

",format_element(e),"

\n"], any_image(url) then ["\"",url,"\""], any_image(url,w,h) then -- libgit2 0.21.4