diff --git a/calexium_lib/web/CXM_making_a_web_site.anubis b/calexium_lib/web/CXM_making_a_web_site.anubis index 1cf3b4f..9200c0c 100644 --- a/calexium_lib/web/CXM_making_a_web_site.anubis +++ b/calexium_lib/web/CXM_making_a_web_site.anubis @@ -5,11 +5,13 @@ *Title* Making interactive Web sites. *Copyright* Copyright (c) Alain Prouté 2004-2005. + Copyright (c) Calexium 2007. + - - *Author* Alain Prouté - - *Revised* January 2005. + *Authors* Alain Prouté + David René + + *Revised* May 2007 *Overview* @@ -701,6 +703,7 @@ public type BackgroundOption: public type Cell_Option: + core_attrs(List(CoreAttrs)), left, // put the content of the cell on the left h_center, // center the content of the cell horizontally right, // put the content of the cell on the right @@ -724,6 +727,9 @@ public type Cell_Option: public type HTML_Cell($T): cell(List(Cell_Option) options, $T content). + +public type HTML_Header_Cell($T): + header_cell(List(Cell_Option) options, $T content). The parameter $T is later instantiated either to 'HTML_In_Form' or to 'HTML_Off_Form', depending on where you put your table (within a form or not within a form). For your @@ -736,10 +742,20 @@ public define HTML_Cell($T) ) = cell([],content). - +public define HTML_Header_Cell($T) + header_cell + ( + $T content + ) = + header_cell([],content). + public type HTML_Row($T): - row(List(Cell_Option) options, List(HTML_Cell($T)) cells). + row(List(Cell_Option) options, List(HTML_Cell($T)) cells). + +public type HTML_Header_Row($T): + empty, + header_row(List(Cell_Option) options, List(HTML_Header_Cell($T)) cells). Same remark as for 'HTML_Cell($T)'. We define several convenience functions: @@ -756,6 +772,20 @@ public define HTML_Row($T) HTML_Cell($T) cell ) = row([],[cell]). + +public define HTML_Header_Row($T) + header_row + ( + List(HTML_Header_Cell($T)) cells + ) = + header_row([],cells). + +public define HTML_Header_Row($T) + header_row + ( + HTML_Header_Cell($T) cell + ) = + header_row([],[cell]). public type Actioner_Connection: same, // use same type of connection as current page @@ -835,7 +865,7 @@ public type HTML_In_Form: paragraph (List(Text_Option), String the_text), image (String url), image (String url, Int32 width, Int32 height), - table (List(Table_Option), List(HTML_Row(HTML_In_Form))), + table (List(Table_Option), HTML_Header_Row(HTML_In_Form), List(HTML_Row(HTML_In_Form))), center (HTML_In_Form), mail_to (String email, HTML_In_Form element), scroller (Int32 width, Int32 height, @@ -907,8 +937,23 @@ public define HTML_In_Form ( List(HTML_Row(HTML_In_Form)) rows ) = - table([],rows). + table([],empty,rows). +public define HTML_In_Form + table + ( + List(Table_Option) options, + List(HTML_Row(HTML_In_Form)) rows + ) = + table(options,empty,rows). + +public define HTML_In_Form + table + ( + HTML_Header_Row(HTML_In_Form) h_row, + List(HTML_Row(HTML_In_Form)) rows + ) = + table([],h_row,rows). public define HTML_In_Form private_download @@ -949,7 +994,7 @@ public type HTML_Off_Form: paragraph (List(Text_Option), String the_text), image (String url), image (String url, Int32 width, Int32 height), - table (List(Table_Option), List(HTML_Row(HTML_Off_Form))), + table (List(Table_Option), HTML_Header_Row(HTML_Off_Form), List(HTML_Row(HTML_Off_Form))), center (HTML_Off_Form), mail_to (String email, HTML_Off_Form element), scroller (Int32 width, Int32 height, @@ -1005,10 +1050,24 @@ public define HTML_Off_Form ( List(HTML_Row(HTML_Off_Form)) rows ) = - table([],rows). - - + table([],empty,rows). +public define HTML_Off_Form + table + ( + List(Table_Option) options, + List(HTML_Row(HTML_Off_Form)) rows + ) = + table(options,empty,rows). + +public define HTML_Off_Form + table + ( + HTML_Header_Row(HTML_Off_Form) h_row, + List(HTML_Row(HTML_Off_Form)) rows + ) = + table([],h_row,rows). + We add two convenience functions for 'row'. The reason why we add two functions, one for 'HTML_In_Form' and one for 'HTML_Off_Form', is that adding a schema with an arbitrary '$T' creates too many ambiguities. This is due to the fact that, if we do so, @@ -2156,7 +2215,7 @@ type HTML_Any($T): any_paragraph (List(Text_Option), String the_text), any_image (String url), any_image (String url, Int32 width, Int32 height), - any_table (List(Table_Option), List(HTML_Row($T))), + any_table (List(Table_Option), HTML_Header_Row($T), List(HTML_Row($T))), any_center ($T), any_mail_to (String email, $T element), any_scroller (Int32 width, Int32 height, @@ -2985,6 +3044,7 @@ define String [h . t] then if h is { + core_attrs(core_attr_list) then format_coreattrs(core_attr_list), left then " align=left", h_center then " align=center", right then " align=right", @@ -3037,7 +3097,22 @@ define Printable_tree . format(t,format_element)] }. - +define Printable_tree + format + ( + List(HTML_Header_Cell($T)) cells, + $T -> Printable_tree format_element + ) = + if cells is + { + [ ] then [ ], + [h . t] then if h is header_cell(options,element) then + ["", + format_element(element), + "" + . format(t,format_element)] + }. + Formating the rows in a table. define Printable_tree @@ -3056,7 +3131,21 @@ define Printable_tree . format(t,format_element)] }. - +define Printable_tree + format + ( + HTML_Header_Row($T) row, + $T -> Printable_tree format_element + ) = + if row is + { + empty then [ ], + header_row(options,cells) then + [" ", + format(cells,format_element), + " " + ] + }. define Printable_tree format1 @@ -3313,8 +3402,10 @@ define Printable_tree ["\"",url,"\""], any_image(url,w,h) then ["\"",url,"\""], - any_table(opts,rows) then - ["",format(rows,format_element),"
"], + any_table(opts,h_row, rows) then + ["", + format(h_row,format_element), + format(rows,format_element),"
"], any_center(e) then ["
",format_element(e),"
"], any_mail_to(email,elem) then @@ -3382,8 +3473,8 @@ define Printable_tree format(cinfo,sn,ic_v,any_image(url),format_element,is_https), image(url,w,h) then format(cinfo,sn,ic_v,any_image(url,w,h),format_element,is_https), - table(opts,rows) then - format(cinfo,sn,ic_v,any_table(opts,rows),format_element,is_https), + table(opts,header_row,rows) then + format(cinfo,sn,ic_v,any_table(opts, header_row, rows),format_element,is_https), center(e) then format(cinfo,sn,ic_v,any_center(e),format_element,is_https), mail_to(a,e) then @@ -3472,7 +3563,7 @@ define Bool paragraph(o,t) then false, image(u) then false, image(u,w,h) then false, - table(o,rows) then mapor(contains_an_upload,rows), + table(o,_,rows) then mapor(contains_an_upload,rows), center(e) then contains_an_upload(e), mail_to(m,e) then false, // 'e' may but should not contain an upload scroller(w,h,cw,ch,e) then contains_an_upload(e), @@ -3531,8 +3622,8 @@ define Printable_tree format(cinfo,sn,ic_v,any_image(url),format_element,is_https), image(url,w,h) then format(cinfo,sn,ic_v,any_image(url,w,h),format_element,is_https), - table(opts,rows) then - format(cinfo,sn,ic_v,any_table(opts,rows),format_element,is_https), + table(opts,header_row, rows) then + format(cinfo,sn,ic_v,any_table(opts,header_row, rows),format_element,is_https), center(e) then format(cinfo,sn,ic_v,any_center(e),format_element,is_https), mail_to(a,e) then -- libgit2 0.21.4