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,11 +5,13 @@ | ||
| 5 | *Title* Making interactive Web sites. | 5 | *Title* Making interactive Web sites. |
| 6 | 6 | ||
| 7 | *Copyright* Copyright (c) Alain Prouté 2004-2005. | 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 | *Overview* | 17 | *Overview* |
| @@ -701,6 +703,7 @@ public type BackgroundOption: | @@ -701,6 +703,7 @@ public type BackgroundOption: | ||
| 701 | 703 | ||
| 702 | 704 | ||
| 703 | public type Cell_Option: | 705 | public type Cell_Option: |
| 706 | + core_attrs(List(CoreAttrs)), | ||
| 704 | left, // put the content of the cell on the left | 707 | left, // put the content of the cell on the left |
| 705 | h_center, // center the content of the cell horizontally | 708 | h_center, // center the content of the cell horizontally |
| 706 | right, // put the content of the cell on the right | 709 | right, // put the content of the cell on the right |
| @@ -724,6 +727,9 @@ public type Cell_Option: | @@ -724,6 +727,9 @@ public type Cell_Option: | ||
| 724 | 727 | ||
| 725 | public type HTML_Cell($T): | 728 | public type HTML_Cell($T): |
| 726 | cell(List(Cell_Option) options, $T content). | 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 | The parameter $T is later instantiated either to 'HTML_In_Form' or to 'HTML_Off_Form', | 734 | The parameter $T is later instantiated either to 'HTML_In_Form' or to 'HTML_Off_Form', |
| 729 | depending on where you put your table (within a form or not within a form). For your | 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,10 +742,20 @@ public define HTML_Cell($T) | ||
| 736 | ) = | 742 | ) = |
| 737 | cell([],content). | 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 | public type HTML_Row($T): | 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 | Same remark as for 'HTML_Cell($T)'. We define several convenience functions: | 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,6 +772,20 @@ public define HTML_Row($T) | ||
| 756 | HTML_Cell($T) cell | 772 | HTML_Cell($T) cell |
| 757 | ) = | 773 | ) = |
| 758 | row([],[cell]). | 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 | public type Actioner_Connection: | 790 | public type Actioner_Connection: |
| 761 | same, // use same type of connection as current page | 791 | same, // use same type of connection as current page |
| @@ -835,7 +865,7 @@ public type HTML_In_Form: | @@ -835,7 +865,7 @@ public type HTML_In_Form: | ||
| 835 | paragraph (List(Text_Option), String the_text), | 865 | paragraph (List(Text_Option), String the_text), |
| 836 | image (String url), | 866 | image (String url), |
| 837 | image (String url, Int32 width, Int32 height), | 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 | center (HTML_In_Form), | 869 | center (HTML_In_Form), |
| 840 | mail_to (String email, HTML_In_Form element), | 870 | mail_to (String email, HTML_In_Form element), |
| 841 | scroller (Int32 width, Int32 height, | 871 | scroller (Int32 width, Int32 height, |
| @@ -907,8 +937,23 @@ public define HTML_In_Form | @@ -907,8 +937,23 @@ public define HTML_In_Form | ||
| 907 | ( | 937 | ( |
| 908 | List(HTML_Row(HTML_In_Form)) rows | 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 | public define HTML_In_Form | 958 | public define HTML_In_Form |
| 914 | private_download | 959 | private_download |
| @@ -949,7 +994,7 @@ public type HTML_Off_Form: | @@ -949,7 +994,7 @@ public type HTML_Off_Form: | ||
| 949 | paragraph (List(Text_Option), String the_text), | 994 | paragraph (List(Text_Option), String the_text), |
| 950 | image (String url), | 995 | image (String url), |
| 951 | image (String url, Int32 width, Int32 height), | 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 | center (HTML_Off_Form), | 998 | center (HTML_Off_Form), |
| 954 | mail_to (String email, HTML_Off_Form element), | 999 | mail_to (String email, HTML_Off_Form element), |
| 955 | scroller (Int32 width, Int32 height, | 1000 | scroller (Int32 width, Int32 height, |
| @@ -1005,10 +1050,24 @@ public define HTML_Off_Form | @@ -1005,10 +1050,24 @@ public define HTML_Off_Form | ||
| 1005 | ( | 1050 | ( |
| 1006 | List(HTML_Row(HTML_Off_Form)) rows | 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 | We add two convenience functions for 'row'. The reason why we add two functions, one | 1071 | We add two convenience functions for 'row'. The reason why we add two functions, one |
| 1013 | for 'HTML_In_Form' and one for 'HTML_Off_Form', is that adding a schema with an | 1072 | for 'HTML_In_Form' and one for 'HTML_Off_Form', is that adding a schema with an |
| 1014 | arbitrary '$T' creates too many ambiguities. This is due to the fact that, if we do so, | 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,7 +2215,7 @@ type HTML_Any($T): | ||
| 2156 | any_paragraph (List(Text_Option), String the_text), | 2215 | any_paragraph (List(Text_Option), String the_text), |
| 2157 | any_image (String url), | 2216 | any_image (String url), |
| 2158 | any_image (String url, Int32 width, Int32 height), | 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 | any_center ($T), | 2219 | any_center ($T), |
| 2161 | any_mail_to (String email, $T element), | 2220 | any_mail_to (String email, $T element), |
| 2162 | any_scroller (Int32 width, Int32 height, | 2221 | any_scroller (Int32 width, Int32 height, |
| @@ -2985,6 +3044,7 @@ define String | @@ -2985,6 +3044,7 @@ define String | ||
| 2985 | [h . t] then | 3044 | [h . t] then |
| 2986 | if h is | 3045 | if h is |
| 2987 | { | 3046 | { |
| 3047 | + core_attrs(core_attr_list) then format_coreattrs(core_attr_list), | ||
| 2988 | left then " align=left", | 3048 | left then " align=left", |
| 2989 | h_center then " align=center", | 3049 | h_center then " align=center", |
| 2990 | right then " align=right", | 3050 | right then " align=right", |
| @@ -3037,7 +3097,22 @@ define Printable_tree | @@ -3037,7 +3097,22 @@ define Printable_tree | ||
| 3037 | . format(t,format_element)] | 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 | Formating the rows in a table. | 3116 | Formating the rows in a table. |
| 3042 | 3117 | ||
| 3043 | define Printable_tree | 3118 | define Printable_tree |
| @@ -3056,7 +3131,21 @@ define Printable_tree | @@ -3056,7 +3131,21 @@ define Printable_tree | ||
| 3056 | . format(t,format_element)] | 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 | define Printable_tree | 3150 | define Printable_tree |
| 3062 | format1 | 3151 | format1 |
| @@ -3313,8 +3402,10 @@ define Printable_tree | @@ -3313,8 +3402,10 @@ define Printable_tree | ||
| 3313 | ["<img alt=\"",url,"\" src=\"",url,"\">"], | 3402 | ["<img alt=\"",url,"\" src=\"",url,"\">"], |
| 3314 | any_image(url,w,h) then | 3403 | any_image(url,w,h) then |
| 3315 | ["<img alt=\"",url,"\" src=\"",url,"\" width=",w," height=",h,">"], | 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 | any_center(e) then | 3409 | any_center(e) then |
| 3319 | ["<center>",format_element(e),"</center>"], | 3410 | ["<center>",format_element(e),"</center>"], |
| 3320 | any_mail_to(email,elem) then | 3411 | any_mail_to(email,elem) then |
| @@ -3382,8 +3473,8 @@ define Printable_tree | @@ -3382,8 +3473,8 @@ define Printable_tree | ||
| 3382 | format(cinfo,sn,ic_v,any_image(url),format_element,is_https), | 3473 | format(cinfo,sn,ic_v,any_image(url),format_element,is_https), |
| 3383 | image(url,w,h) then | 3474 | image(url,w,h) then |
| 3384 | format(cinfo,sn,ic_v,any_image(url,w,h),format_element,is_https), | 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 | center(e) then | 3478 | center(e) then |
| 3388 | format(cinfo,sn,ic_v,any_center(e),format_element,is_https), | 3479 | format(cinfo,sn,ic_v,any_center(e),format_element,is_https), |
| 3389 | mail_to(a,e) then | 3480 | mail_to(a,e) then |
| @@ -3472,7 +3563,7 @@ define Bool | @@ -3472,7 +3563,7 @@ define Bool | ||
| 3472 | paragraph(o,t) then false, | 3563 | paragraph(o,t) then false, |
| 3473 | image(u) then false, | 3564 | image(u) then false, |
| 3474 | image(u,w,h) then false, | 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 | center(e) then contains_an_upload(e), | 3567 | center(e) then contains_an_upload(e), |
| 3477 | mail_to(m,e) then false, // 'e' may but should not contain an upload | 3568 | mail_to(m,e) then false, // 'e' may but should not contain an upload |
| 3478 | scroller(w,h,cw,ch,e) then contains_an_upload(e), | 3569 | scroller(w,h,cw,ch,e) then contains_an_upload(e), |
| @@ -3531,8 +3622,8 @@ define Printable_tree | @@ -3531,8 +3622,8 @@ define Printable_tree | ||
| 3531 | format(cinfo,sn,ic_v,any_image(url),format_element,is_https), | 3622 | format(cinfo,sn,ic_v,any_image(url),format_element,is_https), |
| 3532 | image(url,w,h) then | 3623 | image(url,w,h) then |
| 3533 | format(cinfo,sn,ic_v,any_image(url,w,h),format_element,is_https), | 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 | center(e) then | 3627 | center(e) then |
| 3537 | format(cinfo,sn,ic_v,any_center(e),format_element,is_https), | 3628 | format(cinfo,sn,ic_v,any_center(e),format_element,is_https), |
| 3538 | mail_to(a,e) then | 3629 | mail_to(a,e) then |