Commit 3d9045271130969a8c81c3e2924e6bdf7aa1bdc9

Authored by Cédric RICARD
1 parent 466acef1

Removing Prefix (o, p, f) on input and form names

Showing 1 changed file with 33 additions and 49 deletions   Show diff stats
calexium_lib/web/CXM_making_a_web_site.anubis
@@ -1974,21 +1974,9 @@ define Int @@ -1974,21 +1974,9 @@ define Int
1974 1974
1975 *** [3.1] Prefixing web arguments names. 1975 *** [3.1] Prefixing web arguments names.
1976 1976
1977 - We want to assign different roles to web arguments, and we also want to be able to  
1978 - recognize its role directly from the name of a web argument. The name "s" is reserved  
1979 - for the web argument whose value is the name of the current state. The name "a" is  
1980 - reserved for the web argument whose value is the name of the action to be  
1981 - performed. Other web arguments receive arbitrary names, and in order to avoid clashes,  
1982 - these names are prefixed by:  
1983 -  
1984 - "p" for names of password inputs,  
1985 - "o" for other web arguments  
1986 -  
1987 - The reason why password input names have a distinct prefix is that this allows the HTTP  
1988 - server to hide the passwords on the console of the server and in the journal. 1977 + CR 2008-07-08 Prefixing Removed
  1978 +
1989 1979
1990 -  
1991 -  
1992 1980
1993 *** [3.2] Separating web arguments. 1981 *** [3.2] Separating web arguments.
1994 1982
@@ -2047,23 +2035,19 @@ define (List(Web_arg) lwa) -> Separated_Web_Args($State) @@ -2047,23 +2035,19 @@ define (List(Web_arg) lwa) -> Separated_Web_Args($State)
2047 then 2035 then
2048 if wa_1 is 2036 if wa_1 is
2049 { 2037 {
2050 - web_arg(n,v) then  
2051 - with prefix = if substr(n,0,4) = "amp;" then substr(n,4,1) else substr(n,0,1),  
2052 - name_start = (Int)(if substr(n,0,4) = "amp;" then 5 else 1),  
2053 - if prefix = "s" then  
2054 - swa(success(retrieve_state(v)),an1,op1) else  
2055 - if prefix = "a" then  
2056 - swa(ps1,success(v),op1) else  
2057 - if prefix = "t" then  
2058 - swa(ps1,an1,[web_arg("target",v) . op1]) else  
2059 - if prefix = "p" then  
2060 - swa(ps1,an1,[web_arg(substr(n,name_start,length(n)-name_start),v) . op1]) else  
2061 - if prefix = "o" then  
2062 - swa(ps1,an1,[web_arg(substr(n,name_start,length(n)-name_start),v) . op1]) else  
2063 - swa(ps1,an1,op1), 2038 + web_arg(n, value) then
  2039 + with name = if substr(n,0,4) = "amp;" then substr(n, 4, length(n) - 4) else n,
  2040 + if name = "s" then
  2041 + swa(success(retrieve_state(value)),an1,op1)
  2042 + else if name = "a" then
  2043 + swa(ps1,success(value),op1)
  2044 + else if name = "t" then
  2045 + swa(ps1,an1,[web_arg("target",value) . op1])
  2046 + else
  2047 + swa(ps1,an1,[wa_1 . op1]),
2064 2048
2065 upload(n,v,t) then 2049 upload(n,v,t) then
2066 - swa(ps1,an1,[upload(substr(n,1,length(n)-1),v,t) . op1]) 2050 + swa(ps1,an1,[wa_1 . op1])
2067 }} 2051 }}
2068 }. 2052 }.
2069 2053
@@ -2716,7 +2700,7 @@ define String @@ -2716,7 +2700,7 @@ define String
2716 { 2700 {
2717 [ ] then "", 2701 [ ] then "",
2718 [h . t] then if h is (n,v) then 2702 [h . t] then if h is (n,v) then
2719 - "&o"+n+"="+v+format_extra_operands(t) 2703 + "&"+n+"="+v+format_extra_operands(t)
2720 }. 2704 }.
2721 2705
2722 2706
@@ -2910,7 +2894,7 @@ define URL_or_JavaScript @@ -2910,7 +2894,7 @@ define URL_or_JavaScript
2910 [ 2894 [
2911 "<script type=\"text/javascript\" language =\"JavaScript\">\n", 2895 "<script type=\"text/javascript\" language =\"JavaScript\">\n",
2912 "function ", fn_name, "() {\n", 2896 "function ", fn_name, "() {\n",
2913 - " var fa = document.forms.f",form_name,";\n", 2897 + " var fa = document.forms.",form_name,";\n",
2914 " var u = \"",the_url,"\";\n", 2898 " var u = \"",the_url,"\";\n",
2915 " fa.action = u;", 2899 " fa.action = u;",
2916 if aspect is submit(_, _) then " }\n" 2900 if aspect is submit(_, _) then " }\n"
@@ -3315,7 +3299,7 @@ define Printable_tree @@ -3315,7 +3299,7 @@ define Printable_tree
3315 url(u) then ["<select href=\"",u] 3299 url(u) then ["<select href=\"",u]
3316 javascript(s,h) then [s,"<select onchange=\"",h] 3300 javascript(s,h) then [s,"<select onchange=\"",h]
3317 }, 3301 },
3318 - "\" name=\"o",name,"\" size=\"",size,"\"", format_attrs(options), ">", 3302 + "\" name=\"",name,"\" size=\"",size,"\"", format_attrs(options), ">",
3319 format_choices(choices),"</select>" 3303 format_choices(choices),"</select>"
3320 ], 3304 ],
3321 immediate_selector(options,name,size,choices,selected) then 3305 immediate_selector(options,name,size,choices,selected) then
@@ -3324,7 +3308,7 @@ define Printable_tree @@ -3324,7 +3308,7 @@ define Printable_tree
3324 url(u) then ["<select href=\"",u] 3308 url(u) then ["<select href=\"",u]
3325 javascript(s,h) then [s,"<select onchange=\"",h] 3309 javascript(s,h) then [s,"<select onchange=\"",h]
3326 }, 3310 },
3327 - "\" name=\"o",name,"\" size=\"",size,"\"", format_attrs(options), ">", 3311 + "\" name=\"",name,"\" size=\"",size,"\"", format_attrs(options), ">",
3328 format_choices(choices, selected),"</select>" 3312 format_choices(choices, selected),"</select>"
3329 ], 3313 ],
3330 }. 3314 }.
@@ -3857,49 +3841,49 @@ define Printable_tree @@ -3857,49 +3841,49 @@ define Printable_tree
3857 format(cinfo,sn,ic_v,any_private_download(url,name,extra,action),format_element,is_https), 3841 format(cinfo,sn,ic_v,any_private_download(url,name,extra,action),format_element,is_https),
3858 text_input(options, label_text, id, name, i, w) then 3842 text_input(options, label_text, id, name, i, w) then
3859 [ maybe_label(label_text, id), 3843 [ maybe_label(label_text, id),
3860 - "<input type=\"text\" name=\"o",name,"\" id=\"",id,"\" size=\"",w,"\" value=\"",i,"\"",format_attrs(options)," />"], 3844 + "<input type=\"text\" name=\"",name,"\" id=\"",id,"\" size=\"",w,"\" value=\"",i,"\"",format_attrs(options)," />"],
3861 text_input_ro(options, label_text, id, name,i,w) then 3845 text_input_ro(options, label_text, id, name,i,w) then
3862 [ maybe_label(label_text, id), 3846 [ maybe_label(label_text, id),
3863 - "<input readonly=\"readonly\" type=\"text\" name=\"o",name,"\" id=\"",id,"\" size=\"",w,"\" value=\"",i,"\"",format_attrs(options)," />"], 3847 + "<input readonly=\"readonly\" type=\"text\" name=\"",name,"\" id=\"",id,"\" size=\"",w,"\" value=\"",i,"\"",format_attrs(options)," />"],
3864 password_input(options, label_text, id, name,i,w) then 3848 password_input(options, label_text, id, name,i,w) then
3865 [ maybe_label(label_text, id), 3849 [ maybe_label(label_text, id),
3866 - "<input type=\"password\" name=\"p",name,"\" id=\"",id,"\" size=\"",w,"\" value=\"",i,"\"",format_attrs(options)," />"], 3850 + "<input type=\"password\" name=\"",name,"\" id=\"",id,"\" size=\"",w,"\" value=\"",i,"\"",format_attrs(options)," />"],
3867 text_area(opts,label_text, id, n,i,w,h) then 3851 text_area(opts,label_text, id, n,i,w,h) then
3868 - [ maybe_label(label_text, id), "<textarea ",format(opts)," id=\"",id,"\" name=\"o",n,"\" cols=\"",w,"\" rows=\"",h,"\">",i,"</textarea>"], 3852 + [ maybe_label(label_text, id), "<textarea ",format(opts)," id=\"",id,"\" name=\"",n,"\" cols=\"",w,"\" rows=\"",h,"\">",i,"</textarea>"],
3869 file_upload(options, label, id, n, w) then 3853 file_upload(options, label, id, n, w) then
3870 [ maybe_label(label, id), 3854 [ maybe_label(label, id),
3871 - "<input type=\"file\" id=\"",id,"\" size=\"",w,"\" name=\"o",n,"\"",format_attrs(options)," />"], 3855 + "<input type=\"file\" id=\"",id,"\" size=\"",w,"\" name=\"",n,"\"",format_attrs(options)," />"],
3872 selector(opts, label, id, n,s,cs) then 3856 selector(opts, label, id, n,s,cs) then
3873 [ maybe_label(label, id), 3857 [ maybe_label(label, id),
3874 - "<select id=\"",id,"\" name=\"o",n,"\" size=\"",s,"\" ",format_attrs(opts),">",format_choices(cs),"</select>"], 3858 + "<select id=\"",id,"\" name=\"",n,"\" size=\"",s,"\" ",format_attrs(opts),">",format_choices(cs),"</select>"],
3875 selector(opts, label, id, n,s,cs,sd) then 3859 selector(opts, label, id, n,s,cs,sd) then
3876 [ maybe_label(label, id), 3860 [ maybe_label(label, id),
3877 - "<select id=\"",id,"\" name=\"o",n,"\" size=\"",s,"\" ",format_attrs(opts),">",format_choices(cs,sd),"</select>"], 3861 + "<select id=\"",id,"\" name=\"",n,"\" size=\"",s,"\" ",format_attrs(opts),">",format_choices(cs,sd),"</select>"],
3878 selector_c(opts, label, id, n,s,cs) then 3862 selector_c(opts, label, id, n,s,cs) then
3879 [ maybe_label(label, id), 3863 [ maybe_label(label, id),
3880 - "<select id=\"",id,"\" name=\"o",n,"\" size=\"",s,"\" ",format_attrs(opts),">",format_choices(cs),"</select>"], 3864 + "<select id=\"",id,"\" name=\"",n,"\" size=\"",s,"\" ",format_attrs(opts),">",format_choices(cs),"</select>"],
3881 selector_c(opts, label, id, n,s,cs,sd) then 3865 selector_c(opts, label, id, n,s,cs,sd) then
3882 [ maybe_label(label, id), 3866 [ maybe_label(label, id),
3883 - "<select id=\"",id,"\" name=\"o",n,"\" size=\"",s,"\" ",format_attrs(opts),">",format_choices(cs,sd),"</select>"], 3867 + "<select id=\"",id,"\" name=\"",n,"\" size=\"",s,"\" ",format_attrs(opts),">",format_choices(cs,sd),"</select>"],
3884 3868
3885 radio_button(options, label_text, id, n, v, c) then 3869 radio_button(options, label_text, id, n, v, c) then
3886 [ maybe_label(label_text, id), 3870 [ maybe_label(label_text, id),
3887 - "<input type=\"radio\" name=\"o",n,"\" id=\"",id,"\" value=\"",v,"\"",(if c then " checked=\"checked\"" else ""),format_attrs(options)," />"], 3871 + "<input type=\"radio\" name=\"",n,"\" id=\"",id,"\" value=\"",v,"\"",(if c then " checked=\"checked\"" else ""),format_attrs(options)," />"],
3888 radio_button_r(options, label_text, id, n, v, c) then 3872 radio_button_r(options, label_text, id, n, v, c) then
3889 - [ "<input type=\"radio\" name=\"o",n,"\" id=\"",id,"\" value=\"",v,"\"",(if c then " checked=\"checked\"" else ""),format_attrs(options)," />", 3873 + [ "<input type=\"radio\" name=\"",n,"\" id=\"",id,"\" value=\"",v,"\"",(if c then " checked=\"checked\"" else ""),format_attrs(options)," />",
3890 maybe_label(label_text, id)], 3874 maybe_label(label_text, id)],
3891 check_box(options, label_text, id, n, v, c) then 3875 check_box(options, label_text, id, n, v, c) then
3892 [ maybe_label(label_text, id), 3876 [ maybe_label(label_text, id),
3893 - "<input type=\"checkbox\" name=\"o",n,"\" id=\"",id,"\" value=\"",v,"\"",(if c then " checked=\"checked\" " else ""),format_attrs(options)," />"] 3877 + "<input type=\"checkbox\" name=\"",n,"\" id=\"",id,"\" value=\"",v,"\"",(if c then " checked=\"checked\" " else ""),format_attrs(options)," />"]
3894 check_box_r(options, label_text, id, n, v, c) then 3878 check_box_r(options, label_text, id, n, v, c) then
3895 - [ "<input type=\"checkbox\" name=\"o",n,"\" id=\"",id,"\" value=\"",v,"\"",(if c then " checked=\"checked\" " else ""),format_attrs(options)," />", 3879 + [ "<input type=\"checkbox\" name=\"",n,"\" id=\"",id,"\" value=\"",v,"\"",(if c then " checked=\"checked\" " else ""),format_attrs(options)," />",
3896 maybe_label(label_text, id)] 3880 maybe_label(label_text, id)]
3897 div(options, e) then 3881 div(options, e) then
3898 format(cinfo,sn,ic_v,any_div(options, e),format_element,is_https), 3882 format(cinfo,sn,ic_v,any_div(options, e),format_element,is_https),
3899 div_empty(options) then 3883 div_empty(options) then
3900 format(cinfo,sn,ic_v,any_div_empty(options),format_element,is_https), 3884 format(cinfo,sn,ic_v,any_div_empty(options),format_element,is_https),
3901 hidden(name, value) then 3885 hidden(name, value) then
3902 - ["<input type=\"hidden\" name=\"o",name,"\" value=\"",value,"\" />"], 3886 + ["<input type=\"hidden\" name=\"",name,"\" value=\"",value,"\" />"],
3903 3887
3904 }. 3888 }.
3905 3889
@@ -4047,7 +4031,7 @@ define Printable_tree @@ -4047,7 +4031,7 @@ define Printable_tree
4047 label(n) then ["<a name=\"",n,"\">"], 4031 label(n) then ["<a name=\"",n,"\">"],
4048 form(fn,attributs, c) then 4032 form(fn,attributs, c) then
4049 [ 4033 [
4050 - "<form id=\"f",fn,"\"", 4034 + "<form id=\"",fn,"\"",
4051 format(cinfo,sn,ic_v,any_coreattrs(attributs),format_element,is_https), 4035 format(cinfo,sn,ic_v,any_coreattrs(attributs),format_element,is_https),
4052 " method=\"post\"", 4036 " method=\"post\"",
4053 enctype(c), 4037 enctype(c),
@@ -4064,7 +4048,7 @@ define Printable_tree @@ -4064,7 +4048,7 @@ define Printable_tree
4064 with url = make_actioner_url(cinfo, same, same, 4048 with url = make_actioner_url(cinfo, same, same,
4065 sn, action_name, extra_ops, is_https), 4049 sn, action_name, extra_ops, is_https),
4066 [ 4050 [
4067 - "<form id=\"f",fn,"\"", 4051 + "<form id=\"",fn,"\"",
4068 format(cinfo,sn,ic_v,any_coreattrs(attributs),format_element,is_https), 4052 format(cinfo,sn,ic_v,any_coreattrs(attributs),format_element,is_https),
4069 " method=\"post\"", 4053 " method=\"post\"",
4070 enctype(c), 4054 enctype(c),