Commit 779844312939348ec5e8185c8978c680d04e2bb0

Authored by Cédric RICARD
1 parent d80e09a7

improved 'image' tag

Showing 1 changed file with 29 additions and 21 deletions   Show diff stats
calexium_lib/web/CXM_making_a_web_site.anubis
... ... @@ -985,8 +985,8 @@ public type HTML_In_Form:
985 985 text (List(Text_Option), String the_text),
986 986 preformated (List(Text_Option), String),
987 987 paragraph (List(Text_Option), HTML_In_Form content),
988   - image (String url),
989   - image (String url, Int32 width, Int32 height),
  988 + image (List(CoreAttrs), String url, String alternate),
  989 + image (List(CoreAttrs), String url, String alternate, Int32 width, Int32 height),
990 990 table (List(Table_Option), HTML_Header_Row(HTML_In_Form), List(HTML_Row(HTML_In_Form)), HTML_Footer_Row(HTML_In_Form)),
991 991 center (HTML_In_Form),
992 992 mail_to (String email, HTML_In_Form element),
... ... @@ -1027,6 +1027,10 @@ public type HTML_In_Form:
1027 1027  
1028 1028 public define HTML_In_Form literal(Printable_tree t) = literal_pt(t).
1029 1029  
  1030 +public define HTML_In_Form image(String url) = image([], url, url).
  1031 +
  1032 +public define HTML_In_Form image(String url, Int32 width, Int32 height) = image([], url, url, width, height).
  1033 +
1030 1034 public define HTML_In_Form
1031 1035 foreign_link
1032 1036 (
... ... @@ -1165,8 +1169,8 @@ public type HTML_Off_Form:
1165 1169 text (List(Text_Option), String the_text),
1166 1170 preformated (List(Text_Option), String),
1167 1171 paragraph (List(Text_Option), HTML_Off_Form content),
1168   - image (String url),
1169   - image (String url, Int32 width, Int32 height),
  1172 + image (List(CoreAttrs), String url, String alternate),
  1173 + image (List(CoreAttrs), String url, String alternate, Int32 width, Int32 height),
1170 1174 table (List(Table_Option), HTML_Header_Row(HTML_Off_Form), List(HTML_Row(HTML_Off_Form)), HTML_Footer_Row(HTML_Off_Form)),
1171 1175 center (HTML_Off_Form),
1172 1176 mail_to (String email, HTML_Off_Form element),
... ... @@ -1197,6 +1201,10 @@ public type HTML_Off_Form:
1197 1201 'HTML_Off_Form' defines all the elements you may put outside any form.
1198 1202  
1199 1203  
  1204 +public define HTML_Off_Form image(String url) = image([], url, url).
  1205 +
  1206 +public define HTML_Off_Form image(String url, Int32 width, Int32 height) = image([], url, url, width, height).
  1207 +
1200 1208 public define HTML_Off_Form
1201 1209 form
1202 1210 (
... ... @@ -2417,8 +2425,8 @@ type HTML_Any($T):
2417 2425 any_text (List(Text_Option), String the_text),
2418 2426 any_preformated (List(Text_Option), String),
2419 2427 any_paragraph (List(Text_Option), $T content),
2420   - any_image (String url),
2421   - any_image (String url, Int32 width, Int32 height),
  2428 + any_image (List(CoreAttrs), String url, String alternate),
  2429 + any_image (List(CoreAttrs), String url, String alternate, Int32 width, Int32 height),
2422 2430 any_table (List(Table_Option), HTML_Header_Row($T), List(HTML_Row($T)), HTML_Footer_Row($T)),
2423 2431 any_center ($T),
2424 2432 any_mail_to (String email, $T element),
... ... @@ -3759,10 +3767,10 @@ define Printable_tree
3759 3767 //["<pre>",s,"</pre>"],
3760 3768 any_paragraph(opts,e) then
3761 3769 ["<p ", format_text_options(opts), ">",format_element(e),"</p>\n"],
3762   - any_image(url) then
3763   - ["<img alt=\"",url,"\" src=\"",url,"\">"],
3764   - any_image(url,w,h) then
3765   - ["<img alt=\"",url,"\" src=\"",url,"\" width=",w," height=",h," />"],
  3770 + any_image(opts, url, alt) then
  3771 + ["<img alt=\"",alt,"\" src=\"",url,"\" ", format_attrs(opts)," />"],
  3772 + any_image(opts, url, alt, w, h) then
  3773 + ["<img alt=\"",alt,"\" src=\"",url,"\" width=\"",w,"\" height=\"",h,"\" ", format_attrs(opts)," />"],
3766 3774 any_table(opts,h_row, rows, f_row) then
3767 3775 ["<table ",format(reverse(opts),false),">",
3768 3776 format(h_row, format_element),
... ... @@ -3843,12 +3851,12 @@ define Printable_tree
3843 3851 format(cinfo,sn,ic_v,any_text(opts,t),format_element,is_https),
3844 3852 preformated(o,s) then
3845 3853 format(cinfo,sn,ic_v,any_preformated(o,s),format_element,is_https),
3846   - paragraph(opts,t) then
  3854 + paragraph(opts,t) then
3847 3855 format(cinfo,sn,ic_v,any_paragraph(opts,t),format_element,is_https),
3848   - image(url) then
3849   - format(cinfo,sn,ic_v,any_image(url),format_element,is_https),
3850   - image(url,w,h) then
3851   - format(cinfo,sn,ic_v,any_image(url,w,h),format_element,is_https),
  3856 + image(opts, url, alt) then
  3857 + format(cinfo,sn,ic_v,any_image(opts, url, alt),format_element,is_https),
  3858 + image(opts, url, alt, w, h) then
  3859 + format(cinfo,sn,ic_v,any_image(opts, url, alt, w, h),format_element,is_https),
3852 3860 table(opts,header_row,rows,footer_row) then
3853 3861 format(cinfo,sn,ic_v,any_table(opts, header_row, rows, footer_row),format_element,is_https),
3854 3862 center(e) then
... ... @@ -3967,8 +3975,8 @@ define Bool
3967 3975 text(o,t) then false,
3968 3976 preformated(o,s) then false,
3969 3977 paragraph(o,t) then false,
3970   - image(u) then false,
3971   - image(u,w,h) then false,
  3978 + image(o,u,a) then false,
  3979 + image(o,u,a,w,h) then false,
3972 3980 table(o,_,rows,f_row) then if mapor(contains_an_upload,rows) then true
3973 3981 else contains_an_upload(f_row),
3974 3982 center(e) then contains_an_upload(e),
... ... @@ -4030,10 +4038,10 @@ define Printable_tree
4030 4038 format(cinfo,sn,ic_v,any_preformated(o,s),format_element,is_https),
4031 4039 paragraph(opts,t) then
4032 4040 format(cinfo,sn,ic_v,any_paragraph(opts,t),format_element,is_https),
4033   - image(url) then
4034   - format(cinfo,sn,ic_v,any_image(url),format_element,is_https),
4035   - image(url,w,h) then
4036   - format(cinfo,sn,ic_v,any_image(url,w,h),format_element,is_https),
  4041 + image(opts,url,alt) then
  4042 + format(cinfo,sn,ic_v,any_image(opts,url,alt),format_element,is_https),
  4043 + image(opts,url,alt,w,h) then
  4044 + format(cinfo,sn,ic_v,any_image(opts,url,alt,w,h),format_element,is_https),
4037 4045 table(opts,header_row, rows, footer_row) then
4038 4046 format(cinfo,sn,ic_v,any_table(opts,header_row, rows, footer_row),format_element,is_https),
4039 4047 center(e) then
... ...