diff --git a/web/CXM_form.anubis b/web/CXM_form.anubis
index fa478bd..03ffb1e 100644
--- a/web/CXM_form.anubis
+++ b/web/CXM_form.anubis
@@ -67,14 +67,14 @@ public type CXM_Form_Field:
//--- text area field -----------------------------------------------------------------
text_area(
- List(TextAreaOption) options,
- HTML_Label label,
- HTML_Id id,
- WebArgName web_arg_name,
- InitialValue init_value,
- Width width,
- Int height,
- Mandatory mandatory
+ List(TextAreaOption) options,
+ HTML_Label label,
+ HTML_Id id,
+ WebArgName web_arg_name,
+ InitialValue init_value,
+ Width width,
+ Int height,
+ Mandatory mandatory
),
//--- password input field ------------------------------------------------------------
@@ -87,6 +87,28 @@ public type CXM_Form_Field:
Width width,
Mandatory mandatory),
+ //--- phone field ------------------------------------------------------------
+ phone_input(
+ List(CoreAttrs) icon_options,
+ List(CoreAttrs) options,
+ HTML_Label label,
+ HTML_Id id,
+ WebArgName web_arg_name,
+ InitialValue init_value,
+ Width width,
+ Mandatory mandatory),
+
+ //--- phone field ------------------------------------------------------------
+ email_input(
+ List(CoreAttrs) icon_options,
+ List(CoreAttrs) options,
+ HTML_Label label,
+ HTML_Id id,
+ WebArgName web_arg_name,
+ InitialValue init_value,
+ Width width,
+ Mandatory mandatory),
+
//--- hidden field ------------------------------------------------------------
hidden(
HTML_Id id,
@@ -489,7 +511,19 @@ public define HTML_In_Form
password_input(options, _label, id, name, init, w, mand) then
password_input([class("in") . options], star(_label, mand), id, name, init, pixels(w)),
-
+
+ phone_input(icon_options, options, _label, id, wan, default, w, mand) then
+ sequence([
+ image(icon_options, "/icons/16x16/phone.png", ""),
+ text_input([class("in") . options], star(_label, mand), id, wan, init(get_String(lwa, wan.name, default.value)), pixels(w)),
+ ]),
+
+ email_input(icon_options, options, _label, id, wan, default, w, mand) then
+ sequence([
+ image(icon_options, "/icons/16x16/email_edit.png", ""),
+ text_input([class("in") . options], star(_label, mand), id, wan, init(get_String(lwa, wan.name, default.value)), pixels(w)),
+ ])
+
hidden(id, name, init) then
hidden(id, name, init),
@@ -707,7 +741,7 @@ public define HTML_In_Form
)=
to_HTML_In_Form(fields, [], _class, b_with_label).
-public
+
public define HTML_Off_Form
cxm_form
diff --git a/web/CXM_making_a_web_site.anubis b/web/CXM_making_a_web_site.anubis
index 54725eb..3cf5a77 100644
--- a/web/CXM_making_a_web_site.anubis
+++ b/web/CXM_making_a_web_site.anubis
@@ -328,6 +328,10 @@ public type WEB_Controller_Result:
),
ajax(
HTTP_Answer http_answer
+ ),
+ ajax(
+ WEB_Session session, //modified session
+ HTTP_Answer http_answer //http answer
)
.
@@ -759,30 +763,7 @@ public type HTML_Size:
percentage(Int).
-public type Text_Option:
- size(Int), // size of character font to use
- font(String), // name of character font to use (such as "helvetica",...)
- color(RGB), // color to be used for characters
- italic,
- oblique,
- small_capitals,
- bold,
- underlined,
- left_justified,
- right_justified,
- justified, // justified on both sides
- line_through,
- nowrap,
- class(String), //CSS class
- id(String),
- style(String),
- title(String),
- attr(String, String).
-
-public define Text_Option
- tooltip(String s) = title(s).
-
- A list of 'Text_Option' must be given with each text you want to put in your page.
+
This indicate the way of reading text.
public type Reading_Way:
@@ -882,11 +863,38 @@ public type InputAttrs:
public define InputAttrs attr(String name, Bool value) = attr(name, if value then "true" else "false").
+public type Text_Option:
+ core_attrs(List(CoreAttrs)),
+ size(Int), // size of character font to use
+ font(String), // name of character font to use (such as "helvetica",...)
+ color(RGB), // color to be used for characters
+ italic,
+ oblique,
+ small_capitals,
+ bold,
+ underlined,
+ left_justified,
+ right_justified,
+ justified, // justified on both sides
+ line_through,
+ nowrap,
+ class(String), //CSS class
+ id(String),
+ style(String),
+ title(String),
+ attr(String, String).
+
+public define Text_Option
+ tooltip(String s) = title(s).
+
+ A list of 'Text_Option' must be given with each text you want to put in your page.
+
public define CoreAttrs
tooltip(String s) = title(s).
public define InputAttrs
tooltip(String s) = title(s).
+
public type I18n:
lang (String),
dir (Reading_Way).
@@ -1339,9 +1347,9 @@ public type HTML_In_Form:
literal_pt (Printable_tree),
literal (String),
sequence (List(HTML_In_Form) items),
- text (List(Text_Option), String the_text),
+ text (List(CoreAttrs), String the_text),
preformated (List(Text_Option), String),
- paragraph (List(Text_Option), HTML_In_Form content),
+ paragraph (List(Text_Option), List(HTML_In_Form) content),
image (List(CoreAttrs), String url, String alternate),
image (List(CoreAttrs), String url, String alternate, Int width, Int height),
table (List(Table_Option), HTML_Header_Row(HTML_In_Form), List(HTML_Row(HTML_In_Form)), HTML_Footer_Row(HTML_In_Form)),
@@ -1374,16 +1382,16 @@ public type HTML_In_Form:
radio_button_r (List(CoreAttrs), HTML_Label label, HTML_Id id, WebArgName name, WebArgValue value, Bool checked),
check_box (List(CoreAttrs), HTML_Label label, HTML_Id id, WebArgName name, WebArgValue value, Bool checked),
check_box_r (List(CoreAttrs), HTML_Label label, HTML_Id id, WebArgName name, WebArgValue value, Bool checked),
- div (List(CoreAttrs), HTML_In_Form content),
+ div (List(CoreAttrs), List(HTML_In_Form) content),
div_empty (List(CoreAttrs)),
hidden (HTML_Id id, WebArgName name, WebArgValue value),
partial (HTML_Partial_Content),
br,
progress (List(CoreAttrs), Int value, Int max),
- ol (List(CoreAttrs), HTML_In_Form content),
- ul (List(CoreAttrs), HTML_In_Form content),
- li (List(CoreAttrs), HTML_In_Form content),
- button (List(CoreAttrs), HTML_In_Form content),
+ ol (List(CoreAttrs), List(HTML_In_Form) content),
+ ul (List(CoreAttrs), List(HTML_In_Form) content),
+ li (List(CoreAttrs), List(HTML_In_Form) content),
+ button (List(CoreAttrs), List(HTML_In_Form) content),
i (List(CoreAttrs), String text),
span (List(CoreAttrs), String text),
hr (List(CoreAttrs))
@@ -1457,13 +1465,13 @@ public define HTML_In_Form
.
public define HTML_In_Form
- actioner
- (
- Actioner_Connection conn,
- Actioner_Target targ,
- Actioner_Aspect asp,
- ) =
- actioner(conn, targ, asp, action_name(""), [], []).
+ actioner
+ (
+ Actioner_Connection conn,
+ Actioner_Target targ,
+ Actioner_Aspect asp,
+ )=
+ actioner(conn, targ, asp, action_name(""), [], []).
public define HTML_In_Form
@@ -1542,12 +1550,12 @@ public define HTML_In_Form
public define HTML_In_Form
- text
- (
- List(Text_Option) lto,
- Int i
- ) =
- text(lto, to_decimal(i)).
+ text
+ (
+ List(CoreAttrs) l,
+ Int i
+ ) =
+ text(l, to_decimal(i)).
public define HTML_In_Form
text
@@ -1566,6 +1574,23 @@ public define HTML_In_Form
.
public define HTML_In_Form
+ div
+ (
+ HTML_In_Form element
+ )=
+ div([], [element])
+.
+
+public define HTML_In_Form
+ div
+ (
+ List(CoreAttrs) attrs,
+ HTML_In_Form element
+ )=
+ div(attrs, [element])
+.
+
+public define HTML_In_Form
span
(
String s
@@ -1613,9 +1638,9 @@ public type HTML_Off_Form:
literal_pt (Printable_tree),
literal (String),
sequence (List(HTML_Off_Form) items),
- text (List(Text_Option), String the_text),
+ text (List(CoreAttrs), String the_text),
preformated (List(Text_Option), String),
- paragraph (List(Text_Option), HTML_Off_Form content),
+ paragraph (List(Text_Option), List(HTML_Off_Form) content),
image (List(CoreAttrs), String url, String alternate),
image (List(CoreAttrs), String url, String alternate, Int width, Int height),
table (List(Table_Option), HTML_Header_Row(HTML_Off_Form), List(HTML_Row(HTML_Off_Form)), HTML_Footer_Row(HTML_Off_Form)),
@@ -1638,12 +1663,12 @@ public type HTML_Off_Form:
private_download (String abs_path, String name, String extra_ext,
Maybe((String,List((String,String)))) action),
label (String name),
- form (HTML_Id form_id, List(CoreAttrs), HTML_In_Form content),
+ form (HTML_Id form_id, List(CoreAttrs), List(HTML_In_Form) content),
form (HTML_Id form_id, List(CoreAttrs),
WEB_Action_Name action, List((String,String)) extra_ops,
- HTML_In_Form content),
+ List(HTML_In_Form) content),
in_form (HTML_Id form_id, HTML_In_Form content),
- div (List(CoreAttrs), HTML_Off_Form content),
+ div (List(CoreAttrs), List(HTML_Off_Form) content),
div (List(CoreAttrs), HTML_Partial_Content p_content),
div_empty (List(CoreAttrs)),
iframe (List(CoreAttrs),
@@ -1654,10 +1679,10 @@ public type HTML_Off_Form:
partial (HTML_Partial_Content),
br,
progress (List(CoreAttrs), Int value, Int max),
- ol (List(CoreAttrs), HTML_Off_Form content),
- ul (List(CoreAttrs), HTML_Off_Form content),
- li (List(CoreAttrs), HTML_Off_Form content),
- button (List(CoreAttrs), HTML_Off_Form content),
+ ol (List(CoreAttrs), List(HTML_Off_Form) content),
+ ul (List(CoreAttrs), List(HTML_Off_Form) content),
+ li (List(CoreAttrs), List(HTML_Off_Form) content),
+ button (List(CoreAttrs), List(HTML_Off_Form) content),
i (List(CoreAttrs), String text),
span (List(CoreAttrs), String text),
hr (List(CoreAttrs))
@@ -1667,7 +1692,7 @@ public type HTML_Off_Form:
public define HTML_Off_Form image(String url) = image([], url, url).
-
+public define HTML_Off_Form image(List(CoreAttrs) attrs, String url) = image(attrs, url, url).
public define HTML_Off_Form image(String url, Int width, Int height) = image([], url, url, width, height).
public define HTML_Off_Form
@@ -1677,7 +1702,16 @@ public define HTML_Off_Form
List(CoreAttrs) options,
HTML_In_Form content
) =
- form(html_Id(form_name), options, content).
+ form(html_Id(form_name), options, [content]).
+
+public define HTML_Off_Form
+ form
+ (
+ String form_name,
+ List(CoreAttrs) options,
+ List(HTML_In_Form) contents
+ ) =
+ form(html_Id(form_name), options, contents).
public define HTML_Off_Form
form
@@ -1688,19 +1722,52 @@ public define HTML_Off_Form
List((String,String)) extra_ops,
HTML_In_Form content
) =
- form(html_Id(form_name), options, action, extra_ops, content).
+ form(html_Id(form_name), options, action, extra_ops, [content]).
public define HTML_Off_Form
form
(
+ HTML_Id form_id,
+ List(CoreAttrs) options,
+ WEB_Action_Name action,
+ List((String,String)) extra_ops,
+ HTML_In_Form content
+ ) =
+ form(form_id, options, action, extra_ops, [content]).
+
+public define HTML_Off_Form
+ form
+ (
+ String form_name,
+ List(CoreAttrs) options,
+ WEB_Action_Name action,
+ List((String,String)) extra_ops,
+ List(HTML_In_Form) contents
+ ) =
+ form(html_Id(form_name), options, action, extra_ops, contents).
+
+public define HTML_Off_Form
+ form
+ (
String form_name,
List(CoreAttrs) options,
String action,
List((String,String)) extra_ops,
HTML_In_Form content
) =
- form(html_Id(form_name), options, action_name(action), extra_ops, content).
-
+ form(html_Id(form_name), options, action_name(action), extra_ops, [content]).
+
+public define HTML_Off_Form
+ form
+ (
+ String form_name,
+ List(CoreAttrs) options,
+ String action,
+ List((String,String)) extra_ops,
+ List(HTML_In_Form) contents
+ ) =
+ form(html_Id(form_name), options, action_name(action), extra_ops, contents).
+
public define HTML_Off_Form literal(Printable_tree t) = literal_pt(t).
public define HTML_Off_Form fixed_size(HTML_Size width, HTML_Size height, String name_of_HTML_file)
= fixed_size_2(width,height,name_of_HTML_file).
@@ -1728,6 +1795,15 @@ public define HTML_Off_Form
actioner(conn,targ,asp,action,extra_ops,[]).
public define HTML_Off_Form
+ actioner
+ (
+ Actioner_Aspect asp,
+ WEB_Action_Name action,
+ List((String,String)) extra_ops
+ ) =
+ actioner(same, same, asp, action, extra_ops, []).
+
+public define HTML_Off_Form
/* Older call with String as action instead of WEB_Action_Name.
* This function exists only for compatibility with older project.
* Please condiser to use above function instead
@@ -1852,13 +1928,13 @@ public define HTML_Off_Form
private_download(abs_path,name,extra_ext,success((action_name,args))).
public define HTML_Off_Form
- text
- (
- List(Text_Option) lto,
- Int i
- ) =
- text(lto,to_decimal(i)).
-
+ text
+ (
+ List(CoreAttrs) lto,
+ Int i
+ )=
+ text(lto, to_decimal(i))
+.
public define HTML_Off_Form
text
@@ -1875,9 +1951,133 @@ public define HTML_Off_Form
)=
text([], s)
.
-
-
+public define HTML_Off_Form
+ div
+ (
+ HTML_Off_Form element
+ )=
+ div([], [element])
+.
+
+public define HTML_Off_Form
+ div
+ (
+ List(CoreAttrs) attrs,
+ HTML_Off_Form element
+ )=
+ div(attrs, [element])
+.
+
+public define HTML_Off_Form
+ div
+ (
+ List(HTML_Off_Form) elements
+ )=
+ div([], elements)
+.
+
+
+public define HTML_Off_Form
+ li
+ (
+ List(HTML_Off_Form) elements
+ )=
+ li([], elements)
+.
+
+public define HTML_Off_Form
+ li
+ (
+ List(CoreAttrs) attrs,
+ HTML_Off_Form element
+ )=
+ li(attrs, [element])
+.
+
+public define HTML_Off_Form
+ li
+ (
+ HTML_Off_Form element
+ )=
+ li([], [element])
+.
+
+public define HTML_Off_Form
+ ul
+ (
+ List(HTML_Off_Form) elements
+ )=
+ ul([], elements)
+.
+
+public define HTML_Off_Form
+ ul
+ (
+ List(CoreAttrs) attrs,
+ HTML_Off_Form element
+ )=
+ ul(attrs, [element])
+.
+
+public define HTML_Off_Form
+ ul
+ (
+ HTML_Off_Form element
+ )=
+ ul([], [element])
+.
+
+public define HTML_Off_Form
+ ol
+ (
+ List(HTML_Off_Form) elements
+ )=
+ ol([], elements)
+.
+
+public define HTML_Off_Form
+ ol
+ (
+ List(CoreAttrs) attrs,
+ HTML_Off_Form element
+ )=
+ ol(attrs, [element])
+.
+
+public define HTML_Off_Form
+ ol
+ (
+ HTML_Off_Form element
+ )=
+ ol([], [element])
+.
+
+public define HTML_Off_Form
+ paragraph
+ (
+ List(HTML_Off_Form) elements
+ )=
+ paragraph([], elements)
+.
+
+public define HTML_Off_Form
+ paragraph
+ (
+ List(Text_Option) attrs,
+ HTML_Off_Form element
+ )=
+ paragraph(attrs, [element])
+.
+
+public define HTML_Off_Form
+ paragraph
+ (
+ HTML_Off_Form element
+ )=
+ paragraph([], [element])
+.
+
public define HTML_Off_Form
span
(
@@ -1906,38 +2106,87 @@ public define HTML_In_Form
hr([])
.
+public define HTML_In_Form
+ button
+ (
+ List(HTML_In_Form) elements
+ )=
+ button([], elements)
+.
+
+public define HTML_In_Form
+ button
+ (
+ List(CoreAttrs) attrs,
+ HTML_In_Form element
+ )=
+ button(attrs, [element])
+.
+
+public define HTML_In_Form
+ button
+ (
+ HTML_In_Form element
+ )=
+ button([], [element])
+.
+
+public define HTML_Off_Form
+ button
+ (
+ List(HTML_Off_Form) elements
+ )=
+ button([], elements)
+.
+
+public define HTML_Off_Form
+ button
+ (
+ List(CoreAttrs) attrs,
+ HTML_Off_Form element
+ )=
+ button(attrs, [element])
+.
+
+public define HTML_Off_Form
+ button
+ (
+ HTML_Off_Form element
+ )=
+ button([], [element])
+.
- Cell a gap between two other cells :
public define HTML_Cell(HTML_Off_Form)
- width_gap
- (
- Int w
- ) =
- cell([width(w)],text([],"")).
+ width_gap
+ (
+ Int w
+ )=
+ cell([width(w)], empty).
public define HTML_Cell(HTML_In_Form)
- width_gap
- (
- Int w
- ) =
- cell([width(w)],text([],"")).
-
-
+ width_gap
+ (
+ Int w
+ )=
+ cell([width(w)],empty)
+.
- Row a gap between two other rows :
public define HTML_Row(HTML_Off_Form)
- height_gap
- (
- Int h
- ) =
- row([],[cell([height(h)],text([],""))]).
+ height_gap
+ (
+ Int h
+ )=
+ row([],[cell([height(h)],empty)]).
public define HTML_Row(HTML_In_Form)
- height_gap
- (
- Int h
- ) =
- row([],[cell([height(h)],text([],""))]).
+ height_gap
+ (
+ Int h
+ )=
+ row([],[cell([height(h)],empty)])
+.
Notice that the two types have alternatives in common (same name, same arguments types,
@@ -3017,11 +3266,11 @@ define HTTP_Answer
// content of page
sequence([
- text([size(16)], "Anubis Web Server 1.14"),
+ preformated([size(16)], "Anubis Web Server 1.14"),
br,
- text([size(16)],"Error "+to_String(http_status)),
+ preformated([size(16)],"Error "+to_String(http_status)),
br,
- text([], "Internal message :"+message),
+ preformated([size(14)],"Internal message :"+message),
br,br,
in_form(html_Id(""),text_area(wan(""), init(dump(_session)), 120, 60))
])
@@ -3100,10 +3349,12 @@ define Maybe(WEB_Controller)
)=
if controllers is
{
- [] then failure,
+ [] then
+ println("Can't find controller ["+controller_name+"]");
+ failure,
[h . t] then
if h.name = controller_name then
-
+ println("Controller ["+controller_name+"] found");
success(h)
else
get_controller(controller_name, t)
@@ -3177,6 +3428,8 @@ define (Maybe(WEB_Session), HTTP_Answer)
apply_controller_action(new_controller, controllers, web_session(lang, entries, previous, previous), failure, initial_session),
},
ajax(answer) then (failure, answer),
+ //ajax with modified session that must be saved
+ ajax(session, answer) then (success(session), answer),
}
}
.
@@ -3494,9 +3747,9 @@ public define One
parameter $T becomes either 'HTML_Off_Form' or 'HTML_In_Form'.
type HTML_Any($T):
- any_text (List(Text_Option), String the_text),
+ any_text (List(CoreAttrs), String the_text),
any_preformated (List(Text_Option), String),
- any_paragraph (List(Text_Option), $T content),
+ any_paragraph (List(Text_Option), List($T) content),
any_image (List(CoreAttrs), String url, String alternate),
any_image (List(CoreAttrs), String url, String alternate, Int width, Int height),
any_table (List(Table_Option), HTML_Header_Row($T), List(HTML_Row($T)), HTML_Footer_Row($T)),
@@ -3519,13 +3772,13 @@ type HTML_Any($T):
any_foreign_link (List(Text_Option), String url, String name),
any_private_download (String abs_path, String name, String extra_ext,
Maybe((String,List((String,String))))),
- any_div (List(CoreAttrs), $T element),
+ any_div (List(CoreAttrs), List($T) element),
any_div_empty (List(CoreAttrs)),
any_coreattrs (List(CoreAttrs)),
- any_ol (List(CoreAttrs), $T content),
- any_ul (List(CoreAttrs), $T content),
- any_li (List(CoreAttrs), $T content),
- any_button (List(CoreAttrs), $T element),
+ any_ol (List(CoreAttrs), List($T) content),
+ any_ul (List(CoreAttrs), List($T) content),
+ any_li (List(CoreAttrs), List($T) content),
+ any_button (List(CoreAttrs), List($T) element),
any_i (List(CoreAttrs), String text),
any_span (List(CoreAttrs), String text),
any_hr (List(CoreAttrs))
@@ -3850,6 +4103,8 @@ define List(Text_Option)
get_text_options(t)
else if h is title(_) then
get_text_options(t)
+ else if h is core_attrs(_) then
+ get_text_options(t)
else
[ h . get_text_options(t) ]
@@ -3884,6 +4139,24 @@ define List(CoreAttrs)
get_css_class(t)
}
.
+
+
+define List(CoreAttrs)
+ get_core_attrs
+ (
+ List(Text_Option) l
+ )
+ =
+ if l is
+ {
+ [] then [],
+ [h . t ] then
+ if h is core_attrs(attrs) then
+ attrs + get_core_attrs(t)
+ else
+ get_core_attrs(t)
+ }
+ .
define Printable_tree
format
@@ -4065,18 +4338,11 @@ define String
)
=
with text_options = get_text_options(l),
- css_classes = get_css_class(l),
- if text_options is
- {
- [] then "",
- [_ . _] then " style=\"" + format(text_options) + "\" "
- }
- +
- if css_classes is
- {
- [] then "",
- [_ . _] then format_attrs(css_classes)
- }.
+ core_attrs = get_css_class(l) + get_core_attrs(l),
+ (if length(text_options)= 0 then "" else " style=\"" + format(text_options) + "\" ")
+ +
+ (if length(core_attrs) = 0 then "" else format_attrs(core_attrs))
+ .
//define String
// _format
@@ -4246,11 +4512,20 @@ define Printable_tree
link(opt, text, mb_name) then
with name_tag = if mb_name is success(n) then " name=\"" + n + "\"" else "",
- [
- "",
- text,
- ""
- ],
+ with action_name = if action is {
+ no_action then ""
+ controller_action(_, an) then an,
+ action_name(an) then an,
+ url(_) then ""
+ },
+ if action_name = "" then
+ ["", text, "" ]
+ else
+ ["",
+ text,
+ ""
+ ],
img_link(options, img, alt_text) then
//if action name is empty, format options on image because maybe there onclick action
with action_name = if action is {
@@ -4627,6 +4902,7 @@ define String
[ ] then "",
[h . t] then if h is
{
+ core_attrs(core_attr_list) then format_attrs(core_attr_list),
size(n) then "font-size:"+n+"pt",
font(fn) then "font-family:"+fn,
color(c) then if c is rgb(r,g,b) then
@@ -4871,13 +5147,13 @@ define Printable_tree
if opts is
{
[] then [t],
- [_ . _] then ["",t,""]
+ [_ . _] then ["",t,""]
},
any_preformated(opts,s) then
["",s,"
"],
//["
",s,""], - any_paragraph(opts,e) then - ["
",format_element(e),"
\n"], + any_paragraph(opts,l) then + ["", flat(map(($T e) |-> format_element(e), l)),"
\n"], any_image(opts, url, _alt) then with alt = if _alt = "" then "" else "alt=\""+_alt+"\"", ["