Commit e1abfee506ab725ab7574f42f06a6f6bd9bbc4d8

Authored by David RENE
1 parent 040221f2

add img_link and foreign_link with Actioner_Target and Actioner_Aspect

Showing 1 changed file with 92 additions and 6 deletions   Show diff stats
calexium_lib/web/CXM_making_a_web_site.anubis
... ... @@ -916,7 +916,8 @@ public type Actioner_Target:
916 916 other(String window_name, List(Other_Window_Option)).
917 917  
918 918 public type Actioner_Aspect:
919   - link (List(Text_Option),String text, Maybe(String) name), // hypertext link
  919 + link (List(Text_Option), String url, Maybe(String) name),// hypertext link
  920 + img_link (String url, String img_url),
920 921 push_button (List(CoreAttrs),String text),
921 922 button (String url_off, String url_on), // rollover button
922 923 button (String url_off, String url_on, Int32 w, Int32 h), // idem with size
... ... @@ -993,9 +994,10 @@ public type HTML_In_Form:
993 994 HTML_In_Form content),
994 995 actioner (Actioner_Connection, Actioner_Target, Actioner_Aspect,
995 996 String action_name, List((String,String)) extra_ops,
996   - List(Actioner_Local_Action)),
  997 + List(Actioner_Local_Action)),
  998 + foreign_link_new (Actioner_Target, Actioner_Aspect, String url),
997 999 foreign_link (List(Text_Option), String url),
998   - foreign_link (List(Text_Option), String url, String name),
  1000 + foreign_link (List(Text_Option), String url, String name),
999 1001 private_download (String abs_path, String name, String extra_ext,
1000 1002 Maybe((String,List((String,String)))) action),
1001 1003 text_input (List(InputAttrs), String label_text, HtmlId id, WebArgName name, InitialValue init, Int32 width),
... ... @@ -1178,6 +1180,7 @@ public type HTML_Off_Form:
1178 1180 actioner (Actioner_Connection, Actioner_Target, Actioner_Aspect,
1179 1181 String action_name, List((String,String)) extra_ops,
1180 1182 List(Actioner_Local_Action), String form_name),
  1183 + foreign_link_new (Actioner_Target, Actioner_Aspect, String url),
1181 1184 foreign_link (List(Text_Option), String url),
1182 1185 foreign_link (List(Text_Option), String url, String name),
1183 1186 private_download (String abs_path, String name, String extra_ext,
... ... @@ -2409,6 +2412,7 @@ type HTML_Any($T):
2409 2412 List((String,String)) extra_ops,
2410 2413 List(Actioner_Local_Action),
2411 2414 Maybe(String) form_name),
  2415 + any_foreign_link_new (Actioner_Target, Actioner_Aspect, String url),
2412 2416 any_foreign_link (List(Text_Option), String url),
2413 2417 any_foreign_link (List(Text_Option), String url, String name),
2414 2418 any_private_download (String abs_path, String name, String extra_ext,
... ... @@ -2800,10 +2804,27 @@ define String
2800 2804 same then strict_url,
2801 2805 same(label) then strict_url+"#"+label,
2802 2806 other(wn,ops) then
  2807 +
2803 2808 "javascript:void window.open('"+strict_url+"&t="+wn+"','"+
2804 2809 "w"+to_ascii(sha1(wn))+"','"+format(ops)+"')"
2805 2810 }.
2806 2811  
  2812 +define String
  2813 + make_foreign_link_url
  2814 + (
  2815 + Actioner_Target target,
  2816 + String url
  2817 + ) =
  2818 + if target is
  2819 + {
  2820 + same then "/",
  2821 + same(label) then "/#"+label,
  2822 + other(wn,ops) then
  2823 +
  2824 + "javascript:void window.open('"+url+"','"+
  2825 + "w"+to_ascii(sha1(wn))+"','"+format(ops)+"')"
  2826 + }.
  2827 +
2807 2828  
2808 2829 Depending on the fact that the actioner refers to a form or not, the URL is used in two
2809 2830 different ways. If the actioner does not refer to a form, it is realized by a '<a>'
... ... @@ -3096,6 +3117,7 @@ define Maybe(String)
3096 3117 if aspect is
3097 3118 {
3098 3119 link(_,_,_) then failure,
  3120 + img_link(_,_) then failure,
3099 3121 push_button(opts,_) then extract_id(opts),
3100 3122 button(_,_) then failure,
3101 3123 button(_,_,_,_) then failure,
... ... @@ -3103,7 +3125,55 @@ define Maybe(String)
3103 3125 immediate_selector(_,_,_) then failure,
3104 3126 immediate_selector(_,_,_,_) then failure,
3105 3127 }.
3106   -
  3128 +
  3129 +to do Complete format_foreign_link
  3130 +//TODO Complete format_foreign_link
  3131 +define Printable_tree
  3132 + format_foreign_link
  3133 + (
  3134 +// CommonInfo cinfo,
  3135 + Actioner_Target target,
  3136 + Actioner_Aspect aspect,
  3137 + String url,
  3138 + Bool is_https,
  3139 + ) =
  3140 + //if cinfo is info(common_name,http_port,https_port,site_dir,secret) then
  3141 + with url = make_foreign_link_url(target,url),
  3142 +// with action = format_action(url, aspect, extract_id(aspect), mb_form_name),
  3143 + if aspect is
  3144 + {
  3145 +
  3146 + link(opt, text, mb_name) then
  3147 + with name_tag = if mb_name is success(n) then " name=\"" + n + "\"" else "",
  3148 + [
  3149 + "<a href=\"", url, "\"", format_text_options(opt), name_tag, ">",
  3150 + text,
  3151 + "</a>"
  3152 + ],
  3153 + img_link(_, img) then
  3154 + [
  3155 + "<a href=\"", url ,"\"><img src=\"", img,
  3156 + "\" border=\"0\"></a>"
  3157 + ],
  3158 + push_button(options, text) then
  3159 + ["<a href=\"",url,"\"", format_attrs(options), ">",
  3160 + text, "</a>"
  3161 + ],
  3162 + button(url_off,url_on) then
  3163 + [ ],
  3164 +
  3165 + button(url_off,url_on,w,h) then
  3166 + [ ],
  3167 +
  3168 + submit(options, text) then
  3169 + [ ],
  3170 +
  3171 + immediate_selector(name,size,choices) then
  3172 + [ ],
  3173 + immediate_selector(name,size,choices,selected) then
  3174 + [ ],
  3175 + }.
  3176 +
3107 3177 define Printable_tree
3108 3178 format_actioner
3109 3179 (
... ... @@ -3132,7 +3202,11 @@ define Printable_tree
3132 3202 text,
3133 3203 "</a>"
3134 3204 ],
3135   -
  3205 + img_link(url1, img) then
  3206 + [
  3207 + "<a href=\"", url ,"\"><img src=\"", img,
  3208 + "\" border=\"0\"></a>"
  3209 + ],
3136 3210 push_button(options, text) then
3137 3211 [
3138 3212 if action is
... ... @@ -3226,6 +3300,7 @@ define Printable_tree
3226 3300 if aspect is
3227 3301 {
3228 3302 link(opt,text,name) then [text],
  3303 + img_link(url, img_url) then [url],
3229 3304 push_button(opt, text) then [text],
3230 3305 button(url_off,url_on) then
3231 3306 [
... ... @@ -3689,6 +3764,10 @@ define Printable_tree
3689 3764 "</object>"],
3690 3765 any_actioner(c,t,a,an,eo,ja,fn) then
3691 3766 format_actioner(cinfo,sn,c,t,a,an,eo,ja,fn,is_https),
  3767 +
  3768 + any_foreign_link_new(target, aspect, url) then
  3769 + format_foreign_link(target, aspect, url, is_https),
  3770 +
3692 3771 any_foreign_link(options,url) then
3693 3772 ["<a href=\"",url,"\" ", format_text_options(options), "></a>"], // IE7 doesn't support the form <a href="..." />
3694 3773 any_foreign_link(options,url,name) then
... ... @@ -3755,7 +3834,11 @@ define Printable_tree
3755 3834 scroller(w,h,cw,ch,c) then
3756 3835 format(cinfo,sn,ic_v,any_scroller(w,h,cw,ch,c),format_element,is_https),
3757 3836 actioner(c,t,a,an,eo,ja) then
3758   - format(cinfo,sn,ic_v,any_actioner(c,t,a,an,eo,ja,success(fn)),format_element,is_https),
  3837 + format(cinfo,sn,ic_v,any_actioner(c,t,a,an,eo,ja,success(fn)),format_element,is_https),
  3838 +
  3839 + foreign_link_new(target, aspect, url) then
  3840 + format(cinfo,sn,ic_v,any_foreign_link_new(target,aspect,url),format_element,is_https),
  3841 +
3759 3842 foreign_link(options,url) then
3760 3843 format(cinfo,sn,ic_v,any_foreign_link(options,url),format_element,is_https),
3761 3844 foreign_link(options,url,name) then
... ... @@ -3868,6 +3951,7 @@ define Bool
3868 3951 mail_to(m,e) then false, // 'e' may but should not contain an upload
3869 3952 scroller(w,h,cw,ch,e) then contains_an_upload(e),
3870 3953 actioner(c,t,a,an,eo,ja) then false,
  3954 + foreign_link_new(_,_,_) then false,
3871 3955 foreign_link(o,u) then false,
3872 3956 foreign_link(o,u,n) then false,
3873 3957 private_download(p,n,e,a) then false,
... ... @@ -3942,6 +4026,8 @@ define Printable_tree
3942 4026 format(cinfo,sn,ic_v,any_actioner(c,t,a,an,eo,ja,failure),format_element,is_https),
3943 4027 actioner(c,t,a,an,eo,ja,fn) then
3944 4028 format(cinfo,sn,ic_v,any_actioner(c,t,a,an,eo,ja,success(fn)),format_element,is_https),
  4029 + foreign_link_new(target, aspect, url) then
  4030 + format(cinfo,sn,ic_v,any_foreign_link_new(target,aspect,url),format_element,is_https),
3945 4031 foreign_link(options,url) then
3946 4032 format(cinfo,sn,ic_v,any_foreign_link(options,url),format_element,is_https),
3947 4033 foreign_link(options,url,name) then
... ...