Commit aadc3df9264646a2f19485c101e47cdd729e9d17
1 parent
8161c343
add core_attributes in cell options
add table header row and header cell
Showing
1 changed file
with
113 additions
and
22 deletions
Show diff stats
calexium_lib/web/CXM_making_a_web_site.anubis
| ... | ... | @@ -5,11 +5,13 @@ |
| 5 | 5 | *Title* Making interactive Web sites. |
| 6 | 6 | |
| 7 | 7 | *Copyright* Copyright (c) Alain Prouté 2004-2005. |
| 8 | + Copyright (c) Calexium 2007. | |
| 9 | + | |
| 8 | 10 | |
| 9 | - | |
| 10 | - *Author* Alain Prouté | |
| 11 | - | |
| 12 | - *Revised* January 2005. | |
| 11 | + *Authors* Alain Prouté | |
| 12 | + David René | |
| 13 | + | |
| 14 | + *Revised* May 2007 | |
| 13 | 15 | |
| 14 | 16 | |
| 15 | 17 | *Overview* |
| ... | ... | @@ -701,6 +703,7 @@ public type BackgroundOption: |
| 701 | 703 | |
| 702 | 704 | |
| 703 | 705 | public type Cell_Option: |
| 706 | + core_attrs(List(CoreAttrs)), | |
| 704 | 707 | left, // put the content of the cell on the left |
| 705 | 708 | h_center, // center the content of the cell horizontally |
| 706 | 709 | right, // put the content of the cell on the right |
| ... | ... | @@ -724,6 +727,9 @@ public type Cell_Option: |
| 724 | 727 | |
| 725 | 728 | public type HTML_Cell($T): |
| 726 | 729 | cell(List(Cell_Option) options, $T content). |
| 730 | + | |
| 731 | +public type HTML_Header_Cell($T): | |
| 732 | + header_cell(List(Cell_Option) options, $T content). | |
| 727 | 733 | |
| 728 | 734 | The parameter $T is later instantiated either to 'HTML_In_Form' or to 'HTML_Off_Form', |
| 729 | 735 | 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) |
| 736 | 742 | ) = |
| 737 | 743 | cell([],content). |
| 738 | 744 | |
| 739 | - | |
| 745 | +public define HTML_Header_Cell($T) | |
| 746 | + header_cell | |
| 747 | + ( | |
| 748 | + $T content | |
| 749 | + ) = | |
| 750 | + header_cell([],content). | |
| 751 | + | |
| 740 | 752 | |
| 741 | 753 | public type HTML_Row($T): |
| 742 | - row(List(Cell_Option) options, List(HTML_Cell($T)) cells). | |
| 754 | + row(List(Cell_Option) options, List(HTML_Cell($T)) cells). | |
| 755 | + | |
| 756 | +public type HTML_Header_Row($T): | |
| 757 | + empty, | |
| 758 | + header_row(List(Cell_Option) options, List(HTML_Header_Cell($T)) cells). | |
| 743 | 759 | |
| 744 | 760 | Same remark as for 'HTML_Cell($T)'. We define several convenience functions: |
| 745 | 761 | |
| ... | ... | @@ -756,6 +772,20 @@ public define HTML_Row($T) |
| 756 | 772 | HTML_Cell($T) cell |
| 757 | 773 | ) = |
| 758 | 774 | row([],[cell]). |
| 775 | + | |
| 776 | +public define HTML_Header_Row($T) | |
| 777 | + header_row | |
| 778 | + ( | |
| 779 | + List(HTML_Header_Cell($T)) cells | |
| 780 | + ) = | |
| 781 | + header_row([],cells). | |
| 782 | + | |
| 783 | +public define HTML_Header_Row($T) | |
| 784 | + header_row | |
| 785 | + ( | |
| 786 | + HTML_Header_Cell($T) cell | |
| 787 | + ) = | |
| 788 | + header_row([],[cell]). | |
| 759 | 789 | |
| 760 | 790 | public type Actioner_Connection: |
| 761 | 791 | same, // use same type of connection as current page |
| ... | ... | @@ -835,7 +865,7 @@ public type HTML_In_Form: |
| 835 | 865 | paragraph (List(Text_Option), String the_text), |
| 836 | 866 | image (String url), |
| 837 | 867 | image (String url, Int32 width, Int32 height), |
| 838 | - table (List(Table_Option), List(HTML_Row(HTML_In_Form))), | |
| 868 | + table (List(Table_Option), HTML_Header_Row(HTML_In_Form), List(HTML_Row(HTML_In_Form))), | |
| 839 | 869 | center (HTML_In_Form), |
| 840 | 870 | mail_to (String email, HTML_In_Form element), |
| 841 | 871 | scroller (Int32 width, Int32 height, |
| ... | ... | @@ -907,8 +937,23 @@ public define HTML_In_Form |
| 907 | 937 | ( |
| 908 | 938 | List(HTML_Row(HTML_In_Form)) rows |
| 909 | 939 | ) = |
| 910 | - table([],rows). | |
| 940 | + table([],empty,rows). | |
| 911 | 941 | |
| 942 | +public define HTML_In_Form | |
| 943 | + table | |
| 944 | + ( | |
| 945 | + List(Table_Option) options, | |
| 946 | + List(HTML_Row(HTML_In_Form)) rows | |
| 947 | + ) = | |
| 948 | + table(options,empty,rows). | |
| 949 | + | |
| 950 | +public define HTML_In_Form | |
| 951 | + table | |
| 952 | + ( | |
| 953 | + HTML_Header_Row(HTML_In_Form) h_row, | |
| 954 | + List(HTML_Row(HTML_In_Form)) rows | |
| 955 | + ) = | |
| 956 | + table([],h_row,rows). | |
| 912 | 957 | |
| 913 | 958 | public define HTML_In_Form |
| 914 | 959 | private_download |
| ... | ... | @@ -949,7 +994,7 @@ public type HTML_Off_Form: |
| 949 | 994 | paragraph (List(Text_Option), String the_text), |
| 950 | 995 | image (String url), |
| 951 | 996 | image (String url, Int32 width, Int32 height), |
| 952 | - table (List(Table_Option), List(HTML_Row(HTML_Off_Form))), | |
| 997 | + table (List(Table_Option), HTML_Header_Row(HTML_Off_Form), List(HTML_Row(HTML_Off_Form))), | |
| 953 | 998 | center (HTML_Off_Form), |
| 954 | 999 | mail_to (String email, HTML_Off_Form element), |
| 955 | 1000 | scroller (Int32 width, Int32 height, |
| ... | ... | @@ -1005,10 +1050,24 @@ public define HTML_Off_Form |
| 1005 | 1050 | ( |
| 1006 | 1051 | List(HTML_Row(HTML_Off_Form)) rows |
| 1007 | 1052 | ) = |
| 1008 | - table([],rows). | |
| 1009 | - | |
| 1010 | - | |
| 1053 | + table([],empty,rows). | |
| 1011 | 1054 | |
| 1055 | +public define HTML_Off_Form | |
| 1056 | + table | |
| 1057 | + ( | |
| 1058 | + List(Table_Option) options, | |
| 1059 | + List(HTML_Row(HTML_Off_Form)) rows | |
| 1060 | + ) = | |
| 1061 | + table(options,empty,rows). | |
| 1062 | + | |
| 1063 | +public define HTML_Off_Form | |
| 1064 | + table | |
| 1065 | + ( | |
| 1066 | + HTML_Header_Row(HTML_Off_Form) h_row, | |
| 1067 | + List(HTML_Row(HTML_Off_Form)) rows | |
| 1068 | + ) = | |
| 1069 | + table([],h_row,rows). | |
| 1070 | + | |
| 1012 | 1071 | We add two convenience functions for 'row'. The reason why we add two functions, one |
| 1013 | 1072 | for 'HTML_In_Form' and one for 'HTML_Off_Form', is that adding a schema with an |
| 1014 | 1073 | 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): |
| 2156 | 2215 | any_paragraph (List(Text_Option), String the_text), |
| 2157 | 2216 | any_image (String url), |
| 2158 | 2217 | any_image (String url, Int32 width, Int32 height), |
| 2159 | - any_table (List(Table_Option), List(HTML_Row($T))), | |
| 2218 | + any_table (List(Table_Option), HTML_Header_Row($T), List(HTML_Row($T))), | |
| 2160 | 2219 | any_center ($T), |
| 2161 | 2220 | any_mail_to (String email, $T element), |
| 2162 | 2221 | any_scroller (Int32 width, Int32 height, |
| ... | ... | @@ -2985,6 +3044,7 @@ define String |
| 2985 | 3044 | [h . t] then |
| 2986 | 3045 | if h is |
| 2987 | 3046 | { |
| 3047 | + core_attrs(core_attr_list) then format_coreattrs(core_attr_list), | |
| 2988 | 3048 | left then " align=left", |
| 2989 | 3049 | h_center then " align=center", |
| 2990 | 3050 | right then " align=right", |
| ... | ... | @@ -3037,7 +3097,22 @@ define Printable_tree |
| 3037 | 3097 | . format(t,format_element)] |
| 3038 | 3098 | }. |
| 3039 | 3099 | |
| 3040 | - | |
| 3100 | +define Printable_tree | |
| 3101 | + format | |
| 3102 | + ( | |
| 3103 | + List(HTML_Header_Cell($T)) cells, | |
| 3104 | + $T -> Printable_tree format_element | |
| 3105 | + ) = | |
| 3106 | + if cells is | |
| 3107 | + { | |
| 3108 | + [ ] then [ ], | |
| 3109 | + [h . t] then if h is header_cell(options,element) then | |
| 3110 | + ["<th ",format(reverse(normalize(options))),">", | |
| 3111 | + format_element(element), | |
| 3112 | + "</th>" | |
| 3113 | + . format(t,format_element)] | |
| 3114 | + }. | |
| 3115 | + | |
| 3041 | 3116 | Formating the rows in a table. |
| 3042 | 3117 | |
| 3043 | 3118 | define Printable_tree |
| ... | ... | @@ -3056,7 +3131,21 @@ define Printable_tree |
| 3056 | 3131 | . format(t,format_element)] |
| 3057 | 3132 | }. |
| 3058 | 3133 | |
| 3059 | - | |
| 3134 | +define Printable_tree | |
| 3135 | + format | |
| 3136 | + ( | |
| 3137 | + HTML_Header_Row($T) row, | |
| 3138 | + $T -> Printable_tree format_element | |
| 3139 | + ) = | |
| 3140 | + if row is | |
| 3141 | + { | |
| 3142 | + empty then [ ], | |
| 3143 | + header_row(options,cells) then | |
| 3144 | + ["<thead> <tr ",format(reverse(options)),">", | |
| 3145 | + format(cells,format_element), | |
| 3146 | + "</tr> </thead>" | |
| 3147 | + ] | |
| 3148 | + }. | |
| 3060 | 3149 | |
| 3061 | 3150 | define Printable_tree |
| 3062 | 3151 | format1 |
| ... | ... | @@ -3313,8 +3402,10 @@ define Printable_tree |
| 3313 | 3402 | ["<img alt=\"",url,"\" src=\"",url,"\">"], |
| 3314 | 3403 | any_image(url,w,h) then |
| 3315 | 3404 | ["<img alt=\"",url,"\" src=\"",url,"\" width=",w," height=",h,">"], |
| 3316 | - any_table(opts,rows) then | |
| 3317 | - ["<table ",format(reverse(opts),false),">",format(rows,format_element),"</table>"], | |
| 3405 | + any_table(opts,h_row, rows) then | |
| 3406 | + ["<table ",format(reverse(opts),false),">", | |
| 3407 | + format(h_row,format_element), | |
| 3408 | + format(rows,format_element),"</table>"], | |
| 3318 | 3409 | any_center(e) then |
| 3319 | 3410 | ["<center>",format_element(e),"</center>"], |
| 3320 | 3411 | any_mail_to(email,elem) then |
| ... | ... | @@ -3382,8 +3473,8 @@ define Printable_tree |
| 3382 | 3473 | format(cinfo,sn,ic_v,any_image(url),format_element,is_https), |
| 3383 | 3474 | image(url,w,h) then |
| 3384 | 3475 | format(cinfo,sn,ic_v,any_image(url,w,h),format_element,is_https), |
| 3385 | - table(opts,rows) then | |
| 3386 | - format(cinfo,sn,ic_v,any_table(opts,rows),format_element,is_https), | |
| 3476 | + table(opts,header_row,rows) then | |
| 3477 | + format(cinfo,sn,ic_v,any_table(opts, header_row, rows),format_element,is_https), | |
| 3387 | 3478 | center(e) then |
| 3388 | 3479 | format(cinfo,sn,ic_v,any_center(e),format_element,is_https), |
| 3389 | 3480 | mail_to(a,e) then |
| ... | ... | @@ -3472,7 +3563,7 @@ define Bool |
| 3472 | 3563 | paragraph(o,t) then false, |
| 3473 | 3564 | image(u) then false, |
| 3474 | 3565 | image(u,w,h) then false, |
| 3475 | - table(o,rows) then mapor(contains_an_upload,rows), | |
| 3566 | + table(o,_,rows) then mapor(contains_an_upload,rows), | |
| 3476 | 3567 | center(e) then contains_an_upload(e), |
| 3477 | 3568 | mail_to(m,e) then false, // 'e' may but should not contain an upload |
| 3478 | 3569 | scroller(w,h,cw,ch,e) then contains_an_upload(e), |
| ... | ... | @@ -3531,8 +3622,8 @@ define Printable_tree |
| 3531 | 3622 | format(cinfo,sn,ic_v,any_image(url),format_element,is_https), |
| 3532 | 3623 | image(url,w,h) then |
| 3533 | 3624 | format(cinfo,sn,ic_v,any_image(url,w,h),format_element,is_https), |
| 3534 | - table(opts,rows) then | |
| 3535 | - format(cinfo,sn,ic_v,any_table(opts,rows),format_element,is_https), | |
| 3625 | + table(opts,header_row, rows) then | |
| 3626 | + format(cinfo,sn,ic_v,any_table(opts,header_row, rows),format_element,is_https), | |
| 3536 | 3627 | center(e) then |
| 3537 | 3628 | format(cinfo,sn,ic_v,any_center(e),format_element,is_https), |
| 3538 | 3629 | mail_to(a,e) then | ... | ... |