Commit 2c0623568707d07d9a7dca283c955ec638b17741

Authored by totoro
2 parents 6a68f898 52168de7

merge result !!

asterisk/ami.anubis
... ... @@ -10,14 +10,9 @@ read system/string.anubis
10 10 read tools/basis.anubis
11 11 read tools/connections.anubis
12 12  
13   -read calexium_lib/asterisk/ami_types.anubis
14   -read calexium_lib/asterisk/ami_commands.anubis
15   -read calexium_lib/web/CXM_http_get_common.anubis
  13 +transmit calexium_lib/asterisk/ami_types.anubis
  14 +transmit calexium_lib/asterisk/ami_commands.anubis
16 15  
17   -
18   -
19   - public define Result(
20   -
21 16 define Maybe(One)
22 17 receive
23 18 (
... ... @@ -104,6 +99,7 @@ public define Maybe(Asterisk_client)
104 99 String server_name,
105 100 AMI_Auth auth
106 101 )=
  102 + //println("asterisk_new_client "+server_name);
107 103 if separate_name_port(server_name, 5038) is (name, server_port) then
108 104 //
109 105 // resolve server name and call 'https_get' with numeric server address:
... ... @@ -149,7 +145,8 @@ global define One
149 145 if asterisk_new_client("192.168.3.118:5038", auth("anubix","anubix")) is
150 146 {
151 147 failure then println(" asterisk new client failure"),
152   - success(ami_client) then unique
  148 + success(ami_client) then
  149 + forget(send_action(ami_client, ami_originate_call("1000", "1001")))
153 150 //forget(xml_rpc_client_execute(true, rpc_client, "/Settings", "list_domains", empty_param))
154 151 //forget(xml_rpc_client_execute(true, rpc_client, "/Settings", "delete_domain", parameters([parameter[string("amisdefontainebleau.org")]])))
155 152 //forget(xml_rpc_client_execute(true, rpc_client, "/Settings", "create_domain", empty_param))
... ...
asterisk/ami_commands.anubis
... ... @@ -22,3 +22,30 @@ public define AMI_Action ami_login(AMI_Auth ami_auth) =
22 22 if ami_auth is auth(user, password) then
23 23 ami_login(user, password, true).
24 24  
  25 +public define AMI_Action ami_originate_call(String extension, String out_number) =
  26 + action("Originate", [
  27 + key_value("Channel", "SIP/"+extension),
  28 + key_value("Exten", out_number),
  29 + key_value("Context", "default"),
  30 + key_value("Priority", "1"),
  31 + key_value("Async", "yes")
  32 + ]
  33 + )
  34 +.
  35 +
  36 +public define AMI_Action
  37 + ami_originate_call
  38 + (
  39 + String extension,
  40 + String out_number,
  41 + String context
  42 + )=
  43 + action("Originate", [
  44 + key_value("Channel", "SIP/"+extension),
  45 + key_value("Exten", out_number),
  46 + key_value("Context", context),
  47 + key_value("Priority", "1"),
  48 + key_value("Async", "yes")
  49 + ]
  50 + )
  51 +.
... ...
database/alter_table.anubis
... ... @@ -222,8 +222,9 @@ public define Maybe(One)
222 222 },
223 223 true then
224 224 with tempNameTable = tableName + "_temp",
  225 + forget(sql_query(db, "PRAGMA foreign_keys = 0;"));
225 226 forget(sql_query(db, "DROP TABLE " + tempNameTable));
226   - if my_sql_query(db, "CREATE TEMP TABLE " + tempNameTable + " AS SELECT * from " + fullTableName, log) is failure then failure else
  227 + with result = if my_sql_query(db, "CREATE TEMP TABLE " + tempNameTable + " AS SELECT * from " + fullTableName, log) is failure then failure else
227 228 if my_sql_query(db, "DROP TABLE " + fullTableName, log) is failure then failure else
228 229 if my_sql_query(db, newTableQuery , log) is failure then failure else
229 230 if sql_query(db, "SELECT * FROM " + tempNameTable) is
... ... @@ -244,7 +245,10 @@ public define Maybe(One)
244 245 ok(_,_,_) then logInfo(log, " --> ok."); success(unique)
245 246 }
246 247 }
247   - }
  248 + },
  249 +
  250 + forget(sql_query(db, "PRAGMA foreign_keys = 1;"));
  251 + result
248 252 }
249 253 else
250 254 success(unique)
... ...
database/db_binds.anubis 0 → 100644
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ aka (David RENÉ)
  4 + * Date: 17/03/2017
  5 + * Time: 00:14
  6 + * © Calexium
  7 + */
  8 +
  9 +transmit calexium_lib/database/types/db_id.anubis
  10 +transmit calexium_lib/database/types/db_date.anubis
  11 +transmit calexium_lib/database/types/db_time.anubis
  12 +transmit calexium_lib/database/types/db_datetime.anubis
  13 +transmit calexium_lib/database/db_types.anubis
  14 +
  15 + extended version of bind for SQLite3.
  16 +
  17 +public define SQLite3Bind
  18 + bind_DB_id_or_NULL
  19 + (
  20 + String _name,
  21 + DB_id _value
  22 + )=
  23 + if _value is
  24 + {
  25 + none then bind_NULL(_name)
  26 + db_id(value) then bind_Int(_name, value)
  27 + }
  28 +.
  29 +
  30 +public define SQLite3Bind
  31 + bind_DB_id_or_NULL
  32 + (
  33 + String _name,
  34 + Maybe(DB_id) mb_value
  35 + )=
  36 + if mb_value is
  37 + {
  38 + failure then bind_NULL(_name)
  39 + success(id) then bind_DB_id_or_NULL(_name, id)
  40 + }
  41 +.
  42 +
  43 +public define SQLite3Bind
  44 + bind_Int_or_NULL
  45 + (
  46 + String name,
  47 + Maybe(Int) mb_value
  48 + )=
  49 + if mb_value is
  50 + {
  51 + failure then bind_NULL(name),
  52 + success(value) then bind_Int(name, value)
  53 + }
  54 +.
  55 +
  56 +public define SQLite3Bind
  57 + bind_String_or_NULL
  58 + (
  59 + String name,
  60 + String value
  61 + )=
  62 + if value = "" then
  63 + bind_NULL(name)
  64 + else
  65 + bind_String(name, value).
  66 +
  67 +public define SQLite3Bind
  68 + bind_Datetime
  69 + (
  70 + String name,
  71 + DB_datetime dt
  72 + )=
  73 + bind_String(name, datetime(dt)).
  74 +
  75 +public define SQLite3Bind
  76 + bind_Date
  77 + (
  78 + String name,
  79 + DB_date d
  80 + )=
  81 + bind_String(name, date(d)).
  82 +
  83 +public define SQLite3Bind
  84 + bind_Time
  85 + (
  86 + String name,
  87 + DB_time d
  88 + )=
  89 + bind_String(name, time(d)).
  90 +
  91 +public define SQLite3Bind
  92 + bind_Bool
  93 + (
  94 + String name,
  95 + Bool value
  96 + )=
  97 + bind_Int(name, to_DBInt(value)).
  98 +
  99 +public define SQLite3Bind
  100 + bind_BLOB
  101 + (
  102 + String name,
  103 + $V value
  104 + )=
  105 + bind_ByteArray(name, serialize(value)).
  106 +
... ...
database/db_types.anubis
1 1 /*
2 2 * Created by PyramIDE.
3   - * User: Totoro
  3 + * User: フランスのトトロ aka (David RENÉ)
4 4 * Date: 14/11/2011
5 5 * Time: 22:41
6 6 *
... ... @@ -89,9 +89,7 @@ public define Int
89 89 none then (Int)-1,
90 90 pk(_idx) then _idx
91 91 }.
92   -
93 92  
94   -
95 93 public define String
96 94 to_String
97 95 (
... ... @@ -99,8 +97,16 @@ public define String
99 97 )=
100 98 date(d).
101 99  
  100 +public define String
  101 + String s + DB_date d =
  102 + s + to_String(d)
  103 +.
  104 +
  105 +public define String
  106 + DB_date d + String s =
  107 + to_String(d) + s
  108 +.
102 109  
103   -
104 110 public define String
105 111 to_String
106 112 (
... ... @@ -109,12 +115,32 @@ public define String
109 115 datetime(dt).
110 116  
111 117 public define String
  118 + String s + DB_datetime dt =
  119 + s + to_String(dt)
  120 +.
  121 +
  122 +public define String
  123 + DB_datetime dt + String s =
  124 + to_String(dt) + s
  125 +.
  126 +
  127 +public define String
112 128 to_String
113 129 (
114 130 DB_time t
115 131 )=
116 132 time(t).
117   -
  133 +
  134 +public define String
  135 + String s + DB_time t =
  136 + s + to_String(t)
  137 +.
  138 +
  139 +public define String
  140 + DB_time t + String s =
  141 + to_String(t) + s
  142 +.
  143 +
118 144 public define String
119 145 to_DBString
120 146 (
... ... @@ -129,8 +155,7 @@ public define Int
129 155 )=
130 156 if value then 1 else 0.
131 157  
132   -public type SQLite3_update_field:
133   - field(String column, SQLite3Bind bind).
  158 +
134 159  
135 160  
136 161 * Some Bind helper *
... ...
database/db_update_fields.anubis 0 → 100644
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ aka (David RENÉ)
  4 + * Date: 17/03/2017
  5 + * Time: 00:11
  6 + * © Calexium
  7 + */
  8 +read tools/basis.anubis
  9 +read system/string.anubis
  10 +
  11 +public type SQLite3_update_field:
  12 + field(String column, SQLite3Bind bind).
  13 +
  14 +public define (List(SQLite3Bind), String)
  15 + _make_update_clause_and_binds
  16 + (
  17 + List(SQLite3_update_field) fields,
  18 + List(SQLite3Bind) so_far,
  19 + List(String) set_clause
  20 + )=
  21 + if fields is
  22 + {
  23 + [] then (so_far, join(", ",set_clause)),
  24 + [ h . t ] then
  25 + if h is field(column, bind) then
  26 + _make_update_clause_and_binds(t, [bind . so_far], ["\""+column+"\" = :v_"+column . set_clause])
  27 + }
  28 +.
  29 +
  30 +public define (List(SQLite3Bind), String)
  31 + make_update_clause_and_binds
  32 + (
  33 + List(SQLite3_update_field) fields
  34 + )=
  35 + _make_update_clause_and_binds(fields, [], [])
  36 +.
  37 +
  38 +public define (List(SQLite3Bind), String, String)
  39 + _make_insert_clause_and_binds
  40 + (
  41 + List(SQLite3_update_field) fields,
  42 + List(SQLite3Bind) so_far,
  43 + List(String) insert_columns,
  44 + List(String) insert_values
  45 + )=
  46 + if fields is
  47 + {
  48 + [] then (so_far, "("+join(", ",insert_columns)+")", "("+join(", ",insert_values)+")"),
  49 + [ h . t ] then
  50 + if h is field(column, bind) then
  51 + _make_insert_clause_and_binds(t, [bind . so_far], ["\""+column+"\"" . insert_columns], [":v_"+column . insert_values])
  52 + }
  53 +.
  54 +
  55 +public define (List(SQLite3Bind), String, String)
  56 + make_insert_clause_and_binds
  57 + (
  58 + List(SQLite3_update_field) fields
  59 + )=
  60 + _make_insert_clause_and_binds(fields, [], [], [])
  61 +.
... ...
database/db_utils.anubis
... ... @@ -15,6 +15,8 @@ read data_base/sqlite.anubis
15 15  
16 16 transmit calexium_lib/database/db_types.anubis
17 17 transmit calexium_lib/database/db_utils.anubis
  18 +transmit calexium_lib/database/db_binds.anubis
  19 +transmit calexium_lib/database/db_update_fields.anubis
18 20  
19 21 read calexium_lib/net_services_protocols/logger_service.anubis
20 22  
... ... @@ -287,78 +289,10 @@ public define List(Int)
287 289 This is useful when we want to construct a SQL query with only needs fields.
288 290  
289 291  
290   -public define (List(SQLite3Bind), String)
291   - make_clause_and_binds
292   - (
293   - List(SQLite3_update_field) fields,
294   - List(SQLite3Bind) so_far,
295   - List(String) clause
296   - )=
297   - if fields is
298   - {
299   - [] then (so_far, join(", ",clause)),
300   - [ h . t ] then
301   - if h is field(column, bind) then
302   - make_clause_and_binds(t, [bind . so_far], ["\""+column+"\" = :v_"+column . clause])
303   - }.
  292 +
304 293  
305 294  
306   - extended version of bind for SQLite3.
307 295  
308   -public define SQLite3Bind
309   - bind_Int_or_NULL
310   - (
311   - String name,
312   - Int value
313   - )=
314   - if value = 0 then
315   - bind_NULL(name)
316   - else
317   - bind_Int(name, value).
318   -
319   -public define SQLite3Bind
320   - bind_String_or_NULL
321   - (
322   - String name,
323   - String value
324   - )=
325   - if value = "" then
326   - bind_NULL(name)
327   - else
328   - bind_String(name, value).
329   -
330   -public define SQLite3Bind
331   - bind_Datetime
332   - (
333   - String name,
334   - DB_datetime dt
335   - )=
336   - bind_String(name, datetime(dt)).
337   -
338   -public define SQLite3Bind
339   - bind_Date
340   - (
341   - String name,
342   - DB_date d
343   - )=
344   - bind_String(name, date(d)).
345   -
346   -public define SQLite3Bind
347   - bind_Bool
348   - (
349   - String name,
350   - Bool value
351   - )=
352   - bind_Int(name, to_DBInt(value)).
353   -
354   -public define SQLite3Bind
355   - bind_BLOB
356   - (
357   - String name,
358   - $V value
359   - )=
360   - bind_ByteArray(name, serialize(value)).
361   -
362 296 // -- Migration HELPERS ---------------
363 297  
364 298 public define DbBind
... ...
database/model/db_model.anubis
... ... @@ -200,17 +200,15 @@ define macro Maybe(String)
200 200 mapor((HK_Model_Column cs) |->
201 201 if cs is col(name,_,_) then is_forbidden_column_name(name),
202 202 cols).
203   -
  203 +
204 204 define Bool
205 205 has_forbidden_column_names
206 206 (
207 207 DB_Model_DB db
208 208 ) =
209   - if db is database(_,tables) then
210   - mapor(has_forbidden_column_names,tables).
211   -
  209 + if db is database(_,tables) then
  210 + mapor(has_forbidden_column_names,tables).
212 211  
213   -
214 212 *** [3] Generating the target file.
215 213  
216 214 *** [3.1] Converting a database type into the corresponding Anubis type:
... ...
ds_files/ds_types.anubis
... ... @@ -65,6 +65,22 @@ public define List(DS_Type) calexium_lib_types_description =
65 65 component(list, string, "file_extensions")
66 66 ])
67 67 ]),
  68 +
  69 + ds_type("WEB_Action_Name", [
  70 + enum("no_action"),
  71 + alternative("controller_action", [
  72 + component(string, "controller"),
  73 + component(string, "ac_name")
  74 + ]),
  75 + alternative("action_name", [
  76 + component(string, "ac_name")
  77 + ]),
  78 +
  79 + //url is raw action, hence we will only copy that url in final link
  80 + alternative("url", comment("url is raw action, hence we will only copy that url in final link"), [
  81 + component(string, "url_name", )
  82 + ])
  83 + ])
68 84  
69 85 ]
70 86 .
... ...
web/CXM_form.anubis
... ... @@ -226,6 +226,7 @@ public type CXM_Form_Field:
226 226 div (List(CoreAttrs), HTML_In_Form content),
227 227 partial (HTML_Partial_Content p_content),
228 228 br,
  229 + hr (List(CoreAttrs) options),
229 230 // input_with_help (CXM_Form_Field field,
230 231 // Maybe(String) help_title,
231 232 // String help_text,
... ... @@ -286,6 +287,10 @@ public define CXM_Form_Field
286 287 = input([], label, html_Id(n.name), n, init_value, width, mand).
287 288  
288 289 public define CXM_Form_Field
  290 + input(List(CoreAttrs) options, HTML_Label label, WebArgName n, InitialValue init_value, Width width, Mandatory mand)
  291 + = input(options, label, html_Id(n.name), n, init_value, width, mand).
  292 +
  293 +public define CXM_Form_Field
289 294 input_readonly(HTML_Label label, WebArgName n, InitialValue init_value, Width width)
290 295 = input_readonly([], label, html_Id(n.name), n, init_value, width).
291 296  
... ... @@ -380,7 +385,12 @@ public define CXM_Form_Field
380 385 )=
381 386 hidden(html_Id(""), web_arg_name, value).
382 387  
383   -
  388 +public define CXM_Form_Field
  389 + hr
  390 + =
  391 + hr([])
  392 +.
  393 +
384 394 //--- explanation field ---------------------
385 395  
386 396 // //////////////////////////////////////////////////////////
... ... @@ -411,32 +421,50 @@ define (List((List(CoreAttrs), WebArgValue, String)), List(HTML_Partial_Content)
411 421 ) = construct_selector_hide_show(div_id, items, [], [], 0).
412 422  
413 423 public define HTML_In_Form
  424 + format_div_CXM_Form_Field
  425 + (
  426 + List(CXM_Form_Field) field,
  427 + List(Web_arg) lwa,
  428 + String _class,
  429 + Bool b_with_label
  430 + ).
  431 +
  432 +
  433 +public define HTML_In_Form
414 434 format_CXM_Form_Field
415 435 (
416   - CXM_Form_Field ff,
417   - List(Web_arg) lwa
  436 + CXM_Form_Field ff, //CXM_Form_Field to format
  437 + List(Web_arg) lwa, //web arguments of the session, can be useful for the current drawing
  438 + String _class,
  439 + Bool b_with_label //if false, no need to show/generate label
418 440 ) =
419   - with star = (HTML_Label l, Mandatory m) |-> (HTML_Label)
420   - if m is
421   - {
422   - mandatory then
423   - if l is
424   - {
425   - no_label then l,
426   - label(str, help) then label(str + "<span>*</span>", help),
427   - }
428   -
429   - non_mandatory then l
430   - },
431   - pixels = (Width width) |->
432   - if width is
433   - {
434   - small then 10,
435   - narrow_small then 20,
436   - narrow then 50,
437   - wide then 70,
438   - custom(n) then n
439   - },
  441 + with star = (HTML_Label l, Mandatory m)
  442 + |->
  443 + (HTML_Label)
  444 + if b_with_label then
  445 + if m is
  446 + {
  447 + mandatory then
  448 + if l is
  449 + {
  450 + no_label then l,
  451 + label(str, help) then label(str + "<span>*</span>", help),
  452 + }
  453 + non_mandatory then l
  454 + }
  455 + else
  456 + no_label
  457 + ,
  458 + pixels = (Width width)
  459 + |->
  460 + if width is
  461 + {
  462 + small then 10,
  463 + narrow_small then 20,
  464 + narrow then 50,
  465 + wide then 70,
  466 + custom(n) then n
  467 + },
440 468  
441 469  
442 470 if ff is
... ... @@ -500,7 +528,7 @@ public define HTML_In_Form
500 528 with div_id = generate_random_string(15),
501 529 sequence([
502 530 check_box([data("show_id", div_id), class("in"), class("cxm_checkbox_hide_show"), event(onclick, "checked_hide_show_element('"+div_id+"', this);")], _label, html_Id("checkbox_"+div_id), wan, val, get_Bool(lwa, wan.name, checked)),
503   - div([id(div_id), style("display:"+if checked then "block" else "none")], sequence(map((CXM_Form_Field ff2) |-> div([class("form_field")], format_CXM_Form_Field(ff2, lwa)),fields)))
  531 + div([id(div_id), style("display:"+if checked then "block" else "none")], format_div_CXM_Form_Field(fields, lwa, _class, b_with_label))
504 532 ]),
505 533  
506 534 radio_button(options, _label, id, wan, val, checked, mand) then
... ... @@ -510,7 +538,7 @@ public define HTML_In_Form
510 538 with div_id = generate_random_string(15),
511 539 sequence([
512 540 radio_button([data("show_id", div_id), class("in"), class("cxm_radio_hide_show"), event(onclick, "radio_hide_show_group('"+wan.name+"', this);")], _label, html_Id("radio_button_hide_show_"+div_id), wan, val, get_Bool(lwa, wan.name, checked)),
513   - div([id(div_id), style("display:"+if checked then "block" else "none")], sequence(map((CXM_Form_Field ff2) |-> div([class("form_field")], format_CXM_Form_Field(ff2, lwa)),fields)))
  541 + div([id(div_id), style("display:"+if checked then "block" else "none")], format_div_CXM_Form_Field(fields, lwa, _class, b_with_label))
514 542 ]),
515 543  
516 544 radio_buttonr(options, _label, id, wan, val, checked, mand) then
... ... @@ -540,7 +568,7 @@ public define HTML_In_Form
540 568 ]),
541 569 one_line_fields(fields) then
542 570 table([nude, class("form_one_line")],[row([],
543   - map((CXM_Form_Field ff2) |-> cell([],format_CXM_Form_Field(ff2, lwa)),fields))])
  571 + map((CXM_Form_Field ff2) |-> cell([],format_CXM_Form_Field(ff2, lwa, _class, b_with_label)),fields))])
544 572 ,
545 573  
546 574 upload(options, _label, id, name, w, mand) then
... ... @@ -558,7 +586,8 @@ public define HTML_In_Form
558 586 div(options, e) then div(options, e),
559 587  
560 588 partial(p_content) then partial(p_content),
561   - br then br,
  589 + br then br,
  590 + hr(opts) then hr(opts),
562 591 // input_with_help(input, help_title, help_text, width) then
563 592 // sequence([
564 593 // format_CXM_Form_Field(input, lwa, html_tooltip(force_String(help_title), help_text, width)),
... ... @@ -568,7 +597,7 @@ public define HTML_In_Form
568 597 sequence([
569 598 literal("<fieldset" + format_attrs(options) + ">"),
570 599 literal(if length(legend) > 0 then "<legend>" + legend + "</legend>" else ""),
571   - sequence( map((CXM_Form_Field ffield) |-> div([class("form_field")], format_CXM_Form_Field(ffield, lwa)), fields) ),
  600 + format_div_CXM_Form_Field(fields, lwa, _class, b_with_label),
572 601 literal("</fieldset>")
573 602 ]),
574 603  
... ... @@ -585,45 +614,100 @@ public define HTML_In_Form
585 614 failure then same,
586 615 success(n) then same(n)
587 616 },
588   - submit(attrs + [class(htmlClass.class)], button_text),
  617 + submit(attrs + [class(htmlClass.class + " cxm_submit")], button_text),
589 618 action_name,
590 619 extra_operands
591 620 ),
592 621 empty then literal("")
593 622 }.
594 623  
  624 + public define HTML_In_Form
  625 + format_div_CXM_Form_Field
  626 + (
  627 + CXM_Form_Field field,
  628 + List(Web_arg) lwa,
  629 + String _class,
  630 + Bool b_with_label
  631 + )=
  632 + if field is empty then
  633 + empty
  634 + else if field is no_field then
  635 + empty
  636 + else if field is hidden(id, name, init) then
  637 + format_CXM_Form_Field(field, lwa, _class, b_with_label)
  638 + else if field is br then
  639 + format_CXM_Form_Field(field, lwa, _class, b_with_label)
  640 + else if field is text_area(options, _label, id, wan, default, w, height, mand) then
  641 + div([], format_CXM_Form_Field(field, lwa, _class, b_with_label))
  642 + else
  643 + div([class(_class)], format_CXM_Form_Field(field, lwa, _class, b_with_label))
  644 +.
  645 +
  646 +
  647 +
595 648 public define HTML_In_Form
596   - format_CXM_Form_Field
  649 + format_div_CXM_Form_Field
597 650 (
598 651 List(CXM_Form_Field) fields,
599   - List(Web_arg) lwa
  652 + List(Web_arg) lwa,
  653 + String _class,
  654 + Bool b_with_label
600 655 )=
601   - sequence( map((CXM_Form_Field ff) |-> div([class("form_field aligned")], format_CXM_Form_Field(ff, lwa)), fields) ).
  656 + //println("format_div_CXM_Form_Field");
  657 + sequence( map((CXM_Form_Field field)
  658 + |->
  659 + //with css_line = if line = 0 then " odd_line" else " even_line",
  660 + //println("class "+css_line+" line "+line);
  661 + if field is empty then
  662 + empty
  663 + else if field is no_field then
  664 + empty
  665 + else if field is hidden(id, name, init) then
  666 + format_CXM_Form_Field(field, lwa, _class, b_with_label)
  667 + else if field is br then
  668 + format_CXM_Form_Field(field, lwa, _class, b_with_label)
  669 + else if field is text_area(options, _label, id, wan, default, w, height, mand) then
  670 + div([], format_CXM_Form_Field(field, lwa, _class, b_with_label))
  671 + else
  672 + div([class(_class)], format_CXM_Form_Field(field, lwa, _class, b_with_label))
  673 + , fields))
  674 +.
602 675  
603 676 public define HTML_In_Form
604   - fieldset
  677 + to_HTML_In_Form
605 678 (
606   - List(Web_arg) lwa,
607 679 List(CXM_Form_Field) fields,
  680 + List(Web_arg) lwa,
  681 + String _class,
  682 + Bool b_with_label
608 683 )=
609   - sequence( map((CXM_Form_Field ff) |-> div([class("form_field aligned")], format_CXM_Form_Field(ff, lwa)), fields) ).
  684 + format_div_CXM_Form_Field(fields, lwa, _class, b_with_label)
  685 +.
610 686  
611   -public define HTML_In_Form
  687 + "form_field aligned"
  688 +
  689 + public define HTML_In_Form
612 690 fieldset
613 691 (
614   - List(Web_arg) lwa,
615 692 CXM_Form_Field field,
  693 + List(Web_arg) lwa,
  694 + String _class,
  695 + Bool b_with_label
616 696 )=
617   - div([class("form_field aligned")], format_CXM_Form_Field(field, lwa)).
  697 + fieldset([field], lwa, _class, b_with_label)
  698 +.
618 699  
619 700  
620 701 public define HTML_In_Form
621   - fieldset
  702 + to_HTML_In_Form
622 703 (
623   - List(CXM_Form_Field) fields
  704 + List(CXM_Form_Field) fields,
  705 + String _class,
  706 + Bool b_with_label
624 707 )=
625   - sequence( map((CXM_Form_Field ff) |-> div([class("form_field aligned")], format_CXM_Form_Field(ff, [])), fields) ).
  708 + to_HTML_In_Form(fields, [], _class, b_with_label).
626 709  
  710 +public
627 711  
628 712 public define HTML_Off_Form
629 713 cxm_form
... ... @@ -633,15 +717,16 @@ public define HTML_Off_Form
633 717 WEB_Action_Name action,
634 718 List((String,String)) extra_ops,
635 719 List(Web_arg) lwa,
636   - List(CXM_Form_Field) fields
  720 + List(CXM_Form_Field) fields,
  721 + String _class,
  722 + Bool b_with_label
637 723 ) =
638   -
639 724 form(
640 725 form_Id,
641 726 [class("cxm_form") . options],
642 727 action,
643 728 extra_ops,
644   - format_CXM_Form_Field(fields, lwa)
  729 + format_div_CXM_Form_Field(fields, lwa, _class, b_with_label)
645 730 ).
646 731  
647 732 public define HTML_Off_Form
... ... @@ -656,7 +741,9 @@ public define HTML_Off_Form
656 741 String action, //older manner to call action with String
657 742 List((String,String)) extra_ops,
658 743 List(Web_arg) lwa,
659   - List(CXM_Form_Field) fields
  744 + List(CXM_Form_Field) fields,
  745 + String _class,
  746 + Bool b_with_label
660 747 ) =
661 748  
662 749 form(
... ... @@ -664,7 +751,7 @@ public define HTML_Off_Form
664 751 [class("cxm_form") . options],
665 752 action_name(action),
666 753 extra_ops,
667   - format_CXM_Form_Field(fields, lwa)
  754 + format_div_CXM_Form_Field(fields, lwa, _class, b_with_label)
668 755 ).
669 756  
670 757 public define HTML_Off_Form
... ... @@ -675,63 +762,118 @@ public define HTML_Off_Form
675 762 WEB_Action_Name action,
676 763 List((String,String)) extra_ops,
677 764 List(Web_arg) lwa,
678   - List(CXM_Form_Field) form_fields
  765 + List(CXM_Form_Field) form_fields,
  766 + String _class,
  767 + Bool b_with_label
679 768 )=
680   - cxm_form(html_Id(form_name), options, action, extra_ops, lwa, form_fields).
  769 + cxm_form(html_Id(form_name), options, action, extra_ops, lwa, form_fields, _class, b_with_label).
681 770  
682 771 public define HTML_Off_Form
683 772 cxm_form
684 773 (
685 774 String form_name,
686 775 List(CoreAttrs) options,
687   - String action,
  776 + WEB_Action_Name action,
688 777 List((String,String)) extra_ops,
689 778 List(Web_arg) lwa,
690 779 List(CXM_Form_Field) form_fields
691 780 )=
692   - cxm_form(html_Id(form_name), options, action_name(action), extra_ops, lwa, form_fields).
  781 + cxm_form(form_name, options, action, extra_ops, lwa, form_fields, "form_field aligned", true)
  782 +.
693 783  
  784 +public define HTML_Off_Form
  785 + cxm_form
  786 + (
  787 + String form_name,
  788 + List(CoreAttrs) options,
  789 + String action,
  790 + List((String,String)) extra_ops,
  791 + List(Web_arg) lwa,
  792 + List(CXM_Form_Field) form_fields,
  793 +
  794 + Bool b_with_label
  795 + )=
  796 + cxm_form(html_Id(form_name), options, action_name(action), extra_ops, lwa, form_fields, "form_field aligned", b_with_label)
  797 +.
  798 +
  799 +public define HTML_Off_Form
  800 + cxm_form
  801 + (
  802 + String form_name,
  803 + List(CoreAttrs) options,
  804 + String action,
  805 + List((String,String)) extra_ops,
  806 + List(Web_arg) lwa,
  807 + List(CXM_Form_Field) form_fields
  808 + )=
  809 + cxm_form(html_Id(form_name), options, action_name(action), extra_ops, lwa, form_fields, "form_field aligned", true)
  810 +.
694 811  
695 812 public define HTML_Off_Form
696 813 cxm_form
697 814 (
698 815 String form_id,
699 816 List(CoreAttrs) options,
700   - List(HTML_In_Form) fields
  817 + List(HTML_In_Form) fields,
  818 + String _class
701 819 ) =
702   - cxm_form(html_Id(form_id), options, action_name(""), [], [], map((HTML_In_Form field) |-> raw_in_form(field), fields) ).
  820 + cxm_form(html_Id(form_id), options, action_name(""), [], [], map((HTML_In_Form field) |-> raw_in_form(field), fields), _class, true )
  821 +.
703 822  
704 823 public define HTML_Off_Form
705 824 cxm_form
706 825 (
707   - String form_id,
  826 + String form_id,
708 827 List(CoreAttrs) options,
709   - List(Web_arg) lwa,
710   - List(CXM_Form_Field) fields
  828 + List(Web_arg) lwa,
  829 + List(CXM_Form_Field) fields,
  830 + String _class,
  831 + Bool b_with_label
711 832 ) =
712   - cxm_form(html_Id(form_id), options, action_name(""), [], lwa, fields).
  833 + cxm_form(html_Id(form_id), options, action_name(""), [], lwa, fields, _class, b_with_label).
713 834  
714 835 public define HTML_Off_Form
715 836 cxm_form
716 837 (
717   - String form_id,
718   - List(HTML_In_Form) fields
  838 + String form_id,
  839 + List(HTML_In_Form) fields,
  840 + String _class
719 841 ) =
720   - cxm_form(html_Id(form_id), [], action_name(""), [], [], map((HTML_In_Form field) |-> raw_in_form(field), fields) ).
  842 + cxm_form(html_Id(form_id), [], action_name(""), [], [], map((HTML_In_Form field) |-> raw_in_form(field), fields), _class, true ).
721 843  
722 844 public define HTML_Off_Form
723 845 cxm_form
724 846 (
725 847 String form_id,
726 848 List(Web_arg) lwa,
727   - List(CXM_Form_Field) fields
  849 + List(CXM_Form_Field) fields,
  850 + String _class
  851 + ) =
  852 + cxm_form(form_id, [], lwa, fields, _class, true).
  853 +
  854 +public define HTML_Off_Form
  855 + cxm_form
  856 + (
  857 + String form_id,
  858 + List(Web_arg) lwa,
  859 + List(CXM_Form_Field) fields,
728 860 ) =
729   - cxm_form(form_id, [], lwa, fields).
  861 + cxm_form(form_id, [], lwa, fields, "form_field aligned", true).
  862 +
730 863  
731 864 public define HTML_Off_Form
732 865 cxm_form
733 866 (
734 867 String form_id,
  868 + List(CXM_Form_Field) fields,
  869 + String _class
  870 + ) =
  871 + cxm_form(html_Id(form_id), [], action_name(""), [], [], fields, _class, true).
  872 +
  873 +public define HTML_Off_Form
  874 + cxm_form
  875 + (
  876 + String form_id,
735 877 List(CXM_Form_Field) fields
736 878 ) =
737   - cxm_form(html_Id(form_id), [], action_name(""), [], [], fields).
  879 + cxm_form(html_Id(form_id), [], action_name(""), [], [], fields, "form_field aligned", true).
... ...
web/CXM_jquery.anubis
... ... @@ -6,7 +6,7 @@
6 6 *
7 7 */
8 8  
9   -read calexium_lib/web/CXM_making_a_web_site.anubis
  9 +transmit calexium_lib/web/CXM_making_a_web_site.anubis
10 10 read tools/printable_tree.anubis
11 11 read tools/basis.anubis
12 12  
... ... @@ -18,6 +18,8 @@ public type JQuery_Actioner_type:
18 18 jqscript( String script)
19 19 .
20 20  
  21 +public define JQuery_Actioner_type jqlink(String name) = jqlink(action_name(name)).
  22 +
21 23 /* jQuery Actioner */
22 24 public type JQuery_Actioner:
23 25 jQuery_actioner(Actioner_Target target, JQuery_Actioner_type type). //, String url_or_form_id_or_script
... ... @@ -75,6 +77,7 @@ public define String
75 77 jqlink(control_action) then
76 78 if control_action is
77 79 {
  80 + no_action then "",
78 81 controller_action(ctrl, action) then "document.location='/?aws_controller="+ctrl+"&amp;aws_action="+action+"';",
79 82 action_name(action) then "document.location='/?aws_action="+action+"';",
80 83 url(url) then "document.location='"+url+"';",
... ... @@ -89,9 +92,10 @@ public define String
89 92 jqlink(control_action) then
90 93 if control_action is
91 94 {
92   - controller_action(ctrl, action) then "document.location='/?aws_controller="+ctrl+"&amp;aws_action="+action+"';",
93   - action_name(action) then "document.location='/?aws_action="+action+"';",
94   - url(url) then "document.location='"+url+"';",
  95 + no_action then "",
  96 + controller_action(ctrl, action) then "document.location='/?aws_controller="+ctrl+"&amp;aws_action="+action+"';",
  97 + action_name(action) then "document.location='/?aws_action="+action+"';",
  98 + url(url) then "document.location='"+url+"';",
95 99 }
96 100 jqflink(link) then "document.location='"+link+"';",
97 101 jqscript(script) then script
... ... @@ -103,6 +107,7 @@ public define String
103 107 jqlink(control_action) then
104 108 if control_action is
105 109 {
  110 + no_action then "",
106 111 controller_action(ctrl, action) then
107 112 "window.open('aws_controller="+ctrl+"&amp;aws_action="+action+"', '"+window_name+"', '"+jquery_button_get_onclick_action_window_options(window_options, "")+"');",
108 113 //"document.location='/?aws_controller="+ctrl+"&amp;aws_action="+action+"';",
... ... @@ -153,7 +158,7 @@ define List(HTML_Head_Tag)
153 158 jquery_defaults
154 159 =
155 160 [
156   - js(js_file("/js/jquery/jquery-1.11.3.min.js")),
  161 + js(js_file("/js/jquery/jquery-1.12.4.min.js")),
157 162 js(js_file("/js/jquery/jquery-ui-1.11.4/jquery-ui.min.js")),
158 163 ].
159 164  
... ...
web/CXM_json.anubis
... ... @@ -110,6 +110,14 @@ public define JsonMember
110 110 ) =
111 111 json_member(name, json_null).
112 112  
  113 +public define JsonValue
  114 + to_json_array
  115 + (
  116 + List(String) list_str
  117 + )=
  118 + json_array(map((String str) |-> json_string(str), list_str))
  119 +.
  120 +
113 121 //-------------------------------------------
114 122 // Outputing Json to Printable_tree
115 123  
... ...
web/CXM_making_a_web_site.anubis
... ... @@ -63,6 +63,9 @@ read CXM_json.anubis
63 63 transmit CXM_web_dump.anubis
64 64 transmit CXM_web_arg_utils.anubis
65 65 transmit CXM_web_session.anubis
  66 +transmit CXM_web_action.anubis
  67 +
  68 +transmit calexium_lib/web/types/web_action_name.anubis
66 69  
67 70 //read CXM_html_tooltip.anubis
68 71  
... ... @@ -298,19 +301,6 @@ public type HTTP_Answer:...
298 301 conversation between the client and the web site, but also containing informations
299 302 taken from the data bases.
300 303  
301   -public type WEB_Action_Name:
302   - controller_action(
303   - String controller,
304   - String action_name
305   - ),
306   - action_name(
307   - String action_name
308   - ),
309   - //url is raw action, hence we will onlu copy that url in final link
310   - url(
311   - String url_name
312   - )
313   -.
314 304  
315 305  
316 306  
... ... @@ -422,10 +412,10 @@ define Previous_Session
422 412 with session_name = value(cookie),
423 413 with file_path = session_directory+"/"+session_name,
424 414 //unserialize the stored session and his timeout value
425   - println("retrieve session ["+session_name+"]");
  415 + //println("retrieve session ["+session_name+"]");
426 416 if (RetrieveResult((Int, WEB_Session_No_Var)))retrieve(file_path) is ok(d) then
427 417 (
428   - println("retrieve session OK ["+session_name+"]");
  418 + //println("retrieve session OK ["+session_name+"]");
429 419 since d is (time_stamp, s_no_var),
430 420 with s = to_WEB_Session(s_no_var),
431 421 if time_stamp < now then
... ... @@ -1033,25 +1023,41 @@ public type HTML_Footer_Row($T):
1033 1023 Same remark as for 'HTML_Cell($T)'. We define several convenience functions:
1034 1024  
1035 1025 public define HTML_Row($T)
1036   - row
1037   - (
1038   - List(HTML_Cell($T)) cells
1039   - ) =
1040   - row([],cells).
  1026 + row
  1027 + (
  1028 + List(HTML_Cell($T)) cells
  1029 + )=
  1030 + row([],cells).
1041 1031  
1042 1032 public define HTML_Row($T)
1043   - row
1044   - (
1045   - HTML_Cell($T) cell
1046   - ) =
1047   - row([],[cell]).
  1033 + row
  1034 + (
  1035 + HTML_Cell($T) cell
  1036 + )=
  1037 + row([],[cell]).
  1038 +
  1039 +public define HTML_Row($T)
  1040 + row
  1041 + (
  1042 + List(Cell_Option) options,
  1043 + HTML_Cell($T) cell
  1044 + )=
  1045 + row(options,[cell]).
  1046 +
  1047 +public define HTML_Row($T)
  1048 + row
  1049 + (
  1050 + Cell_Option option,
  1051 + HTML_Cell($T) cell
  1052 + )=
  1053 + row([option],[cell]).
1048 1054  
1049 1055 public define HTML_Header_Row($T)
1050   - header_row
1051   - (
1052   - List(HTML_Header_Cell($T)) cells
1053   - ) =
1054   - header_row([],cells).
  1056 + header_row
  1057 + (
  1058 + List(HTML_Header_Cell($T)) cells
  1059 + ) =
  1060 + header_row([],cells).
1055 1061  
1056 1062 public define HTML_Header_Row($T)
1057 1063 header_row
... ... @@ -1379,7 +1385,8 @@ public type HTML_In_Form:
1379 1385 li (List(CoreAttrs), HTML_In_Form content),
1380 1386 button (List(CoreAttrs), HTML_In_Form content),
1381 1387 i (List(CoreAttrs), String text),
1382   - span (List(CoreAttrs), String text)
  1388 + span (List(CoreAttrs), String text),
  1389 + hr (List(CoreAttrs))
1383 1390 .
1384 1391  
1385 1392  
... ... @@ -1652,7 +1659,8 @@ public type HTML_Off_Form:
1652 1659 li (List(CoreAttrs), HTML_Off_Form content),
1653 1660 button (List(CoreAttrs), HTML_Off_Form content),
1654 1661 i (List(CoreAttrs), String text),
1655   - span (List(CoreAttrs), String text)
  1662 + span (List(CoreAttrs), String text),
  1663 + hr (List(CoreAttrs))
1656 1664 .
1657 1665  
1658 1666 'HTML_Off_Form' defines all the elements you may put outside any form.
... ... @@ -1861,11 +1869,11 @@ public define HTML_Off_Form
1861 1869 .
1862 1870  
1863 1871 public define HTML_Off_Form
1864   - text
1865   - (
1866   - String s
1867   - ) =
1868   - text([],s)
  1872 + text
  1873 + (
  1874 + String s
  1875 + )=
  1876 + text([], s)
1869 1877 .
1870 1878  
1871 1879  
... ... @@ -1886,6 +1894,18 @@ public define HTML_Off_Form
1886 1894 span([], to_decimal(i))
1887 1895 .
1888 1896  
  1897 +public define HTML_Off_Form
  1898 + hr
  1899 + =
  1900 + hr([])
  1901 +.
  1902 +
  1903 +public define HTML_In_Form
  1904 + hr
  1905 + =
  1906 + hr([])
  1907 +.
  1908 +
1889 1909 - Cell a gap between two other cells :
1890 1910  
1891 1911 public define HTML_Cell(HTML_Off_Form)
... ... @@ -3021,48 +3041,52 @@ define WEB_Controller_Result
3021 3041 {
3022 3042 [] then http_answer(error_page(http_not_found, "No action found", _session)),
3023 3043 [h . t] then
3024   - with action_name = if h.name is
  3044 + if h.name = no_action then
  3045 + http_answer( _session, html_content(http_no_content, empty))
  3046 + else
  3047 + with action_name = if h.name is
3025 3048 {
  3049 + no_action then "",
3026 3050 controller_action(_, name) then name,
3027 3051 action_name(name) then name,
3028 3052 url(url) then url,
3029 3053 },
3030   - if requested_action_name = action_name then
3031   - with step = get_Int(_session.fields, "AWS_SESSION_STEP", 0) + 1,
3032   - replace_Int(_session.fields, "AWS_SESSION_STEP", step);
3033   - if h.allowed_proto is
3034   - {
3035   - //Action only in HTTP
3036   - http then
3037   - if _session.web_request.is_https then
3038   - http_answer(error_page(http_forbidden, "Only HTTP authorized", _session))
3039   - else
3040   - //ask to the server the authorization to execute that action
3041   - if h.allow(_session) then
3042   - h.do_it(_session)
3043   - else
3044   - http_answer(error_page(http_unauthorized, "you are not authorized for this action", _session))
3045   -
3046   - //Action only in HTTPS
3047   - https then
3048   - if _session.web_request.is_https then
3049   - //ask to the server the authorization to execute that action
3050   - if h.allow(_session) then
3051   - h.do_it(_session)
3052   - else
3053   - http_answer(error_page(http_unauthorized, "you are not authorized for this action", _session))
3054   - else
3055   - http_answer(error_page(http_forbidden, "Only HTTPS authorized", _session))
3056   - //Action in both HTTP / HTTPS
3057   - http_https then
3058   - //ask to the server the authorization to execute that action
3059   - if h.allow(_session) then
3060   - //println("do_it "+action_name);
3061   - h.do_it(_session)
3062   - else
3063   - http_answer(error_page(http_unauthorized, "you are not authorized for this action", _session))
3064   -
3065   - }
  3054 + if requested_action_name = action_name then
  3055 + with step = get_Int(_session.fields, "AWS_SESSION_STEP", 0) + 1,
  3056 + replace_Int(_session.fields, "AWS_SESSION_STEP", step);
  3057 + if h.allowed_proto is
  3058 + {
  3059 + //Action only in HTTP
  3060 + http then
  3061 + if _session.web_request.is_https then
  3062 + http_answer(error_page(http_forbidden, "Only HTTP authorized", _session))
  3063 + else
  3064 + //ask to the server the authorization to execute that action
  3065 + if h.allow(_session) then
  3066 + h.do_it(_session)
  3067 + else
  3068 + http_answer(error_page(http_unauthorized, "you are not authorized for this action", _session))
  3069 +
  3070 + //Action only in HTTPS
  3071 + https then
  3072 + if _session.web_request.is_https then
  3073 + //ask to the server the authorization to execute that action
  3074 + if h.allow(_session) then
  3075 + h.do_it(_session)
  3076 + else
  3077 + http_answer(error_page(http_unauthorized, "you are not authorized for this action", _session))
  3078 + else
  3079 + http_answer(error_page(http_forbidden, "Only HTTPS authorized", _session))
  3080 + //Action in both HTTP / HTTPS
  3081 + http_https then
  3082 + //ask to the server the authorization to execute that action
  3083 + if h.allow(_session) then
  3084 + //println("do_it "+action_name);
  3085 + h.do_it(_session)
  3086 + else
  3087 + http_answer(error_page(http_unauthorized, "you are not authorized for this action", _session))
  3088 +
  3089 + }
3066 3090 else
3067 3091 apply_action(_session, requested_action_name, t)
3068 3092 }
... ... @@ -3212,8 +3236,8 @@ public define Web_Site
3212 3236 List(Web_arg) _lwa,
3213 3237 Bool is_https) |->
3214 3238 //(Printable_tree)
3215   - println("host_name "+host_name);
3216   - println(dump_http_info(http_info));
  3239 + //println("host_name "+host_name);
  3240 + //println(dump_http_info(http_info));
3217 3241 println(dump_web_arg_values(_lwa));
3218 3242  
3219 3243  
... ... @@ -3503,7 +3527,8 @@ type HTML_Any($T):
3503 3527 any_li (List(CoreAttrs), $T content),
3504 3528 any_button (List(CoreAttrs), $T element),
3505 3529 any_i (List(CoreAttrs), String text),
3506   - any_span (List(CoreAttrs), String text)
  3530 + any_span (List(CoreAttrs), String text),
  3531 + any_hr (List(CoreAttrs))
3507 3532 .
3508 3533  
3509 3534  
... ... @@ -3691,6 +3716,7 @@ public define String
3691 3716 )=
3692 3717 if action is
3693 3718 {
  3719 + no_action then "",
3694 3720 controller_action(controller, action_name) then "?aws_controller="+controller+"&amp;aws_action="+action_name,
3695 3721 action_name(action_name) then "?aws_action="+action_name,
3696 3722 url(url) then url
... ... @@ -3804,8 +3830,6 @@ define URL_or_JavaScript
3804 3830 )
3805 3831 }.
3806 3832  
3807   -
3808   -
3809 3833 Now, we format the actioner according to its aspect.
3810 3834  
3811 3835 define List(Text_Option)
... ... @@ -4230,6 +4254,7 @@ define Printable_tree
4230 4254 img_link(options, img, alt_text) then
4231 4255 //if action name is empty, format options on image because maybe there onclick action
4232 4256 with action_name = if action is {
  4257 + no_action then ""
4233 4258 controller_action(_, an) then an,
4234 4259 action_name(an) then an,
4235 4260 url(_) then ""
... ... @@ -4255,6 +4280,7 @@ define Printable_tree
4255 4280 with action_name =
4256 4281 if action is
4257 4282 {
  4283 + no_action then "",
4258 4284 controller_action(_, an) then an,
4259 4285 action_name(an) then an,
4260 4286 url(_) then ""
... ... @@ -4300,6 +4326,7 @@ define Printable_tree
4300 4326 ],
4301 4327 javascript(s,h) then
4302 4328 with action_name = if action is {
  4329 + no_action then "",
4303 4330 controller_action(_, an) then an,
4304 4331 action_name(an) then an,
4305 4332 url(_) then ""
... ... @@ -4912,9 +4939,11 @@ define Printable_tree
4912 4939 ["<i", format_attrs(opts), ">",t,"</i>\n"],
4913 4940 any_span(opts , t) then
4914 4941 ["<span", format_attrs(opts), ">",t,"</span>"]
4915   - }.
4916   -
4917   -
  4942 + any_hr(opts) then
  4943 + ["<hr", format_attrs(opts),">"]
  4944 + }
  4945 +.
  4946 +
4918 4947  
4919 4948  
4920 4949 // *** [5.8] Formating 'in form' elements.
... ... @@ -5144,6 +5173,8 @@ define Printable_tree
5144 5173 format(cinfo,ic_v,any_i(opts,t),format_element,is_https, action_count, head_tags),
5145 5174 span(opts,t) then
5146 5175 format(cinfo,ic_v,any_span(opts,t),format_element,is_https, action_count, head_tags)
  5176 + hr(opts) then
  5177 + format(cinfo,ic_v,any_hr(opts),format_element,is_https, action_count, head_tags)
5147 5178 }.
5148 5179  
5149 5180  
... ... @@ -5205,12 +5236,12 @@ define Bool
5205 5236 mail_to(m,e) then false, // 'e' may but should not contain an upload
5206 5237 scroller(w,h,cw,ch,e) then contains_an_upload(e),
5207 5238 actioner(c,t,a,an,eo,ja) then false,
5208   - foreign_link_new(_,_,_) then false,
  5239 + foreign_link_new(_,_,_) then false,
5209 5240 foreign_link(o,u) then false,
5210 5241 foreign_link(o,u,n) then false,
5211 5242 private_download(p,n,e,a) then false,
5212   - text_input(o,lt,l,n,i,w) then false,
5213   - text_input_ro(o,lt,l,n,i,w) then false,
  5243 + text_input(o,lt,l,n,i,w) then false,
  5244 + text_input_ro(o,lt,l,n,i,w) then false,
5214 5245 password_input(o,lt,l,n,i,w) then false,
5215 5246 text_area(o,lt,id,n,i,w,h) then false,
5216 5247 file_upload(o,l,i,n,w) then true,
... ... @@ -5219,7 +5250,7 @@ define Bool
5219 5250 selector_c(o,l,i,n,s,c) then false,
5220 5251 selector_c(o,l,i,n,s,c,p) then false,
5221 5252 radio_button(o,_,_,n,v,c) then false,
5222   - radio_button_r(o,_,_,n,v,c) then false,
  5253 + radio_button_r(o,_,_,n,v,c) then false,
5223 5254 check_box(o,_,_,n,v,c) then false,
5224 5255 check_box_r(o,_,_,n,v,c) then false,
5225 5256 div(o,c) then contains_an_upload(c),
... ... @@ -5233,7 +5264,8 @@ define Bool
5233 5264 li(_,_) then false,
5234 5265 button(_,_) then false,
5235 5266 i(_,_) then false,
5236   - span(_,_) then false
  5267 + span(_,_) then false,
  5268 + hr(_) then false
5237 5269 }
5238 5270 .
5239 5271  
... ... @@ -5377,7 +5409,10 @@ define Printable_tree
5377 5409 i(opts, t) then
5378 5410 format(cinfo,ic_v,any_i(opts,t),format_element,is_https, action_count, head_tags),
5379 5411 span(opts,t) then
5380   - format(cinfo,ic_v,any_span(opts,t),format_element,is_https, action_count, head_tags),
  5412 + format(cinfo,ic_v,any_span(opts,t),format_element,is_https, action_count, head_tags),
  5413 + hr(opts) then
  5414 + format(cinfo,ic_v,any_hr(opts),format_element,is_https, action_count, head_tags),
  5415 +
5381 5416 }.
5382 5417  
5383 5418  
... ...
web/CXM_multihost_http_server.anubis
... ... @@ -685,20 +685,20 @@ type EncodingType:
685 685 multipart_form_data.
686 686  
687 687  
688   -type BufferedConnection:
689   - buffered_connection(Connection conn,
  688 +public type HTTP_BufferedConnection:
  689 + http_buffered_connection(Connection conn,
690 690 Var(ByteArray) buffer,
691 691 Var(Int) read_pos,
692 692 Var(List(Word8)) unput_chars // for reading requests
693 693 ).
694 694  
695 695  
696   -define BufferedConnection
697   - buffered_connection
  696 +public define HTTP_BufferedConnection
  697 + http_buffered_connection
698 698 (
699 699 Connection conn
700 700 )=
701   - buffered_connection(conn, var(constant_byte_array(0, 0)), var(0), var([]))
  701 + http_buffered_connection(conn, var(constant_byte_array(0, 0)), var(0), var([]))
702 702 .
703 703  
704 704  
... ... @@ -777,7 +777,7 @@ define One
777 777 unput // unputting a character (add it in front of the list)
778 778 (
779 779 Word8 character,
780   - BufferedConnection s
  780 + HTTP_BufferedConnection s
781 781 ) =
782 782 s.unput_chars <- (List(Word8))[character . *(s.unput_chars)].
783 783  
... ... @@ -829,7 +829,7 @@ define One
829 829 define ReadResult
830 830 read_from_connexion
831 831 (
832   - BufferedConnection connection,
  832 + HTTP_BufferedConnection connection,
833 833 Int size,
834 834 Int time_out,
835 835 ByteArray result_buffer,
... ... @@ -881,7 +881,7 @@ define Result(Error,Word8)
881 881 next_char // reading a character (check the list first, and read on the connection
882 882 // only when the list is empty).
883 883 (
884   - BufferedConnection connection
  884 + HTTP_BufferedConnection connection
885 885 // Int dead_line,
886 886 // DenialOfService dos
887 887 ) =
... ... @@ -937,7 +937,7 @@ define Result(Error,Word8)
937 937 define ByteArray
938 938 get_and_erase_buffer
939 939 (
940   - BufferedConnection connection
  940 + HTTP_BufferedConnection connection
941 941 )=
942 942 with head = to_byte_array(implode(*connection.unput_chars)),
943 943 tail = extract(*connection.buffer, *connection.read_pos, length(*connection.buffer)),
... ... @@ -971,7 +971,7 @@ define ByteArray
971 971 define Result(Error,One)
972 972 read_and_ignore
973 973 (
974   - BufferedConnection connection, // to client
  974 + HTTP_BufferedConnection connection, // to client
975 975 Int number_of_characters // number of characters to read and ignore
976 976 ) =
977 977 if number_of_characters =< 0 then
... ... @@ -999,7 +999,7 @@ define Result(Error,One)
999 999 define Result(Error,String)
1000 1000 read_string
1001 1001 (
1002   - BufferedConnection connection, // connection with the client
  1002 + HTTP_BufferedConnection connection, // connection with the client
1003 1003 List(Word8) so_far // characters read so far (in reverse order)
1004 1004 ) =
1005 1005 if next_char(connection) is
... ... @@ -1297,34 +1297,36 @@ define Bool
1297 1297 Skipping HTTP blanks.
1298 1298  
1299 1299 define Result(Error,One)
1300   - skip_http_blanks
1301   - (
1302   - BufferedConnection connection
1303   - ) =
1304   - if next_char(connection) is
1305   - {
1306   - error(msg) then error(msg),
1307   - ok(c) then
1308   - if is_strict_blank(c)
1309   - then skip_http_blanks(connection)
1310   - else if c = 13
  1300 + skip_http_blanks
  1301 + (
  1302 + HTTP_BufferedConnection connection
  1303 + )
  1304 + =
  1305 + if next_char(connection) is
  1306 + {
  1307 + error(msg) then error(msg),
  1308 + ok(c) then
  1309 + if is_strict_blank(c)
  1310 + then skip_http_blanks(connection)
  1311 + else if c = 13
  1312 + then if next_char(connection) is
  1313 + {
  1314 + error(msg) then error(msg), // (unput(c); ok(unique)),
  1315 + ok(d) then
  1316 + if d = 10
1311 1317 then if next_char(connection) is
1312 1318 {
1313   - error(msg) then error(msg), // (unput(c); ok(unique)),
1314   - ok(d) then
1315   - if d = 10
1316   - then if next_char(connection) is
1317   - {
1318   - error(msg) then error(msg), // (unput(d); unput(c); ok(unique)),
1319   - ok(e) then
1320   - if is_strict_blank(e)
1321   - then skip_http_blanks(connection)
1322   - else (unput(e, connection); unput(d, connection); unput(c, connection); ok(unique))
1323   - }
1324   - else (unput(d, connection); unput(c, connection); ok(unique))
  1319 + error(msg) then error(msg), // (unput(d); unput(c); ok(unique)),
  1320 + ok(e) then
  1321 + if is_strict_blank(e)
  1322 + then skip_http_blanks(connection)
  1323 + else (unput(e, connection); unput(d, connection); unput(c, connection); ok(unique))
1325 1324 }
1326   - else (unput(c, connection); ok(unique))
1327   - }.
  1325 + else (unput(d, connection); unput(c, connection); ok(unique))
  1326 + }
  1327 + else (unput(c, connection); ok(unique))
  1328 + }
  1329 +.
1328 1330  
1329 1331  
1330 1332  
... ... @@ -1353,7 +1355,7 @@ define Result(Error,One)
1353 1355 public define Result(Error,One)
1354 1356 read_new_line
1355 1357 (
1356   - BufferedConnection connection
  1358 + HTTP_BufferedConnection connection
1357 1359 ) =
1358 1360 if skip_http_blanks(connection) is
1359 1361 {
... ... @@ -1384,7 +1386,7 @@ public define Result(Error,One)
1384 1386 public define Result(Error,One)
1385 1387 skip_line
1386 1388 (
1387   - BufferedConnection connection
  1389 + HTTP_BufferedConnection connection
1388 1390 ) =
1389 1391 if next_char(connection) is
1390 1392 {
... ... @@ -1423,7 +1425,7 @@ public define Result(Error,One)
1423 1425 define Result(Error,String)
1424 1426 read_word_aux
1425 1427 (
1426   - BufferedConnection connection,
  1428 + HTTP_BufferedConnection connection,
1427 1429 List(Word8) so_far
1428 1430 ) =
1429 1431 if next_char(connection) is
... ... @@ -1439,7 +1441,7 @@ define Result(Error,String)
1439 1441 define Result(Error,String)
1440 1442 read_word
1441 1443 (
1442   - BufferedConnection connection
  1444 + HTTP_BufferedConnection connection
1443 1445 ) =
1444 1446 if skip_http_blanks(connection) is
1445 1447 {
... ... @@ -1613,7 +1615,7 @@ define Result(Error,HTTP_RequestType)
1613 1615 public define Result(Error, HTTP_RequestLine)
1614 1616 read_request_line
1615 1617 (
1616   - BufferedConnection connection
  1618 + HTTP_BufferedConnection connection
1617 1619 ) =
1618 1620 if read_word(connection) is
1619 1621 {
... ... @@ -1664,7 +1666,7 @@ define Bool
1664 1666 define Result(Error,String)
1665 1667 read_header_name
1666 1668 (
1667   - BufferedConnection connection,
  1669 + HTTP_BufferedConnection connection,
1668 1670 List(Word8) so_far
1669 1671 ) =
1670 1672 if next_char(connection) is
... ... @@ -1679,7 +1681,7 @@ define Result(Error,String)
1679 1681 define Result(Error,One)
1680 1682 skip_colon
1681 1683 (
1682   - BufferedConnection connection
  1684 + HTTP_BufferedConnection connection
1683 1685 ) =
1684 1686 //Skip the blank char until ':'
1685 1687 if skip_http_blanks(connection) is
... ... @@ -1699,7 +1701,7 @@ define Result(Error,One)
1699 1701 define Result(Error,String)
1700 1702 read_header_value
1701 1703 (
1702   - BufferedConnection connection,
  1704 + HTTP_BufferedConnection connection,
1703 1705 List(Word8) so_far
1704 1706 ) =
1705 1707 if next_char(connection) is
... ... @@ -1731,7 +1733,7 @@ define Result(Error,String)
1731 1733 define Result(Error,Maybe(HTTP_header))
1732 1734 read_header
1733 1735 (
1734   - BufferedConnection connection
  1736 + HTTP_BufferedConnection connection
1735 1737 ) =
1736 1738 //Find the name
1737 1739 if read_header_name(connection, []) is
... ... @@ -1772,7 +1774,7 @@ define Result(Error,Maybe(HTTP_header))
1772 1774 public define Result(Error,List(HTTP_header))
1773 1775 read_http_headers
1774 1776 (
1775   - BufferedConnection connection
  1777 + HTTP_BufferedConnection connection
1776 1778 ) =
1777 1779 if read_header(connection) is
1778 1780 {
... ... @@ -1831,13 +1833,13 @@ public define Result(Error,Int)
1831 1833 make at most 10 retries, with a small sleeping time between any two of them.
1832 1834  
1833 1835 public define Result(Error, ByteArray)
1834   - read_http_body
1835   - (
1836   - BufferedConnection connection,
1837   - Int body_size,
1838   - ByteArray so_far, // when calling this function, 'so_far' is the empty byte array
1839   - Int retries // this function is called with retries = 10
1840   - ) =
  1836 + read_http_body
  1837 + (
  1838 + HTTP_BufferedConnection connection,
  1839 + Int body_size,
  1840 + ByteArray so_far, // when calling this function, 'so_far' is the empty byte array
  1841 + Int retries // this function is called with retries = 10
  1842 + )=
1841 1843 if body_size = 0 then ok(constant_byte_array(0,0)) else
1842 1844 if retries =< 0 then error(cannot_read_from_connection) else
1843 1845  
... ... @@ -3152,7 +3154,7 @@ define One
3152 3154 http_https_handler
3153 3155 (
3154 3156 List(Web_Site_Description) sites,
3155   - BufferedConnection connection,
  3157 + HTTP_BufferedConnection connection,
3156 3158 Bool is_https,
3157 3159 DenialOfService dos,
3158 3160 SState s,
... ... @@ -3300,7 +3302,7 @@ define Server -&gt; ((RWStream) -&gt; One)
3300 3302 if is_dubious_IP(addr,dos)
3301 3303 then print("Rejecting dubious IP address "+ip_addr_to_string(addr)+"\n")
3302 3304 else
3303   - with connection = buffered_connection(tcp(conn), var(constant_byte_array(0, 0)), var(0), var([])),
  3305 + with connection = http_buffered_connection(tcp(conn), var(constant_byte_array(0, 0)), var(0), var([])),
3304 3306 http_https_handler(sites, connection, false, dos, sstate(var(0),var(0)), shutdown_required).
3305 3307 public define One
3306 3308 http_direct_handler
... ... @@ -3314,7 +3316,7 @@ public define One
3314 3316 if is_dubious_IP(addr,dos)
3315 3317 then print("Rejecting dubious IP address "+ip_addr_to_string(addr)+"\n")
3316 3318 else
3317   - with connection = buffered_connection(tcp(conn), var(constant_byte_array(0, 0)), var(0), var([])),
  3319 + with connection = http_buffered_connection(tcp(conn), var(constant_byte_array(0, 0)), var(0), var([])),
3318 3320 http_https_handler(sites, connection, false, dos, sstate(var(0),var(0)), shutdown_required).
3319 3321  
3320 3322  
... ... @@ -3326,7 +3328,7 @@ define Server -&gt; (SSL_Connection -&gt; One)
3326 3328 (One) -> Bool shutdown_required
3327 3329 ) =
3328 3330 (Server server) |-> (SSL_Connection conn) |->
3329   - with connection = buffered_connection(ssl(conn), var(constant_byte_array(0, 0)), var(0), var([])),
  3331 + with connection = http_buffered_connection(ssl(conn), var(constant_byte_array(0, 0)), var(0), var([])),
3330 3332 http_https_handler(sites, connection, true, dos, sstate(var(0),var(0)), shutdown_required).
3331 3333  
3332 3334  
... ... @@ -3722,7 +3724,7 @@ define Server -&gt; ((RWStream) -&gt; One)
3722 3724 ) =
3723 3725 (Server server) |-> (RWStream conn) |->
3724 3726 with start_time = (Int)now,
3725   - connection = buffered_connection(tcp(conn), var(constant_byte_array(0, 0)), var(0), var([])),
  3727 + connection = http_buffered_connection(tcp(conn), var(constant_byte_array(0, 0)), var(0), var([])),
3726 3728 if read_request_line(connection) is
3727 3729 {
3728 3730 error(msg) then print(format(msg)),
... ...
web/CXM_page_message.anubis 0 → 100644
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ aka (David RENÉ)
  4 + * Date: 20/02/2017
  5 + * Time: 04:31
  6 + * © Calexium
  7 + */
  8 +
  9 +read calexium_lib/web/CXM_making_a_web_site.anubis
  10 +read calexium_lib/web/widgets/icons_set.anubis
  11 +
  12 +public type Alignment:
  13 + left,
  14 + center,
  15 + right.
  16 +
  17 +public type Page_Message:
  18 + no_message,
  19 + info(String message),
  20 + info_translate(String message),
  21 + ok(String message),
  22 + ok_translate(String message),
  23 + warning(String message),
  24 + warning_translate(String message),
  25 + error(String message, Alignment align),
  26 + error_translate(String message, Alignment align).
  27 +
  28 +public define One
  29 + set_Page_Message
  30 + (
  31 + Var(List(WEB_Session_Field)) fields,
  32 + Page_Message p_message
  33 + )=
  34 + with step = get_Int(fields, "AWS_SESSION_STEP",0),
  35 + replace_Int(fields, "PAGE_MESSAGE_TTL", step+1);
  36 + if p_message is
  37 + {
  38 + no_message then
  39 + replace_String(fields, "PAGE_STATUS", "NO_MESSAGE");
  40 + replace_String(fields, "PAGE_MESSAGE", "")
  41 + info(msg_str) then
  42 + replace_String(fields, "PAGE_STATUS", "PAGE_INFO");
  43 + replace_String(fields, "PAGE_MESSAGE", msg_str)
  44 + info_translate(msg_str) then
  45 + replace_String(fields, "PAGE_STATUS", "PAGE_INFO_T");
  46 + replace_String(fields, "PAGE_MESSAGE", msg_str)
  47 + ok(msg_str) then
  48 + replace_String(fields, "PAGE_STATUS", "PAGE_OK");
  49 + replace_String(fields, "PAGE_MESSAGE", msg_str)
  50 + ok_translate(msg_str) then
  51 + replace_String(fields, "PAGE_STATUS", "PAGE_OK_T");
  52 + replace_String(fields, "PAGE_MESSAGE", msg_str)
  53 + warning(msg_str) then
  54 + replace_String(fields, "PAGE_STATUS", "PAGE_WARNING");
  55 + replace_String(fields, "PAGE_MESSAGE", msg_str)
  56 + warning_translate(msg_str) then
  57 + replace_String(fields, "PAGE_STATUS", "PAGE_WARNING_T");
  58 + replace_String(fields, "PAGE_MESSAGE", msg_str)
  59 + error(msg_str, align) then
  60 + replace_String(fields, "PAGE_STATUS", "PAGE_ERROR");
  61 + replace_String(fields, "PAGE_MESSAGE", msg_str)
  62 + error_translate(msg_str, align) then
  63 + replace_String(fields, "PAGE_STATUS", "PAGE_ERROR_T");
  64 + replace_String(fields, "PAGE_MESSAGE", msg_str)
  65 + }
  66 +.
  67 +
  68 +public define Page_Message
  69 + error
  70 + (
  71 + String message
  72 + ) = error(message, left).
  73 +
  74 +public define Page_Message
  75 + error_translate
  76 + (
  77 + String message
  78 + ) = error_translate(message, left).
  79 +
  80 +public define Page_Message
  81 + get_Page_Message
  82 + (
  83 + Var(List(WEB_Session_Field)) fields,
  84 + (String) -> String _T
  85 + )=
  86 + with page_status = get_String(fields, "PAGE_STATUS", "NO_MESSAGE"),
  87 + page_string = get_String(fields, "PAGE_MESSAGE", ""),
  88 + page_ttl = get_Int(fields, "PAGE_MESSAGE_TTL", 0),
  89 + step = get_Int(fields, "AWS_SESSION_STEP", 0),
  90 +
  91 + //the page Message is TimeOut. We remove it
  92 + if page_ttl < step then
  93 + remove_Int(fields, "PAGE_MESSAGE_TTL");
  94 + replace_String(fields, "PAGE_STATUS", "NO_MESSAGE");
  95 + replace_String(fields, "PAGE_MESSAGE", "");
  96 + no_message
  97 + else
  98 +
  99 + if page_status = "NO_MESSAGE" then
  100 + no_message
  101 + else if page_status = "PAGE_INFO" then
  102 + info(page_string)
  103 + else if page_status = "PAGE_INFO_T" then
  104 + info(_T(page_string))
  105 + else if page_status = "PAGE_OK" then
  106 + ok(page_string)
  107 + else if page_status = "PAGE_OK_T" then
  108 + ok(_T(page_string))
  109 + else if page_status = "PAGE_WARNING" then
  110 + warning(page_string)
  111 + else if page_status = "PAGE_WARNING_T" then
  112 + warning(_T(page_string))
  113 + else if page_status = "PAGE_ERROR" then
  114 + error(page_string)
  115 + else if page_status = "PAGE_ERROR_T" then
  116 + error(_T(page_string))
  117 + else
  118 + no_message
  119 +.
  120 +
  121 +define List(CoreAttrs)
  122 + get_info_line_attrbs
  123 + (
  124 + String html_class,
  125 + Alignment align
  126 + ) =
  127 + if align is
  128 + {
  129 + left then [class(html_class)],
  130 + center then [class(html_class), style("margin-left: auto; margin-right: auto;")],
  131 + right then [class(html_class), style("margin-left: auto;")]
  132 + }.
  133 +
  134 +public define HTML_Off_Form hide_info_line_btn = div([event(onclick, "this.parentNode.style.display=&quot;none&quot;;"), style("width: 16px; height: 16px; background: transparent url(&quot;"+icn16_cross+"&quot;) no-repeat scroll center center; float: right; display: inline; cursor: pointer;")], literal("")).
  135 +
  136 +public define HTML_In_Form
  137 + display_info_line
  138 + (
  139 + String html_id,
  140 + String html_class,
  141 + String txt,
  142 + Alignment align
  143 + ) =
  144 + div(get_info_line_attrbs(html_class, align), sequence([partial(partial_content(hide_info_line_btn)), partial(partial_content(literal(txt)))])).
  145 +
  146 +public define HTML_Off_Form
  147 + display_info_line
  148 + (
  149 + String html_id,
  150 + String html_class,
  151 + String txt,
  152 + Alignment align
  153 + ) =
  154 + div(get_info_line_attrbs(html_class, align), sequence([hide_info_line_btn, partial(partial_content(literal(txt)))])).
  155 +
  156 +public define HTML_Off_Form
  157 + display_main_info_line
  158 + (
  159 + String html_class,
  160 + String txt,
  161 + Alignment align
  162 + ) =
  163 + display_info_line("informations", html_class, txt, align).
  164 +
  165 +public define HTML_Off_Form
  166 + display_main_info_line
  167 + (
  168 + String html_class,
  169 + String txt
  170 + ) =
  171 + display_info_line("informations", html_class, txt, left).
... ...
web/CXM_web_action.anubis 0 → 100644
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ aka (David RENÉ)
  4 + * Date: 14/03/2017
  5 + * Time: 04:23
  6 + * © Calexium
  7 + */
  8 +
  9 +transmit calexium_lib/web/types/web_action_name.anubis
  10 +//public type WEB_Action_Name:
  11 +// controller_action(
  12 +// String controller,
  13 +// String action_name
  14 +// ),
  15 +// action_name(
  16 +// String action_name
  17 +// ),
  18 +// //url is raw action, hence we will only copy that url in final link
  19 +// url(
  20 +// String url_name
  21 +// )
  22 +//.
  23 +
  24 +public define String
  25 + to_Anubis_Source
  26 + (
  27 + WEB_Action_Name wan
  28 + )=
  29 + if wan is
  30 + {
  31 + no_action then "no_action",
  32 + controller_action(cont, ac_name) then "controller_action(\""+cont+"\", \""+ac_name+"\")",
  33 + action_name(ac_name) then "action_name(\""+ac_name+"\")",
  34 + url(url_name) then "url(\""+url_name+"\")"
  35 + }
  36 +.
... ...
web/CXM_web_arg_utils.anubis
... ... @@ -9,27 +9,41 @@ transmit tools/basis.anubis
9 9 transmit calexium_lib/web/CXM_common.anubis
10 10 transmit calexium_lib/database/db_types.anubis
11 11  
12   -public define DB_id
13   - get_DB_id
  12 +public define Maybe(DB_id)
  13 + get_mb_DB_id
14 14 (
15 15 List(Web_arg) lwa,
16 16 String arg_name
17 17 ) =
18 18 if web_arg_value(lwa, arg_name) is
19 19 {
20   - not_found then none,
  20 + not_found then failure,
21 21 found(value) then
22 22 //Check if value is none which means no id provided
23 23 if value="none" then
24   - none
  24 + success(none)
25 25 else
26 26 //Now try to convert the string into Int to get the id
27 27 if decimal_scan(value) is
28 28 {
29   - failure then none,
30   - success(_value) then db_id(_value)
  29 + failure then success(none),
  30 + success(_value) then success(db_id(_value))
31 31 }
32   - }.
  32 + }
  33 +.
  34 +
  35 +public define DB_id
  36 + get_DB_id
  37 + (
  38 + List(Web_arg) lwa,
  39 + String arg_name
  40 + ) =
  41 + if get_mb_DB_id(lwa, arg_name) is
  42 + {
  43 + failure then none,
  44 + success(value) then value
  45 + }
  46 +.
33 47  
34 48 public define Maybe(DB_date)
35 49 get_DB_date
... ... @@ -91,6 +105,41 @@ public define String
91 105 failure then default_value
92 106 success(value) then value
93 107 }.
  108 +
  109 +public define Maybe(String)
  110 + get_Password
  111 + (
  112 + List(Web_arg) lwa,
  113 + String pwd_1_name,
  114 + String pwd_2_name
  115 + )=
  116 + if get_String(lwa, pwd_1_name) is
  117 + {
  118 + failure then failure,
  119 + success(password1) then
  120 + if get_String(lwa, pwd_2_name) is
  121 + {
  122 + failure then failure
  123 + success(password2) then
  124 + if password1 = password2 then
  125 + success(password1)
  126 + else
  127 + failure
  128 + }
  129 + }
  130 +.
  131 +
  132 +public define Maybe(Bool)
  133 + get_mb_Bool
  134 + (
  135 + List(Web_arg) lwa,
  136 + String arg_name
  137 + ) =
  138 + if web_arg_value(lwa, arg_name) is
  139 + {
  140 + not_found then failure,
  141 + found(value) then success(to_Bool(value))
  142 + }.
94 143  
95 144 public define Bool
96 145 get_Bool
... ... @@ -100,8 +149,8 @@ public define Bool
100 149 ) =
101 150 if web_arg_value(lwa, arg_name) is
102 151 {
103   - not_found then false,
104   - found(_) then true
  152 + not_found then false,
  153 + found(value) then to_Bool(value)
105 154 }.
106 155  
107 156 public define Bool
... ... @@ -217,6 +266,35 @@ public define List(Int)
217 266 }
218 267 .
219 268  
  269 +public define Maybe(Float)
  270 + get_Float
  271 + (
  272 + List(Web_arg) lwa,
  273 + String name
  274 + ) =
  275 + if web_arg_value(lwa, name) is
  276 + {
  277 + not_found then /*logDebug(debug_log, "Can't find argument '" + name + "'");*/ failure
  278 + found(str) then
  279 + if str = "" then
  280 + failure
  281 + else
  282 + string_to_float(str)
  283 + }.
  284 +
  285 +public define Float
  286 + get_Float
  287 + (
  288 + List(Web_arg) lwa,
  289 + String name,
  290 + Float default_value
  291 + ) =
  292 + if get_Float(lwa, name) is
  293 + {
  294 + failure then default_value,
  295 + success(value) then value
  296 + }.
  297 +
220 298 public define Maybe(Word32)
221 299 get_Word32
222 300 (
... ...
web/CXM_web_session.anubis
... ... @@ -8,6 +8,7 @@
8 8  
9 9 read system/convert.anubis
10 10 read system/muscle.anubis
  11 +read calexium_lib/database/db_types.anubis
11 12 read CXM_common.anubis
12 13 read CXM_web_dump.anubis
13 14  
... ... @@ -16,6 +17,7 @@ public type WEB_Session_Field_Datum:
16 17 string(String), //fully implented
17 18 bool(Bool), //fully implented
18 19 int(Int), //fully implented
  20 + db_id(DB_id),
19 21 message(Message), //fully implented
20 22 byte_array(ByteArray),
21 23 float(Float),
... ... @@ -31,6 +33,7 @@ public type WEB_Session_Field_Type:
31 33 string_t,
32 34 bool_t,
33 35 int_t,
  36 + db_id_t,
34 37 message_t,
35 38 byte_array_t,
36 39 float_t,
... ... @@ -214,7 +217,7 @@ define One
214 217 /*************** String *****************/
215 218  
216 219 Maybe(String) get_String(fields, _field_name)
217   - String get_String(fiels, _field_name, default_value)
  220 + String get_String(fields, _field_name, default_value)
218 221  
219 222 public define Maybe(String)
220 223 get_String
... ... @@ -279,7 +282,7 @@ public define One
279 282 /*************** Bool *****************/
280 283  
281 284 Maybe(Bool) get_Bool(fields, _field_name)
282   - Bool get_Bool(fiels, _field_name, default_value)
  285 + Bool get_Bool(fields, _field_name, default_value)
283 286  
284 287 public define Maybe(Bool)
285 288 get_Bool
... ... @@ -344,7 +347,7 @@ public define One
344 347 /*************** Int *****************/
345 348  
346 349 Maybe(String) get_Int(fields, _field_name)
347   - String get_Int(fiels, _field_name, default_value)
  350 + String get_Int(fields, _field_name, default_value)
348 351  
349 352 public define Maybe(Int)
350 353 get_Int
... ... @@ -406,6 +409,71 @@ public define One
406 409 remove_any(fields, int_t, _field_name)
407 410 .
408 411  
  412 + /*************** DB_id *****************/
  413 +
  414 + Maybe(String) get_DB_id(fields, _field_name)
  415 + String get_DB_id(fields, _field_name, default_value)
  416 +
  417 +public define Maybe(DB_id)
  418 + get_DB_id
  419 + (
  420 + Var(List(WEB_Session_Field)) fields,
  421 + String _field_name,
  422 + ) =
  423 + if get_field(*fields, db_id_t, _field_name) is
  424 + {
  425 + failure then failure,
  426 + success(datum) then
  427 + if datum is db_id(value) then
  428 + success(value)
  429 + else
  430 + failure
  431 + }
  432 +.
  433 +
  434 +public define DB_id
  435 + get_DB_id
  436 + (
  437 + Var(List(WEB_Session_Field)) fields,
  438 + String _field_name,
  439 + DB_id default_value
  440 + ) =
  441 + if get_DB_id(fields, _field_name) is
  442 + {
  443 + failure then default_value
  444 + success(value) then value
  445 + }.
  446 +
  447 +public define One
  448 + put_DB_id
  449 + (
  450 + Var(List(WEB_Session_Field)) fields,
  451 + String _field_name,
  452 + DB_id _field_value
  453 + )=
  454 + fields <- [session_field(_field_name, int_t, var(db_id(_field_value))) . *fields]
  455 +.
  456 +
  457 +public define One
  458 + replace_DB_id
  459 + (
  460 + Var(List(WEB_Session_Field)) fields,
  461 + String _field_name,
  462 + DB_id _field_value
  463 + )=
  464 + replace_any(fields, db_id_t, _field_name, db_id(_field_value))
  465 +.
  466 +
  467 +
  468 +public define One
  469 + remove_DB_id
  470 + (
  471 + Var(List(WEB_Session_Field)) fields,
  472 + String _field_name
  473 + )=
  474 + remove_any(fields, db_id_t, _field_name)
  475 +.
  476 +
409 477 /*************** Message *****************/
410 478  
411 479 Maybe(String) get_Message(fields, _field_name)
... ... @@ -993,6 +1061,7 @@ public define String
993 1061 string(_string) then name+", Type = String, Value = ["+_string+"]",
994 1062 bool(_bool) then name+", Type = Bool, Value = ["+to_String(_bool)+"]",
995 1063 int(_int) then name+", Type = Int, Value = ["+_int+"]",
  1064 + db_id(_db_id) then name+", Type = DB_id, Value = ["+_db_id+"]",
996 1065 message(_message) then name+", Type = Message, Value = ["+dump(_message)+"]",
997 1066 byte_array(_byte_array) then name+", Type = ByteArray",
998 1067 float(_float) then name+", Type = Float, Value = ["+float_to_string(_float, 10)+"]",
... ...
web/CXM_xml_rpc.anubis
... ... @@ -304,7 +304,7 @@ define Maybe(XML_RPC_response)
304 304 )=
305 305 //TODO find the header and content-lenght to get full length of answer
306 306 //construct a buffered connection
307   - with b_con = buffered_connection(conn),
  307 + with b_con = http_buffered_connection(conn),
308 308 if skip_line(b_con) is
309 309 {
310 310 error(msg) then print(format(msg));failure,
... ...
web/jQuery/CXM_jq_checkbox.anubis
... ... @@ -58,7 +58,7 @@ public define HTML_Partial_Content
58 58 [
59 59 js_inline(jquery_ready(checkbox_init_script(checkbox_id, initial_state)))
60 60 ],
61   - jquery_button(jquery_img_button(image_url, checkbox_label, checkbox_id, jQuery_actioner(same, jqscript, checkbox_onclick_script(checkbox_id, on_script, off_script)), orientation))
  61 + jquery_button(jquery_img_button(image_url, checkbox_label, checkbox_id, jQuery_actioner(same, jqscript(checkbox_onclick_script(checkbox_id, on_script, off_script))), orientation))
62 62 ).
63 63  
64 64 public define HTML_Partial_Content
... ...
web/jQuery/CXM_jq_radio.anubis
1   -/*
  1 +/*
2 2 * Created by PyramIDE.
3 3 * User: フランスのトトロ
4 4 * Date: 28/06/2015
... ... @@ -96,7 +96,7 @@ public define HTML_Partial_Content
96 96 [
97 97 js_inline(jquery_ready(radio_init_script(radio_id, radio_group, initial_state)))
98 98 ],
99   - jquery_button(jquery_img_button(image_url, checkbox_label, radio_id, jQuery_actioner(same, jqscript, radio_onclick_script(radio_id, radio_group, multi_select_with_shift, on_script)), orientation))
  99 + jquery_button(jquery_img_button(image_url, checkbox_label, radio_id, jQuery_actioner(same, jqscript(radio_onclick_script(radio_id, radio_group, multi_select_with_shift, on_script))), orientation))
100 100 ).
101 101  
102 102 public define HTML_Partial_Content
... ...
web/jQuery/CXM_jquery_dialog.anubis
... ... @@ -18,6 +18,7 @@ public type JQuery_dialog:
18 18 off_form(HTML_Off_Form o_form),
19 19 ajax(WEB_Action_Name url).
20 20  
  21 +public define JQuery_dialog ajax(String url) = ajax(action_name(url)).
21 22  
22 23 public define HTML_Partial_Content
23 24 jq_dialog_create
... ...
web/jQuery/jqgrid.anubis 0 → 100644
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ aka (David RENÉ)
  4 + * Date: 26/03/2017
  5 + * Time: 18:28
  6 + * © Calexium
  7 + */
  8 +
  9 +read calexium_lib/web/CXM_making_a_web_site.anubis
  10 +
  11 +public define List(HTML_Head_Tag)
  12 + jqgrid_init
  13 + (
  14 + String lang
  15 + )=
  16 + [
  17 + js(js_file("jqGrid/jquery.jqgrid.min.js")),
  18 + css(css_file("jqGrid/css/ui.jqgrid.min.css")),
  19 + js(js_file("jqGrid/i18n/min/grid.locale-"+lang+".js"))
  20 + ]
  21 +.
... ...
web/jQuery/ui-addon/datetimepicker.anubis
... ... @@ -30,7 +30,7 @@ public define String
30 30 Bool add_icon
31 31 ) = "// Datetimepicker\n
32 32 $.datetimepicker.setLocale('"+lang+"');
33   - $('.datepicker').datetimepicker({timepicker:false,format:'d/m/Y'});
  33 + $('.datepicker').datetimepicker({timepicker:false,format:'Y-m-d'});
34 34 $('.datetimepicker').datetimepicker({format:'Y-m-d H:i'});
35 35 $('.timepicker').datetimepicker({datepicker:false,format:'H:i',step:5});
36 36 " + if add_icon then "
... ...
web/types/web_action_name.anubis 0 → 100644
  1 +/*
  2 + * Created by 伝作 (Densaku).
  3 + * Types & Messages generator written by フランスのトトロ aka (David RENÉ)
  4 + * Date: 2017-03-15
  5 + * Time: 02:27:54
  6 + *
  7 + */
  8 +
  9 +transmit system/muscle.anubis
  10 +transmit system/convert.anubis
  11 +transmit tools/basis.anubis
  12 +
  13 +
  14 +public type WEB_Action_Name:
  15 + no_action,
  16 + controller_action(
  17 + String controller,
  18 + String ac_name
  19 + ),
  20 + action_name(
  21 + String ac_name
  22 + ),
  23 + //url is raw action, hence we will only copy that url in final link
  24 +
  25 + url(
  26 + String url_name
  27 + )
  28 +.
  29 +
  30 + WEB_Action_Name message format
  31 + ==============================
  32 +
  33 +
  34 +public define Message
  35 + to_Message
  36 + (
  37 + WEB_Action_Name _web_action_name
  38 + )=
  39 + with _web_action_name_message = message((Word32)0), //
  40 + forget(add_string(_web_action_name_message, "__TYPE__", "WEB_Action_Name"));
  41 + if _web_action_name is
  42 + {
  43 + //Alternative no_action (NO TYPE)
  44 + no_action then
  45 + forget(add_string(_web_action_name_message, "__TYPE_ALT__", "no_action")),
  46 +
  47 + //Alternative controller_action
  48 + controller_action(_controller, _ac_name) then
  49 + forget(add_string(_web_action_name_message, "__TYPE_ALT__", "controller_action"));
  50 + // [type = String] controller_action.controller
  51 + forget(add_string(_web_action_name_message, "controller", _controller));
  52 + // [type = String] controller_action.ac_name
  53 + forget(add_string(_web_action_name_message, "ac_name", _ac_name)),
  54 +
  55 + //Alternative action_name
  56 + action_name(_ac_name) then
  57 + forget(add_string(_web_action_name_message, "__TYPE_ALT__", "action_name"));
  58 + // [type = String] action_name.ac_name
  59 + forget(add_string(_web_action_name_message, "ac_name", _ac_name)),
  60 +
  61 + //Alternative url
  62 + //url is raw action, hence we will only copy that url in final link
  63 + url(_url_name) then
  64 + forget(add_string(_web_action_name_message, "__TYPE_ALT__", "url"));
  65 + // [type = String] url.url_name
  66 + forget(add_string(_web_action_name_message, "url_name", _url_name)),
  67 +
  68 + };
  69 + _web_action_name_message
  70 +.
  71 +
  72 +public define Maybe(WEB_Action_Name)
  73 + from_Message
  74 + (
  75 + Message _web_action_name_message
  76 + )=
  77 + if find_string(_web_action_name_message, "__TYPE__") is {failure then failure, success(__type__) then
  78 + if find_string(_web_action_name_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then
  79 + if __type__ = "WEB_Action_Name" then
  80 + //Alternative no_action (NO TYPE)
  81 + if __type_alt__ = "no_action" then
  82 + success(no_action)
  83 + else //Alternative controller_action
  84 + if __type_alt__ = "controller_action" then //Alternative controller_action
  85 + // [type = String] controller_action.controller
  86 + if find_string(_web_action_name_message, "controller") is {failure then failure, success(controller) then
  87 + // [type = String] controller_action.ac_name
  88 + if find_string(_web_action_name_message, "ac_name") is {failure then failure, success(ac_name) then
  89 +
  90 + success(controller_action(controller, ac_name))
  91 + }}
  92 + else //Alternative action_name
  93 + if __type_alt__ = "action_name" then //Alternative action_name
  94 + // [type = String] action_name.ac_name
  95 + if find_string(_web_action_name_message, "ac_name") is {failure then failure, success(ac_name) then
  96 +
  97 + success(action_name(ac_name))
  98 + }
  99 + else //Alternative url
  100 + //url is raw action, hence we will only copy that url in final link
  101 + if __type_alt__ = "url" then //Alternative url
  102 + // [type = String] url.url_name
  103 + if find_string(_web_action_name_message, "url_name") is {failure then failure, success(url_name) then
  104 +
  105 + success(url(url_name))
  106 + }
  107 + else
  108 + failure //No valid Alternative found !
  109 + else
  110 + failure //Type not found in message !
  111 + }}
  112 +.
  113 +
... ...
web/widgets/button.anubis
... ... @@ -42,7 +42,19 @@ public define HTML_Partial_Content
42 42 String url
43 43 )=
44 44 img_button_flink(img_path, [], same, url).
  45 +
  46 +public define HTML_Partial_Content
  47 + img_button
  48 + (
  49 + String img_path,
  50 + List(CoreAttrs) core_attrs,
  51 + Actioner_Target target,
  52 + WEB_Action_Name url,
  53 + List((String, String)) extra_ops
  54 + )=
  55 + partial_content(actioner(same, same, img_link(core_attrs+[style("cursor: pointer")], img_path, ""), url, extra_ops)).
45 56  
  57 +
46 58 public define HTML_Partial_Content
47 59 img_button
48 60 (
... ... @@ -66,6 +78,15 @@ public define HTML_Partial_Content
66 78 img_button
67 79 (
68 80 String img_path,
  81 + WEB_Action_Name url,
  82 + List((String, String)) extra_ops
  83 + )=
  84 + img_button(img_path, [], same, url, extra_ops).
  85 +
  86 +public define HTML_Partial_Content
  87 + img_button
  88 + (
  89 + String img_path,
69 90 String url,
70 91 List((String, String)) extra_ops
71 92 )=
... ...
web/widgets/icons_set.anubis
... ... @@ -6,11 +6,13 @@
6 6 * © Calexium
7 7 */
8 8  
  9 +public define String icn16_add = "icons/16x16/add.png".
9 10 public define String icn16_edit = "icons/16x16/edit.png".
10 11 public define String icn16_calendar = "icons/16x16/calendar.png".
11 12 public define String icn16_check = "icons/16x16/check.png".
12 13 public define String icn16_clock = "icons/16x16/clock.png".
13 14 public define String icn16_cross = "icons/16x16/cross.png".
  15 +public define String icn16_email = "icons/16x16/email.png".
14 16 public define String icn16_forward = "icons/16x16/forward.png".
15 17 public define String icn16_home = "icons/16x16/home.png".
16 18 public define String icn16_key = "icons/16x16/key.png".
... ... @@ -22,6 +24,7 @@ public define String icn16_group = &quot;icons/16x16/group.png&quot;.
22 24 public define String icn16_question = "icons/16x16/question.png".
23 25 public define String icn16_refresh = "icons/16x16/arrow_refresh.png".
24 26 public define String icn16_vcard_add = "icons/16x16/vcard_add.png".
  27 +public define String icn16_view_list = "icons/16x16/view_list.png".
25 28 public define String icn16_warning = "icons/16x16/warning.png".
26 29  
27 30 public define String icn16_true = "icons/16x16/check.png".
... ...
web/widgets/left_menu.anubis
... ... @@ -43,6 +43,16 @@ public define Left_Menu_Entry
43 43 public define Left_Menu_Entry
44 44 left_menu_entry
45 45 (
  46 + String entry_id,
  47 + String action,
  48 + String text
  49 + )=
  50 + left_menu_entry(entry_id, [], action_name(action), text, [])
  51 + .
  52 +
  53 +public define Left_Menu_Entry
  54 + left_menu_entry
  55 + (
46 56 String entry_id, //it's also use as icon prefix
47 57 WEB_Action_Name action, //action (url to apply when click
48 58 String text, //text to show
... ... @@ -50,6 +60,17 @@ public define Left_Menu_Entry
50 60 )=
51 61 left_menu_entry(entry_id, [], action, text, extra)
52 62 .
  63 +
  64 +public define Left_Menu_Entry
  65 + left_menu_entry
  66 + (
  67 + String entry_id, //it's also use as icon prefix
  68 + String action, //action (url to apply when click
  69 + String text, //text to show
  70 + List((String, String)) extra //extra web arguments to send when click
  71 + )=
  72 + left_menu_entry(entry_id, [], action_name(action), text, extra)
  73 + .
53 74  
54 75 public define Left_Menu_Entry
55 76 title
... ...