Commit f715c0d976749ee62370e2a17220ea2458fcd44e

Authored by totoro
1 parent 1dcf554d

replace String action_name by WEB_Action_Name

introduce WEB_Session management
add database/types generated by densaku
database/db_types.anubis
... ... @@ -8,26 +8,32 @@
8 8 transmit tools/basis.anubis
9 9 transmit tools/ISO-8601.anubis
10 10  
  11 +transmit calexium_lib/database/types/db_id.anubis
  12 +transmit calexium_lib/database/types/db_date.anubis
  13 +transmit calexium_lib/database/types/db_time.anubis
  14 +transmit calexium_lib/database/types/db_datetime.anubis
  15 +transmit calexium_lib/database/types/db_integer.anubis
  16 +
11 17 /* DB_id will is deprecated. Please use next version below all upper case */
12   -public type DB_id:
13   - none,
14   - db_id(Int value).
  18 +//public type DB_id:
  19 +// none,
  20 +// db_id(Int value).
15 21  
16 22 public type DB_ID:
17 23 none,
18 24 pk(Int value).
19 25  
20   -public type DB_datetime:
21   - db_datetime(String datetime). //Date and time in ISO8601 format "YYYY-MM-DD hh:mm:ss"
  26 +//public type DB_datetime:
  27 +// db_datetime(String datetime). //Date and time in ISO8601 format "YYYY-MM-DD hh:mm:ss"
22 28  
23   -public type DB_date:
24   - db_date(String date). //Date in ISO8601 format "YYYY-MM-DD"
25   -
26   -public type DB_time:
27   - db_time(String time). //Time in ISO8601 format "hh:mm:ss"
28   -
29   -public type DB_integer:
30   - db_integer(Int value).
  29 +//public type DB_date:
  30 +// db_date(String date). //Date in ISO8601 format "YYYY-MM-DD"
  31 +//
  32 +//public type DB_time:
  33 +// db_time(String time). //Time in ISO8601 format "hh:mm:ss"
  34 +//
  35 +//public type DB_integer:
  36 +// db_integer(Int value).
31 37  
32 38  
33 39 public define String
... ...
database/types/db_date.anubis 0 → 100644
  1 +/*
  2 + * Created by 伝作 (Densaku).
  3 + * Types & Messages generator written by フランスのトトロ aka (David RENÉ)
  4 + * Date: 2017-02-15
  5 + * Time: 02:18:49
  6 + *
  7 + */
  8 +
  9 +transmit system/muscle.anubis
  10 +transmit system/convert.anubis
  11 +transmit tools/basis.anubis
  12 +
  13 +
  14 +public type DB_date:
  15 + db_date(
  16 + String date //Date and time in ISO8601 format "YYYY-MM-DD"
  17 + )
  18 +.
  19 +
  20 + DB_date message format
  21 + ======================
  22 +
  23 +
  24 +public define Message
  25 + to_Message
  26 + (
  27 + DB_date _db_date
  28 + )=
  29 + with _db_date_message = message((Word32)0), //
  30 + forget(add_string(_db_date_message, "__TYPE__", "DB_date"));
  31 + if _db_date is
  32 + {
  33 + //Alternative db_date
  34 + db_date(_date) then
  35 + forget(add_string(_db_date_message, "__TYPE_ALT__", "db_date"));
  36 + // [type = String] db_date.date
  37 + forget(add_string(_db_date_message, "date", _date)),
  38 +
  39 + };
  40 + _db_date_message
  41 +.
  42 +
  43 +public define Maybe(DB_date)
  44 + from_Message
  45 + (
  46 + Message _db_date_message
  47 + )=
  48 + if find_string(_db_date_message, "__TYPE__") is {failure then failure, success(__type__) then
  49 + if find_string(_db_date_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then
  50 + if __type__ = "DB_date" then
  51 + //Alternative db_date
  52 + if __type_alt__ = "db_date" then //Alternative db_date
  53 + // [type = String] db_date.date
  54 + if find_string(_db_date_message, "date") is {failure then failure, success(date) then
  55 +
  56 + success(db_date(date))
  57 + }
  58 + else
  59 + failure //No valid Alternative found !
  60 + else
  61 + failure //Type not found in message !
  62 + }}
  63 +.
  64 +
... ...
database/types/db_datetime.anubis 0 → 100644
  1 +/*
  2 + * Created by 伝作 (Densaku).
  3 + * Types & Messages generator written by フランスのトトロ aka (David RENÉ)
  4 + * Date: 2017-02-15
  5 + * Time: 02:18:48
  6 + *
  7 + */
  8 +
  9 +transmit system/muscle.anubis
  10 +transmit system/convert.anubis
  11 +transmit tools/basis.anubis
  12 +
  13 +
  14 +public type DB_datetime:
  15 + db_datetime(
  16 + String datetime //Date and time in ISO8601 format "YYYY-MM-DD hh:mm:ss"
  17 + )
  18 +.
  19 +
  20 + DB_datetime message format
  21 + ==========================
  22 +
  23 +
  24 +public define Message
  25 + to_Message
  26 + (
  27 + DB_datetime _db_datetime
  28 + )=
  29 + with _db_datetime_message = message((Word32)0), //
  30 + forget(add_string(_db_datetime_message, "__TYPE__", "DB_datetime"));
  31 + if _db_datetime is
  32 + {
  33 + //Alternative db_datetime
  34 + db_datetime(_datetime) then
  35 + forget(add_string(_db_datetime_message, "__TYPE_ALT__", "db_datetime"));
  36 + // [type = String] db_datetime.datetime
  37 + forget(add_string(_db_datetime_message, "datetime", _datetime)),
  38 +
  39 + };
  40 + _db_datetime_message
  41 +.
  42 +
  43 +public define Maybe(DB_datetime)
  44 + from_Message
  45 + (
  46 + Message _db_datetime_message
  47 + )=
  48 + if find_string(_db_datetime_message, "__TYPE__") is {failure then failure, success(__type__) then
  49 + if find_string(_db_datetime_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then
  50 + if __type__ = "DB_datetime" then
  51 + //Alternative db_datetime
  52 + if __type_alt__ = "db_datetime" then //Alternative db_datetime
  53 + // [type = String] db_datetime.datetime
  54 + if find_string(_db_datetime_message, "datetime") is {failure then failure, success(datetime) then
  55 +
  56 + success(db_datetime(datetime))
  57 + }
  58 + else
  59 + failure //No valid Alternative found !
  60 + else
  61 + failure //Type not found in message !
  62 + }}
  63 +.
  64 +
... ...
database/types/db_id.anubis 0 → 100644
  1 +/*
  2 + * Created by 伝作 (Densaku).
  3 + * Types & Messages generator written by フランスのトトロ aka (David RENÉ)
  4 + * Date: 2017-02-15
  5 + * Time: 02:18:48
  6 + *
  7 + */
  8 +
  9 +transmit system/muscle.anubis
  10 +transmit system/convert.anubis
  11 +transmit tools/basis.anubis
  12 +
  13 +
  14 +public type DB_id:
  15 + none, //no database Primary Key ID
  16 + db_id(
  17 + Int value //Integer value of the Primary Key ID
  18 + )
  19 +.
  20 +
  21 + DB_id message format
  22 + ====================
  23 +
  24 +
  25 +public define Message
  26 + to_Message
  27 + (
  28 + DB_id _db_id
  29 + )=
  30 + with _db_id_message = message((Word32)0), //
  31 + forget(add_string(_db_id_message, "__TYPE__", "DB_id"));
  32 + if _db_id is
  33 + {
  34 + //Alternative none (NO TYPE)
  35 + none then
  36 + forget(add_string(_db_id_message, "__TYPE_ALT__", "none")),
  37 +
  38 + //Alternative db_id
  39 + db_id(_value) then
  40 + forget(add_string(_db_id_message, "__TYPE_ALT__", "db_id"));
  41 + // [type = Int] db_id.value
  42 + forget(add_string(_db_id_message, "value", to_String(_value))),
  43 +
  44 + };
  45 + _db_id_message
  46 +.
  47 +
  48 +public define Maybe(DB_id)
  49 + from_Message
  50 + (
  51 + Message _db_id_message
  52 + )=
  53 + if find_string(_db_id_message, "__TYPE__") is {failure then failure, success(__type__) then
  54 + if find_string(_db_id_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then
  55 + if __type__ = "DB_id" then
  56 + //Alternative none (NO TYPE)
  57 + if __type_alt__ = "none" then
  58 + success(none)
  59 + else //Alternative db_id
  60 + if __type_alt__ = "db_id" then //Alternative db_id
  61 + // [type = Int] db_id.value
  62 + if find_string(_db_id_message, "value") is {failure then failure, success(_value) then
  63 + if decimal_scan(_value) is { failure then failure, success(value) then
  64 +
  65 + success(db_id(value))
  66 + }}
  67 + else
  68 + failure //No valid Alternative found !
  69 + else
  70 + failure //Type not found in message !
  71 + }}
  72 +.
  73 +
... ...
database/types/db_integer.anubis 0 → 100644
  1 +/*
  2 + * Created by 伝作 (Densaku).
  3 + * Types & Messages generator written by フランスのトトロ aka (David RENÉ)
  4 + * Date: 2017-02-15
  5 + * Time: 02:18:49
  6 + *
  7 + */
  8 +
  9 +transmit system/muscle.anubis
  10 +transmit system/convert.anubis
  11 +transmit tools/basis.anubis
  12 +
  13 +
  14 +public type DB_integer:
  15 + db_integer(
  16 + Int value //Integer from datatase
  17 + )
  18 +.
  19 +
  20 + DB_integer message format
  21 + =========================
  22 +
  23 +
  24 +public define Message
  25 + to_Message
  26 + (
  27 + DB_integer _db_integer
  28 + )=
  29 + with _db_integer_message = message((Word32)0), //
  30 + forget(add_string(_db_integer_message, "__TYPE__", "DB_integer"));
  31 + if _db_integer is
  32 + {
  33 + //Alternative db_integer
  34 + db_integer(_value) then
  35 + forget(add_string(_db_integer_message, "__TYPE_ALT__", "db_integer"));
  36 + // [type = Int] db_integer.value
  37 + forget(add_string(_db_integer_message, "value", to_String(_value))),
  38 +
  39 + };
  40 + _db_integer_message
  41 +.
  42 +
  43 +public define Maybe(DB_integer)
  44 + from_Message
  45 + (
  46 + Message _db_integer_message
  47 + )=
  48 + if find_string(_db_integer_message, "__TYPE__") is {failure then failure, success(__type__) then
  49 + if find_string(_db_integer_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then
  50 + if __type__ = "DB_integer" then
  51 + //Alternative db_integer
  52 + if __type_alt__ = "db_integer" then //Alternative db_integer
  53 + // [type = Int] db_integer.value
  54 + if find_string(_db_integer_message, "value") is {failure then failure, success(_value) then
  55 + if decimal_scan(_value) is { failure then failure, success(value) then
  56 +
  57 + success(db_integer(value))
  58 + }}
  59 + else
  60 + failure //No valid Alternative found !
  61 + else
  62 + failure //Type not found in message !
  63 + }}
  64 +.
  65 +
... ...
database/types/db_time.anubis 0 → 100644
  1 +/*
  2 + * Created by 伝作 (Densaku).
  3 + * Types & Messages generator written by フランスのトトロ aka (David RENÉ)
  4 + * Date: 2017-02-15
  5 + * Time: 02:18:49
  6 + *
  7 + */
  8 +
  9 +transmit system/muscle.anubis
  10 +transmit system/convert.anubis
  11 +transmit tools/basis.anubis
  12 +
  13 +
  14 +public type DB_time:
  15 + db_time(
  16 + String time //Date and time in ISO8601 format "hh:mm:ss"
  17 + )
  18 +.
  19 +
  20 + DB_time message format
  21 + ======================
  22 +
  23 +
  24 +public define Message
  25 + to_Message
  26 + (
  27 + DB_time _db_time
  28 + )=
  29 + with _db_time_message = message((Word32)0), //
  30 + forget(add_string(_db_time_message, "__TYPE__", "DB_time"));
  31 + if _db_time is
  32 + {
  33 + //Alternative db_time
  34 + db_time(_time) then
  35 + forget(add_string(_db_time_message, "__TYPE_ALT__", "db_time"));
  36 + // [type = String] db_time.time
  37 + forget(add_string(_db_time_message, "time", _time)),
  38 +
  39 + };
  40 + _db_time_message
  41 +.
  42 +
  43 +public define Maybe(DB_time)
  44 + from_Message
  45 + (
  46 + Message _db_time_message
  47 + )=
  48 + if find_string(_db_time_message, "__TYPE__") is {failure then failure, success(__type__) then
  49 + if find_string(_db_time_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then
  50 + if __type__ = "DB_time" then
  51 + //Alternative db_time
  52 + if __type_alt__ = "db_time" then //Alternative db_time
  53 + // [type = String] db_time.time
  54 + if find_string(_db_time_message, "time") is {failure then failure, success(time) then
  55 +
  56 + success(db_time(time))
  57 + }
  58 + else
  59 + failure //No valid Alternative found !
  60 + else
  61 + failure //Type not found in message !
  62 + }}
  63 +.
  64 +
... ...
web/CXM_form.anubis
... ... @@ -241,7 +241,7 @@ public type CXM_Form_Field:
241 241 //--- submit button -------------------------------------------------------------------
242 242 submit (List(CoreAttrs) options,
243 243 HtmlClass class,
244   - String action_name,
  244 + WEB_Action_Name action_name,
245 245 Maybe(String) label,
246 246 String button_text,
247 247 List((String,String)) extra_operands),
... ... @@ -310,11 +310,11 @@ public define CXM_Form_Field
310 310 = radio_buttonr([], label, html_Id(n.name), n, value, checked, mand).
311 311  
312 312 public define CXM_Form_Field
313   - submit(String action_name, HtmlClass class, Maybe(String) label, String button_text, List((String,String)) extra_operands)
  313 + submit(WEB_Action_Name action_name, HtmlClass class, Maybe(String) label, String button_text, List((String,String)) extra_operands)
314 314 = submit([], class, action_name, label, button_text, extra_operands).
315 315  
316 316 public define CXM_Form_Field
317   - submit(String action_name, Maybe(String) label, String button_text, List((String,String)) extra_operands)
  317 + submit(WEB_Action_Name action_name, Maybe(String) label, String button_text, List((String,String)) extra_operands)
318 318 = submit([], htmlClass(""), action_name, label, button_text, extra_operands).
319 319  
320 320 public define CXM_Form_Field
... ... @@ -619,9 +619,9 @@ public define HTML_In_Form
619 619 public define HTML_Off_Form
620 620 cxm_form
621 621 (
622   - HTML_Id form_Id,
  622 + HTML_Id form_Id,
623 623 List(CoreAttrs) options,
624   - String action_name,
  624 + WEB_Action_Name action,
625 625 List((String,String)) extra_ops,
626 626 List(Web_arg) lwa,
627 627 List(CXM_Form_Field) fields
... ... @@ -630,7 +630,7 @@ public define HTML_Off_Form
630 630 form(
631 631 form_Id,
632 632 [class("cxm_form") . options],
633   - action_name,
  633 + action,
634 634 extra_ops,
635 635 format_CXM_Form_Field(fields, lwa)
636 636 ).
... ... @@ -640,12 +640,12 @@ public define HTML_Off_Form
640 640 (
641 641 String form_name,
642 642 List(CoreAttrs) options,
643   - String action_name,
  643 + WEB_Action_Name action,
644 644 List((String,String)) extra_ops,
645 645 List(Web_arg) lwa,
646 646 List(CXM_Form_Field) form_fields
647 647 )=
648   - cxm_form(html_Id(form_name), options, action_name, extra_ops, lwa, form_fields).
  648 + cxm_form(html_Id(form_name), options, action, extra_ops, lwa, form_fields).
649 649  
650 650 public define HTML_In_Form
651 651 cxm_fieldset
... ... @@ -665,7 +665,7 @@ public define HTML_Off_Form
665 665 List(CoreAttrs) options,
666 666 List(HTML_In_Form) fields
667 667 ) =
668   - cxm_form(html_Id(form_id), options, "", [], [], map((HTML_In_Form field) |-> raw_in_form(field), fields) ).
  668 + cxm_form(html_Id(form_id), options, action_name(""), [], [], map((HTML_In_Form field) |-> raw_in_form(field), fields) ).
669 669  
670 670 public define HTML_Off_Form
671 671 cxm_form
... ... @@ -675,7 +675,7 @@ public define HTML_Off_Form
675 675 List(Web_arg) lwa,
676 676 List(CXM_Form_Field) fields
677 677 ) =
678   - cxm_form(html_Id(form_id), options, "", [], lwa, fields).
  678 + cxm_form(html_Id(form_id), options, action_name(""), [], lwa, fields).
679 679  
680 680 public define HTML_Off_Form
681 681 cxm_form
... ... @@ -683,7 +683,7 @@ public define HTML_Off_Form
683 683 String form_id,
684 684 List(HTML_In_Form) fields
685 685 ) =
686   - cxm_form(html_Id(form_id), [], "", [], [], map((HTML_In_Form field) |-> raw_in_form(field), fields) ).
  686 + cxm_form(html_Id(form_id), [], action_name(""), [], [], map((HTML_In_Form field) |-> raw_in_form(field), fields) ).
687 687  
688 688 public define HTML_Off_Form
689 689 cxm_form
... ... @@ -700,4 +700,4 @@ public define HTML_Off_Form
700 700 String form_id,
701 701 List(CXM_Form_Field) fields
702 702 ) =
703   - cxm_form(html_Id(form_id), [], "", [], [], fields).
  703 + cxm_form(html_Id(form_id), [], action_name(""), [], [], fields).
... ...
web/CXM_making_a_web_site.anubis
... ... @@ -5,7 +5,7 @@
5 5 *Title* Making interactive Web sites.
6 6  
7 7 *Copyright* Copyright (c) Alain Prouté 2004-2005.
8   - Copyright (c) Calexium 2007-2016.
  8 + Copyright (c) Calexium 2007-2017.
9 9  
10 10  
11 11 *Authors* Alain Prouté
... ... @@ -47,7 +47,7 @@
47 47 ---------------------------------------------------------------------------------------
48 48  
49 49  
50   -read tools/basis.anubis
  50 +transmit tools/basis.anubis
51 51 read tools/printable_tree.anubis
52 52 read tools/base64.anubis
53 53 read tools/random.anubis
... ... @@ -55,12 +55,13 @@ read tools/dictionaries.anubis
55 55 read system/lists.anubis
56 56 read system/string.anubis
57 57 read system/logger.anubis
58   -read CXM_common.anubis
59   -read CXM_multihost_http_server.anubis
  58 +transmit CXM_common.anubis
  59 +transmit CXM_multihost_http_server.anubis
60 60 read web/mime.anubis
61 61 read CXM_cookies.anubis
62 62 read CXM_json.anubis
63   -read CXM_web_dump.anubis
  63 +transmit CXM_web_dump.anubis
  64 +transmit CXM_web_arg_utils.anubis
64 65  
65 66 //read CXM_html_tooltip.anubis
66 67  
... ... @@ -276,64 +277,6 @@ public type Web_Action($State):
276 277 In most cases, HTTP informations are not used. This is the reason why they are gathered
277 278 for simplicity into a unique datum of type 'HTTP_Info'.
278 279  
279   -// For your convenience, we introduce the following simpler variants:
280   -//
281   -//public define Web_Action($State)
282   -// http_action
283   -// (
284   -// String name,
285   -// $State -> Bool allow,
286   -// (List(Web_arg),$State) -> $State do_it
287   -// ) =
288   -// http_action(name,
289   -// (Maybe($State) ms) |-> if ms is
290   -// {
291   -// failure then true,
292   -// success(s) then allow(s)
293   -// },
294   -// (HTTP_Info h, List(Web_arg) l, Maybe($State) s) |-> if s is
295   -// {
296   -// failure then (failure, []),
297   -// success(s2) then (success(do_it(l,s2)), [])
298   -// }).
299   -//
300   -//public define Web_Action($State)
301   -// https_action
302   -// (
303   -// String name,
304   -// $State -> Bool allow,
305   -// (List(Web_arg),$State) -> $State do_it
306   -// ) =
307   -// https_action(name,
308   -// (Maybe($State) ms) |-> if ms is
309   -// {
310   -// failure then true,
311   -// success(s) then allow(s)
312   -// },
313   -// (HTTP_Info h, List(Web_arg) l, Maybe($State) s) |-> if s is
314   -// {
315   -// failure then (failure, []),
316   -// success(s2) then (success(do_it(l,s2)), [])
317   -// }).
318   -//
319   -//public define Web_Action($State)
320   -// http_https_action
321   -// (
322   -// String name,
323   -// $State -> Bool allow,
324   -// (List(Web_arg),$State) -> $State do_it
325   -// ) =
326   -// http_https_action(name,
327   -// (Maybe($State) ms) |-> if ms is
328   -// {
329   -// failure then true,
330   -// success(s) then allow(s)
331   -// },
332   -// (HTTP_Info h, List(Web_arg) l, Maybe($State) s) |-> if s is
333   -// {
334   -// failure then (failure, []),
335   -// success(s2) then (success(do_it(l,s2)), [])
336   -// }).
337 280  
338 281  
339 282  
... ... @@ -353,19 +296,189 @@ public type HTTP_Answer:...
353 296 understand the page shown to the client as a representation of the current state of the
354 297 conversation between the client and the web site, but also containing informations
355 298 taken from the data bases.
356   -
357   -transmit CXM_controller.anubis
358   -
359   -public type WEB_Controller($State):
  299 +
  300 +public type WEB_Action_Name:
  301 + controller_action(
  302 + String controller,
  303 + String action_name
  304 + ),
  305 + action_name(
  306 + String name
  307 + )
  308 +.
  309 +
  310 +public type WEB_Session_Entry:
  311 + session_entry(
  312 + String field,
  313 + String value
  314 + ).
  315 +
  316 +public type WEB_Request:
  317 + web_request(
  318 + HTTP_Info http_info,
  319 + List(Web_arg) lwa,
  320 + Bool is_https,
  321 + )
  322 +.
  323 +
  324 +public type WEB_Session:
  325 + web_session(
  326 + String language,
  327 + List(WEB_Session_Entry) entries,
  328 + WEB_Request web_request,
  329 + WEB_Request previous_request
  330 + ).
  331 +
  332 +
  333 +
  334 +public type WEB_Controller_Result:
  335 + http_answer(
  336 + WEB_Session session, //modified session
  337 + HTTP_Answer http_answer //http answer
  338 + ),
  339 + http_answer(
  340 + HTTP_Answer http_answer //http answer
  341 + ),
  342 + redirect( //internal redirection, session is modified to call the right controller and action
  343 + WEB_Session session
  344 + ),
  345 + redirect_to_previous,
  346 + ajax(
  347 + HTTP_Answer http_answer
  348 + )
  349 +.
  350 +
  351 +public type WEB_Action_Allowed_Protocol:
  352 + http,
  353 + https,
  354 + http_https.
  355 +
  356 +public type WEB_Action:
  357 + web_action(
  358 + WEB_Action_Name name, // name of action
  359 + WEB_Action_Allowed_Protocol allowed_proto,
  360 + (WEB_Session) -> Bool allow, // true if action allowed
  361 + (WEB_Session) -> WEB_Controller_Result do_it
  362 + )
  363 +.
  364 +
  365 +public type WEB_Controller:
360 366 web_controller(
361   - String name, //controller name
362   - (HTTP_Info http_info,
363   - List(Web_arg) lwa,
364   - Bool is_https,
365   - $State session
366   - ) -> ($State, HTTP_Answer) view //view renderer
  367 + String name, //controller name
  368 + Var(List(WEB_Action)) controller_actions, //list of all actions of that controller
  369 + (WEB_Session)-> WEB_Controller_Result error //Error renderer
367 370 )
368 371 .
  372 +
  373 +define List(HTTP_header)
  374 + make_session_cookie_headers
  375 + (
  376 + String website_name,
  377 + String session_name
  378 + )
  379 + =
  380 + //println("Set-Cookie state_"+website_name+"="+state_name);
  381 + [
  382 + http_header("Set-Cookie", "session_"+website_name+"="+session_name)
  383 + ]
  384 + .
  385 +
  386 +define WEB_Session -> String // the function constructed returns the name of the state
  387 + make_save_session_function
  388 + (
  389 + Int timeout,
  390 + String state_directory
  391 + ) =
  392 + (WEB_Session s) |->
  393 + //Set the new timeout
  394 + with time_stamp = now+timeout,
  395 + to_be_saved = (time_stamp,s),
  396 + //generate new session name
  397 + session_name = to_ascii(sha1(s)),
  398 + //println("make_save_state_function " + state_directory+"/s"+state_name);
  399 + if save(to_be_saved,state_directory+"/"+session_name) is ok then
  400 + session_name
  401 + else
  402 + println("Cannot create session file in '"+state_directory+"'.\n");
  403 + ""
  404 +.
  405 +
  406 +
  407 + When a request arrives, we need to retrieve the previous state from the server's
  408 + disk. We receive the name of that state. If the state is out of date, the state file is
  409 + kept 3 days, and then deleted.
  410 +
  411 +type Previous_Session:
  412 + not_found, // cannot retrieve the previous state
  413 + out_of_date(WEB_Session p_session), // the previous state is out of date
  414 + still_valid(WEB_Session p_session). // the previous state is still valid
  415 +
  416 +define Previous_Session
  417 + retrieve_session
  418 + (
  419 + HTTP_Info http_info,
  420 + String session_directory,
  421 + String website_name
  422 + ) =
  423 + if find_cookie("session_"+website_name, server_get_cookies(http_headers(http_info))) is
  424 + {
  425 + failure then not_found
  426 + success(cookie) then
  427 + //println("find_cookie(\"state_"+website_name+"\" success");
  428 + with session_name = value(cookie),
  429 + with file_path = session_directory+"/"+session_name,
  430 + //unserialize the stored session and his timeout value
  431 + if (RetrieveResult((Int, WEB_Session)))retrieve(file_path) is ok(d) then
  432 + (
  433 + since d is (time_stamp, s),
  434 + if time_stamp < now then
  435 + (
  436 + forget(remove(file_path));
  437 + out_of_date(s)
  438 + )
  439 + else
  440 + still_valid(s) // state has been successfully retrieved
  441 + )
  442 + else
  443 + not_found
  444 + }
  445 +.
  446 +
  447 +define (List(String) file_names) -> One
  448 + make_delete_out_of_date_sessions_function
  449 + (
  450 + String state_directory
  451 + ) =
  452 + (List(String) file_names) |-df->
  453 + if file_names is
  454 + {
  455 + [ ] then unique,
  456 + [h . t] then
  457 + with file_path = state_directory+"/"+h,
  458 + if (RetrieveResult((Int, WEB_Session)))retrieve(file_path) is ok(d)
  459 + then (
  460 + if d is (time_stamp,data) then
  461 + if time_stamp < now
  462 + then (forget(remove(file_path)); df(t))
  463 + else df(t)
  464 + )
  465 + else (forget(remove(file_path)); df(t))
  466 + }.
  467 +
  468 +define One
  469 + delete_out_of_date_sessions // for all web sites
  470 + (
  471 + List((String, List(String) -> One)) directories_and_functions
  472 + )=
  473 + if directories_and_functions is
  474 + {
  475 + [ ] then unique,
  476 + [h . t] then
  477 + since h is (state_directory, function),
  478 + function(directory_list(state_directory,"*"));
  479 + delete_out_of_date_sessions(t)
  480 + }
  481 +.
369 482  
370 483 ** (1.5) States.
371 484  
... ... @@ -1236,7 +1349,7 @@ public type HTML_In_Form:
1236 1349 Int content_width, Int content_height,
1237 1350 HTML_In_Form content),
1238 1351 actioner (Actioner_Connection, Actioner_Target, Actioner_Aspect,
1239   - String action_name, List((String,String)) extra_ops,
  1352 + WEB_Action_Name action_name, List((String,String)) extra_ops,
1240 1353 List(Actioner_Local_Action)),
1241 1354 foreign_link_new (Actioner_Target, Actioner_Aspect, String url),
1242 1355 foreign_link (List(Text_Option), String url),
... ... @@ -1293,15 +1406,16 @@ public define HTML_In_Form
1293 1406 foreign_link([size(tsize)],url,name).
1294 1407  
1295 1408 public define HTML_In_Form
1296   - actioner
1297   - (
  1409 + actioner
  1410 + (
1298 1411 Actioner_Connection conn,
1299 1412 Actioner_Target targ,
1300 1413 Actioner_Aspect asp,
1301   - String action_name,
  1414 + WEB_Action_Name action,
1302 1415 List((String,String)) extra_ops
1303   - ) =
1304   - actioner(conn,targ,asp,action_name,extra_ops,[]).
  1416 + )=
  1417 + actioner(conn,targ,asp,action,extra_ops,[])
  1418 +.
1305 1419  
1306 1420 public define HTML_In_Form
1307 1421 actioner
... ... @@ -1310,7 +1424,7 @@ public define HTML_In_Form
1310 1424 Actioner_Target targ,
1311 1425 Actioner_Aspect asp,
1312 1426 ) =
1313   - actioner(conn, targ, asp, "", [], []).
  1427 + actioner(conn, targ, asp, action_name(""), [], []).
1314 1428  
1315 1429  
1316 1430 public define HTML_In_Form
... ... @@ -1454,10 +1568,10 @@ public type HTML_Off_Form:
1454 1568 fixed_size (HTML_Size width, HTML_Size height, HTML_Off_Form content),
1455 1569 fixed_size_2 (HTML_Size width, HTML_Size height, String name_of_HTML_file),
1456 1570 actioner (Actioner_Connection, Actioner_Target, Actioner_Aspect,
1457   - String action_name, List((String,String)) extra_ops,
  1571 + WEB_Action_Name action_name, List((String,String)) extra_ops,
1458 1572 List(Actioner_Local_Action)),
1459 1573 actioner (Actioner_Connection, Actioner_Target, Actioner_Aspect,
1460   - String action_name, List((String,String)) extra_ops,
  1574 + WEB_Action_Name action_name, List((String,String)) extra_ops,
1461 1575 List(Actioner_Local_Action), String form_name),
1462 1576 foreign_link_new (Actioner_Target, Actioner_Aspect, String url),
1463 1577 foreign_link (List(Text_Option), String url),
... ... @@ -1467,7 +1581,7 @@ public type HTML_Off_Form:
1467 1581 label (String name),
1468 1582 form (HTML_Id form_id, List(CoreAttrs), HTML_In_Form content),
1469 1583 form (HTML_Id form_id, List(CoreAttrs),
1470   - String action_name, List((String,String)) extra_ops,
  1584 + WEB_Action_Name action, List((String,String)) extra_ops,
1471 1585 HTML_In_Form content),
1472 1586 in_form (HTML_Id form_id, HTML_In_Form content),
1473 1587 div (List(CoreAttrs), HTML_Off_Form content),
... ... @@ -1507,11 +1621,11 @@ public define HTML_Off_Form
1507 1621 (
1508 1622 String form_name,
1509 1623 List(CoreAttrs) options,
1510   - String action_name,
  1624 + WEB_Action_Name action,
1511 1625 List((String,String)) extra_ops,
1512 1626 HTML_In_Form content
1513 1627 ) =
1514   - form(html_Id(form_name), options, action_name, extra_ops, content).
  1628 + form(html_Id(form_name), options, action, extra_ops, content).
1515 1629  
1516 1630  
1517 1631 public define HTML_Off_Form literal(Printable_tree t) = literal_pt(t).
... ... @@ -1535,10 +1649,10 @@ public define HTML_Off_Form
1535 1649 Actioner_Connection conn,
1536 1650 Actioner_Target targ,
1537 1651 Actioner_Aspect asp,
1538   - String action_name,
  1652 + WEB_Action_Name action,
1539 1653 List((String,String)) extra_ops
1540 1654 ) =
1541   - actioner(conn,targ,asp,action_name,extra_ops,[]).
  1655 + actioner(conn,targ,asp,action,extra_ops,[]).
1542 1656  
1543 1657 public define HTML_Off_Form
1544 1658 table
... ... @@ -1772,8 +1886,8 @@ define Printable_tree
1772 1886 public type HTML_Meta:
1773 1887 keywords (List(String)),
1774 1888 refresh (Actioner_Connection connection,
1775   - Actioner_Target target,
1776   - String action_name,
  1889 + Actioner_Target target,
  1890 + WEB_Action_Name action,
1777 1891 Int delay), // in seconds
1778 1892 refresh (String url, Int delay), // in seconds
1779 1893 meta (String name, String content),
... ... @@ -2009,22 +2123,26 @@ public define HTTP_Answer
2009 2123 *** [1] States.
2010 2124 *** [1.1] Saving and retrieving states.
2011 2125 *** [1.2] Deleting out of date states.
  2126 +
  2127 + *** [2] Sessions.
  2128 + *** [2.1] Saving and retrieving sessions.
  2129 + *** [2.2] Deleting out of date sessions.
  2130 +
  2131 + *** [3] Tools.
  2132 + *** [3.1] Directories.
  2133 + *** [3.2] Secondary documents.
2012 2134  
2013   - *** [2] Tools.
2014   - *** [2.1] Directories.
2015   - *** [2.2] Secondary documents.
2016   -
2017   - *** [3] Managing web arguments.
  2135 + *** [4] Managing web arguments.
2018 2136 *** [3.1] Prefixing web arguments names.
2019 2137 *** [3.2] Separating web arguments.
2020 2138 *** [3.3] Applying an action.
2021 2139  
2022   - *** [4] Web site descriptions and the 'awp handlers'.
  2140 + *** [5] Web site descriptions and the 'awp handlers'.
2023 2141 *** [4.1] The type 'Web_Site'.
2024 2142 *** [4.2] Making a web site description.
2025 2143 *** [4.3] Starting the servers.
2026 2144  
2027   - *** [5] HTML Formating.
  2145 + *** [6] HTML Formating.
2028 2146 *** [5.1] The type 'HTML_Any($T)'.
2029 2147 *** [5.2] Formating a color.
2030 2148 *** [5.3] Creating buttons.
... ... @@ -2043,7 +2161,7 @@ define Printable_tree
2043 2161 format
2044 2162 (
2045 2163 CommonInfo cinfo,
2046   - String sn, // state_name
  2164 + //String sn, // state_name
2047 2165 Var(Int) ic_v, // 'idnum' counter variable
2048 2166 HTML_Off_Form element,
2049 2167 Bool is_https,
... ... @@ -2086,7 +2204,8 @@ read CXM_web_arg_encode.anubis
2086 2204  
2087 2205 The tool below constructs the function which is able to save a state on the server's
2088 2206 disk.
2089   -
  2207 +
  2208 +
2090 2209 define ($State s) -> String // the function constructed returns the name of the state
2091 2210 make_save_state_function
2092 2211 (
... ... @@ -2129,7 +2248,9 @@ define (String state_name) -&gt; PreviousState($State)
2129 2248 )
2130 2249 else still_valid(s) // state has been successfully retrieved
2131 2250 )
2132   - else not_found.
  2251 + else
  2252 + forget(remove(file_path));
  2253 + not_found.
2133 2254  
2134 2255  
2135 2256  
... ... @@ -2150,7 +2271,7 @@ define (List(String) file_names) -&gt; One
2150 2271 {
2151 2272 [ ] then unique,
2152 2273 [h . t] then
2153   - with file_path = state_directory+"/"+h,
  2274 + with file_path = state_directory+"/s"+h,
2154 2275 if (RetrieveResult((Int,$State)))retrieve(file_path) is ok(d)
2155 2276 then (
2156 2277 if d is (time_stamp,data) then
... ... @@ -2159,7 +2280,7 @@ define (List(String) file_names) -&gt; One
2159 2280 else df(t)
2160 2281 )
2161 2282 else (forget(remove(file_path)); df(t))
2162   - }.
  2283 + }.
2163 2284  
2164 2285  
2165 2286 The 'labelled arrow' |-df-> is documented in 'documentation/en/anubis_doc.txt'.
... ... @@ -2223,7 +2344,7 @@ define One
2223 2344 else if now > next_time
2224 2345 then
2225 2346 (
2226   - delete_out_of_date_states(directories_and_functions);
  2347 + delete_out_of_date_states(directories_and_functions);
2227 2348 delete_states_loop(directories_and_functions,
2228 2349 timeout,
2229 2350 now+timeout,
... ... @@ -2276,7 +2397,6 @@ define String
2276 2397 (
2277 2398 String sd, // site directory
2278 2399 String as, // authorization_secret
2279   - String sn, // state name
2280 2400 $T -> Printable_tree format_element,
2281 2401 $T content,
2282 2402 HTML_Size width
... ... @@ -2428,8 +2548,6 @@ define (List(Web_arg) lwa, HTTP_Info info) -&gt; Separated_Web_Args($State)
2428 2548  
2429 2549  
2430 2550  
2431   -
2432   -
2433 2551  
2434 2552 *** [3.3] Applying an action.
2435 2553  
... ... @@ -2546,7 +2664,7 @@ public define Printable_tree
2546 2664 format
2547 2665 (
2548 2666 CommonInfo cinfo,
2549   - String state_name,
  2667 + //String state_name,
2550 2668 List(HTTP_header) headers,
2551 2669 HTTP_Answer page,
2552 2670 Bool is_https,
... ... @@ -2681,7 +2799,7 @@ public define Web_Site
2681 2799 },
2682 2800  
2683 2801 format(info(host_name, http_port, https_port, site_directory, secret),
2684   - state_name,
  2802 + //state_name,
2685 2803 additional_headers(new_state) + cookie_headers,
2686 2804 compute_page(new_state),
2687 2805 is_https,
... ... @@ -2726,17 +2844,17 @@ public define Web_Site
2726 2844 ) -> HTTP_Answer view //view renderer
2727 2845 )
2728 2846  
2729   -define ($State, HTTP_Answer)
2730   - controller_404
2731   - (HTTP_Info http_info,
2732   - List(Web_arg) lwa,
2733   - Bool is_https,
2734   - $State session
2735   - ) =
2736   - (session,
  2847 +
  2848 +
  2849 +define HTTP_Answer
  2850 + error_page
  2851 + (
  2852 + HTTP_Status http_status
  2853 + )
  2854 + =
2737 2855 html_page
2738 2856 (
2739   - "page not found", // title of web site
  2857 + http_status, // status
2740 2858 [], // list of 'META' tags (empty for this site)
2741 2859 body // body of page
2742 2860 (
... ... @@ -2746,56 +2864,141 @@ define ($State, HTTP_Answer)
2746 2864 ],
2747 2865  
2748 2866 // content of page
2749   - center(text([size(14)],"Error 404, Page not found"))
  2867 + sequence([
  2868 + text([size(16)], "Anubis Web Server 1.14"),
  2869 + br,
  2870 + text([size(16)],"Error "+to_String(http_status))
  2871 + ])
2750 2872 )
2751   - ))
  2873 + )
2752 2874 .
2753 2875  
2754   -define (HTTP_Info http_info,
2755   - List(Web_arg) lwa,
2756   - Bool is_https,
2757   - $State session
2758   - ) -> ($State, HTTP_Answer)
  2876 +define WEB_Controller_Result
  2877 + apply_action
  2878 + (
  2879 + WEB_Session _session,
  2880 + String requested_action_name,
  2881 + List(WEB_Action) actions_list
  2882 + ) =
  2883 + if actions_list is
  2884 + {
  2885 + [] then http_answer(error_page(http_not_found)),
  2886 + [h . t] then
  2887 + with action_name = if h.name is
  2888 + {
  2889 + controller_action(_, name) then name,
  2890 + action_name(name) then name
  2891 + },
  2892 + if requested_action_name = action_name then
  2893 + if h.allowed_proto is
  2894 + {
  2895 + //Action only in HTTP
  2896 + http then
  2897 + if _session.web_request.is_https then
  2898 + http_answer(error_page(http_forbidden))
  2899 + else
  2900 + //ask to the server the authorization to execute that action
  2901 + if h.allow(_session) then
  2902 + h.do_it(_session)
  2903 + else
  2904 + http_answer(error_page(http_unauthorized))
  2905 +
  2906 + //Action only in HTTPS
  2907 + https then
  2908 + if _session.web_request.is_https then
  2909 + //ask to the server the authorization to execute that action
  2910 + if h.allow(_session) then
  2911 + h.do_it(_session)
  2912 + else
  2913 + http_answer(error_page(http_unauthorized))
  2914 + else
  2915 + http_answer(error_page(http_forbidden))
  2916 + //Action in both HTTP / HTTPS
  2917 + http_https then
  2918 + //ask to the server the authorization to execute that action
  2919 + if h.allow(_session) then
  2920 + h.do_it(_session)
  2921 + else
  2922 + http_answer(error_page(http_unauthorized))
  2923 +
  2924 + }
  2925 + else
  2926 + apply_action(_session, requested_action_name, t)
  2927 + }
  2928 +.
  2929 +
  2930 +define Maybe(WEB_Controller)
2759 2931 get_controller
2760 2932 (
2761 2933 String controller_name,
2762   - List(WEB_Controller($State)) controllers
  2934 + List(WEB_Controller) controllers,
2763 2935 )=
2764 2936 if controllers is
2765 2937 {
2766   - [] then controller_404,
  2938 + [] then failure,
2767 2939 [h . t] then
2768 2940 if h.name = controller_name then
2769   - h.view
  2941 + success(h)
2770 2942 else
2771 2943 get_controller(controller_name, t)
2772 2944 }
2773 2945 .
2774 2946  
  2947 +define (Maybe(WEB_Session), HTTP_Answer)
  2948 + apply_controller_action
  2949 + (
  2950 + WEB_Controller controller,
  2951 + List(WEB_Controller) controllers,
  2952 + WEB_Session _session
  2953 + )=
  2954 + //get the action name
  2955 + if get_String(_session.web_request.lwa, "aws_action") is
  2956 + {
  2957 + failure then (failure, error_page(http_not_found)),
  2958 + success(action_name) then
  2959 +
  2960 + if apply_action(_session, action_name, *controller.controller_actions) is
  2961 + {
  2962 + http_answer(session, answer) then (success(session), answer),
  2963 + http_answer(answer) then (success(_session), answer),
  2964 + redirect(new_session) then
  2965 + if get_controller(get_String(new_session.web_request.lwa, "aws_controller", "root"), controllers) is
  2966 + {
  2967 + failure then (failure, error_page(http_not_found)),
  2968 + success(new_controller) then apply_controller_action(new_controller, controllers, new_session),
  2969 + }
  2970 +
  2971 + redirect_to_previous then
  2972 + if get_controller(get_String(_session.previous_request.lwa, "aws_controller", "root"), controllers) is
  2973 + {
  2974 + failure then (failure, error_page(http_not_found)),
  2975 + success(new_controller) then
  2976 + since _session is web_session(lang, entries, _, previous),
  2977 + apply_controller_action(new_controller, controllers, web_session(lang, entries, previous, previous)),
  2978 + }
  2979 +
  2980 + ajax(answer) then (failure, answer),
  2981 + }
  2982 + }
  2983 +.
  2984 +
2775 2985 public define Web_Site
2776   - make_web_site_controller_description
2777   - (
2778   - String website_name, // site_UID
2779   - List(String) common_names, // for example: ["www.our-business.com"]
2780   - String site_directory,
2781   - String state_directory,
2782   - One -> One init,
  2986 + make_web_site_controller_description
  2987 + (
  2988 + String website_name, // site_UID
  2989 + List(String) common_names, // for example: ["www.our-business.com"]
  2990 + String site_directory,
  2991 + String state_directory,
  2992 + One -> One init,
2783 2993 (HTTP_Info,
2784 2994 List(Web_arg),
2785   - Bool is_https) -> $State initial_state,
2786   - ($State expired,
2787   - Maybe(String),
2788   - HTTP_Info,
2789   - List(Web_arg),
2790   - Bool is_https) -> $State ticket_expired_state,
2791   - (Maybe(String),
  2995 + Bool is_https) -> WEB_Session initial_session,
  2996 + (WEB_Session,
2792 2997 HTTP_Info,
2793 2998 List(Web_arg),
2794   - Bool is_https) -> $State ticket_lost_state,
2795   - //List(Web_Action($State)) actions,
2796   - Var(List(WEB_Controller($State))) web_controllers,
2797   - //$State -> HTTP_Answer compute_page,
2798   - $State -> List(HTTP_header) additional_headers,
  2999 + Bool is_https) -> WEB_Session expired_session,
  3000 + Var(List(WEB_Controller)) web_controllers,
  3001 + Maybe(WEB_Session) -> List(HTTP_header) additional_headers,
2799 3002 Int timeout,
2800 3003 Redirections redirections,
2801 3004 String charset,
... ... @@ -2805,9 +3008,9 @@ public define Web_Site
2805 3008 List(MIME) known_mime_types,
2806 3009 (String action_name,
2807 3010 List(Web_arg) args) -> One before_send_file
2808   - //Bool using_state_cookies
2809   - ) =
2810   - init(unique);
  3011 + )=
  3012 + //call the initialization function
  3013 + init(unique);
2811 3014  
2812 3015  
2813 3016 //
... ... @@ -2820,72 +3023,74 @@ public define Web_Site
2820 3023 //
2821 3024 // construct tool functions
2822 3025 // TODO 'make_separate_web_args_function' must retrieve state_cookies before parsing web_args if using_state_cookies is true
2823   - with save_state = make_save_state_function(timeout, state_directory),
2824   - retrieve_state = make_retrieve_state_function(state_directory),
2825   - separate_web_args = make_separate_web_args_function(state_directory, retrieve_state, website_name),
  3026 + with save_session = make_save_session_function(timeout, state_directory),
  3027 + // retrieve_session = make_retrieve_session_function(state_directory, website_name),
  3028 + //separate_web_args = make_separate_web_args_function(state_directory, retrieve_state),
2826 3029 //apply_action = make_apply_action_function(actions),
  3030 +
2827 3031 //
2828 3032 // construct the site handler
2829 3033 //
2830   - site_handler = (Word32 http_port, Word32 https_port) |->
  3034 + site_handler = (Word32 http_port, Word32 https_port) |->
2831 3035 ((String host_name,
2832 3036 HTTP_Info http_info,
2833   - List(Web_arg) lwa,
  3037 + List(Web_arg) _lwa,
2834 3038 Bool is_https) |->
2835 3039 //(Printable_tree)
  3040 + println("host_name "+host_name);
2836 3041 println(dump_http_info(http_info));
2837   - println(dump_web_arg_values(lwa));
  3042 + println(dump_web_arg_values(_lwa));
2838 3043  
2839   - since separate_web_args(lwa, http_info) is swa(mb_previous_state, mb_action_name, operands),
2840   -
2841   - with new_state = if mb_previous_state is
2842   - {
2843   - not_found then
2844   - //println("previous state not found");
2845   - if mb_action_name is
2846   - {
2847   - failure then initial_state(http_info, operands, is_https),
2848   - success(_) then
2849   - ticket_lost_state(mb_action_name, http_info,operands,is_https)
2850   - },
2851 3044  
2852   - out_of_date(state) then
2853   - //println("previous out_of_date");
2854   - ticket_expired_state(state, mb_action_name, http_info,operands,is_https),
  3045 + //retrieve the previous session and determine the new one
  3046 + with current_session = if retrieve_session(http_info, state_directory, website_name) is
  3047 + {
  3048 + not_found then
  3049 + //println("previous state not found");
  3050 + initial_session(http_info, _lwa, is_https),
2855 3051  
2856   - still_valid(state) then state
  3052 + out_of_date(previous_session) then
  3053 + //println("previous out_of_date");
  3054 + expired_session(previous_session, http_info, _lwa, is_https),
2857 3055  
2858   - },
2859   - //if state_and_headers is (session_ticket, mb_new_state, headers) then
2860   - with state_name = save_state(new_state),
2861   - //println("Cookie new STATE NAME "+state_name);
2862   - with cookie_headers = if mb_action_name is
2863   - {
2864   - failure then
2865   - make_state_cookie_headers(website_name, state_name),
2866   - success(action_name) then
2867   - if action_name = "none" then
2868   - []
2869   - else if substr(action_name, 0, 5)="ajax_" then
2870   - []
2871   - else
2872   - make_state_cookie_headers(website_name, state_name)
2873   - },
2874   - with controller = get_controller("root", *web_controllers),
2875   - since controller(http_info, lwa, is_https, new_state) is (result_state, http_answer),
2876   - format(info(host_name, http_port, https_port, site_directory, secret),
2877   - state_name,
2878   - additional_headers(new_state) + cookie_headers,
2879   - http_answer,
2880   - is_https,
2881   - charset)
2882   - ),
  3056 + still_valid(previous_session) then
  3057 + since previous_session is web_session(lang, entries, previous, _),
  3058 + web_session(lang, entries, web_request(http_info, _lwa, is_https), previous)
  3059 + },
  3060 +
  3061 +
  3062 + //apply the action according to current session
  3063 + //since apply_controller_action(get_controller(get_String(lwa, "aws_controller", "root"), *web_controllers), *web_controllers, current_session)
  3064 + since if get_controller(get_String(current_session.web_request.lwa, "aws_controller", "root"), *web_controllers) is
  3065 + {
  3066 + failure then (failure, error_page(http_not_found)),
  3067 + success(new_controller) then apply_controller_action(new_controller, *web_controllers, current_session),
  3068 + }
  3069 + is (mb_new_session, http_answer),
  3070 +
  3071 + //save the session if need and construct the according cookie
  3072 + with cookie_headers =
  3073 + if mb_new_session is
  3074 + {
  3075 + failure then [],
  3076 + success(new_session) then
  3077 + with session_name = save_session(new_session),
  3078 + make_session_cookie_headers(website_name, session_name)
  3079 + },
  3080 +
  3081 + //formatting and send http answer because this is the last function
  3082 + format(info(host_name, http_port, https_port, site_directory, secret),
  3083 + //state_name,
  3084 + additional_headers(mb_new_session) + cookie_headers,
  3085 + http_answer,
  3086 + is_https,
  3087 + charset)
  3088 + ),
2883 3089 //
2884 3090 // make the delete_out_of_date function
2885 3091 //
2886 3092 delete_out_of_date =
2887   - make_delete_out_of_date_states_function((Maybe($State))failure,
2888   - site_directory+"/states"),
  3093 + make_delete_out_of_date_sessions_function(site_directory+"/states"),
2889 3094 //
2890 3095 // construct the web site description
2891 3096 //
... ... @@ -2899,13 +3104,14 @@ public define Web_Site
2899 3104 secret,
2900 3105 known_mime_types,
2901 3106 site_handler(http_port,https_port),
2902   - (HTTP_Info http_info, List(Web_arg) lwa) |-> if separate_web_args(lwa, http_info ) is
2903   - swa(mb_previous_state,mb_action_name,operands) then
2904   - if mb_action_name is
2905   - {
2906   - failure then unique
2907   - success(an) then before_send_file(an,operands)
2908   - }
  3107 + (HTTP_Info http_info, List(Web_arg) lwa) |-> unique
  3108 +// if separate_web_args(lwa, http_info ) is
  3109 +// swa(mb_previous_state,mb_action_name,operands) then
  3110 +// if mb_action_name is
  3111 +// {
  3112 +// failure then unique
  3113 +// success(an) then before_send_file(an,operands)
  3114 +// }
2909 3115 //using_state_cookies
2910 3116 ),
2911 3117 delete_out_of_date).
... ... @@ -3102,7 +3308,7 @@ type HTML_Any($T):
3102 3308 any_actioner (Actioner_Connection,
3103 3309 Actioner_Target,
3104 3310 Actioner_Aspect,
3105   - String action_name,
  3311 + WEB_Action_Name action,
3106 3312 List((String,String)) extra_ops,
3107 3313 List(Actioner_Local_Action),
3108 3314 Maybe(String) form_name),
... ... @@ -3298,25 +3504,39 @@ define Int
3298 3504 window.
3299 3505  
3300 3506 define String
3301   - make_actioner_url
3302   - (
3303   - CommonInfo cinfo,
3304   - Actioner_Connection connection,
3305   - Actioner_Target target,
3306   - String state_name,
3307   - String action_name,
3308   - List((String,String)) extra_ops,
3309   - Bool is_https
3310   - ) =
  3507 + make_actioner_url
  3508 + (
  3509 + CommonInfo cinfo,
  3510 + Actioner_Connection connection,
  3511 + Actioner_Target target,
  3512 + WEB_Action_Name action,
  3513 + List((String,String)) extra_ops,
  3514 + Bool is_https
  3515 + ) =
3311 3516 if cinfo is info(common_name,http_port,https_port,site_directory,secret) then
3312 3517 with strict_url =
3313 3518 if connection is
3314 3519 {
3315 3520 same then "/",
3316   - http then "http://"+common_name+":"+http_port+"/",
3317   - https then "https://"+common_name+":"+https_port+"/",
  3521 + http then
  3522 + if http_port = 80 then
  3523 + "http://"+common_name+"/"
  3524 + else
  3525 + "http://"+common_name+":"+http_port+"/",
  3526 + https then
  3527 + if https_port = 443 then
  3528 + "https://"+common_name+"/"
  3529 + else
  3530 + "https://"+common_name+":"+https_port+"/",
3318 3531 } +
3319   - "?a=" + action_name +
  3532 + //with action_string =
  3533 + if action is
  3534 + {
  3535 + controller_action(controller, action_name) then "?aws_controller="+controller+"&amp;aws_action="+action_name,
  3536 + action_name(action_name) then "?aws_action="+action_name
  3537 + }
  3538 + //"?a=" + action_name +
  3539 + +
3320 3540 format_extra_operands(extra_ops),
3321 3541 if target is
3322 3542 {
... ... @@ -3738,7 +3958,7 @@ define Printable_tree
3738 3958 String url,
3739 3959 Bool is_https,
3740 3960 CommonInfo cinfo,
3741   - String state_name,
  3961 +// String state_name,
3742 3962 Var(Int) action_count,
3743 3963 Var(Int) ic_v, // 'idnum' counter variable
3744 3964 Var(List(HTML_Head_Tag)) head_tags
... ... @@ -3781,7 +4001,7 @@ define Printable_tree
3781 4001 html(html_off_form) then
3782 4002 [
3783 4003 "<a href=\"", full_url, "\">",
3784   - format(cinfo, state_name, ic_v, html_off_form, is_https, action_count, head_tags),
  4004 + format(cinfo, ic_v, html_off_form, is_https, action_count, head_tags),
3785 4005 "</a>"
3786 4006 ]
3787 4007 }.
... ... @@ -3790,11 +4010,10 @@ define Printable_tree
3790 4010 format_actioner
3791 4011 (
3792 4012 CommonInfo cinfo,
3793   - String state_name,
3794 4013 Actioner_Connection connection,
3795 4014 Actioner_Target target,
3796 4015 Actioner_Aspect aspect,
3797   - String action_name,
  4016 + WEB_Action_Name action,
3798 4017 List((String,String)) extra_ops,
3799 4018 List(Actioner_Local_Action) local_actions,
3800 4019 Maybe(String) mb_form_name,
... ... @@ -3807,8 +4026,8 @@ define Printable_tree
3807 4026  
3808 4027 if cinfo is info(common_name,http_port,https_port,site_dir,secret) then
3809 4028 with url = make_actioner_url(cinfo,connection,target,
3810   - state_name,action_name,extra_ops,is_https),
3811   - with action = format_action(url, aspect, extract_id(aspect), mb_form_name, action_count),
  4029 + action,extra_ops,is_https),
  4030 + with formatted_action = format_action(url, aspect, extract_id(aspect), mb_form_name, action_count),
3812 4031 if aspect is
3813 4032 {
3814 4033  
... ... @@ -3821,6 +4040,10 @@ define Printable_tree
3821 4040 ],
3822 4041 img_link(options, img, alt_text) then
3823 4042 //if action name is empty, format options on image because maybe there onclick action
  4043 + with action_name = if action is {
  4044 + controller_action(_, an) then an,
  4045 + action_name(an) then an
  4046 + },
3824 4047 if action_name ="" then
3825 4048 [
3826 4049 "<img src=\"", img,"\"",
... ... @@ -3833,12 +4056,18 @@ define Printable_tree
3833 4056 ],
3834 4057 push_button(options, text) then
3835 4058 [
3836   - if action is
  4059 + if formatted_action is
3837 4060 {
3838 4061 url(u) then ["<a href=\"",u,"\"", format_attrs(options), ">",
3839 4062 text, "</a>"
3840 4063 ],
3841 4064 javascript(s,h) then
  4065 + with action_name =
  4066 + if action is
  4067 + {
  4068 + controller_action(_, an) then an,
  4069 + action_name(an) then an
  4070 + },
3842 4071 if action_name = "" then
3843 4072 ["<input type=\"button\" value=\"",text,"\"", format_attrs(options), " />"]
3844 4073 else
... ... @@ -3846,7 +4075,7 @@ define Printable_tree
3846 4075 }
3847 4076 ],
3848 4077 button(url_off,url_on) then
3849   - [ if action is
  4078 + [ if formatted_action is
3850 4079 {
3851 4080 url(u) then ["<a href=\"",u],
3852 4081 javascript(s,h) then [s,"<a onMouseDown=\"",h]
... ... @@ -3859,7 +4088,7 @@ define Printable_tree
3859 4088 ],
3860 4089  
3861 4090 button(url_off,url_on,w,h) then
3862   - [ if action is
  4091 + [ if formatted_action is
3863 4092 {
3864 4093 url(u) then ["<a href=\"",u],
3865 4094 javascript(s,h2) then [s,"<a onMouseDown=\"",h2]
... ... @@ -3873,12 +4102,16 @@ define Printable_tree
3873 4102  
3874 4103 submit(options, text) then
3875 4104 [
3876   - if action is
  4105 + if formatted_action is
3877 4106 {
3878 4107 url(u) then ["<a href=\"",u,"\"", format_attrs(options), ">",
3879 4108 text, "</a>"
3880 4109 ],
3881 4110 javascript(s,h) then
  4111 + with action_name = if action is {
  4112 + controller_action(_, an) then an,
  4113 + action_name(an) then an
  4114 + },
3882 4115 if action_name = "" then // special case where URL (so the action_name) is provided by the form itself
3883 4116 // so javascript isn't needed. This is the standard HMTL way.
3884 4117 ["<input type=\"submit\" value=\"",text,"\"", format_attrs(options), " />"]
... ... @@ -3900,7 +4133,7 @@ define Printable_tree
3900 4133 [
3901 4134 //if custom function name is provided, that name is used instead of autogenerated js function
3902 4135 if custom_function_name = "" then
3903   - if action is
  4136 + if formatted_action is
3904 4137 {
3905 4138 url(u) then ["<select href=\"",u]
3906 4139 javascript(s,h) then [s,"<select onchange=\"",h]
... ... @@ -3914,7 +4147,7 @@ define Printable_tree
3914 4147 html(html_off_form) then
3915 4148 [
3916 4149 "<a href=\"", url, "\">",
3917   - format(cinfo, state_name, ic_v, html_off_form, is_https, action_count, head_tags),
  4150 + format(cinfo, ic_v, html_off_form, is_https, action_count, head_tags),
3918 4151 "</a>"
3919 4152 ]
3920 4153 }.
... ... @@ -3933,19 +4166,17 @@ define Printable_tree
3933 4166  
3934 4167  
3935 4168 define Printable_tree
3936   - format_private_download
3937   - (
3938   - CommonInfo cinfo,
3939   - String sn, // state name
3940   - String abs_path, // absolute file path on server
3941   - String name, // name of file as it appears in the browser
3942   - String extra, // extra extension
3943   - Maybe((String,List((String,String)))) action
3944   -
3945   - ) =
3946   - if cinfo is info(common_name,http_port,https_port,site_directory,secret) then
3947   - with private_download_directory = site_directory+"/private_download",
3948   - with auth = make_authorization(site_directory,secret,abs_path),
  4169 + format_private_download
  4170 + (
  4171 + CommonInfo cinfo,
  4172 + String abs_path, // absolute file path on server
  4173 + String name, // name of file as it appears in the browser
  4174 + String extra, // extra extension
  4175 + Maybe((String,List((String,String)))) action
  4176 + ) =
  4177 + if cinfo is info(common_name,http_port,https_port,site_directory,secret) then
  4178 + with private_download_directory = site_directory+"/private_download",
  4179 + with auth = make_authorization(site_directory,secret,abs_path),
3949 4180 [
3950 4181 "<a href=\"",name,extra,"?zauth=",auth,
3951 4182 if action is
... ... @@ -3959,9 +4190,6 @@ define Printable_tree
3959 4190 "</a>"
3960 4191 ].
3961 4192  
3962   -
3963   -
3964   -
3965 4193 *** [5.6] Formating rows and cells in a table.
3966 4194  
3967 4195 define Int
... ... @@ -4237,7 +4465,6 @@ define String
4237 4465 define Printable_tree
4238 4466 format_scroller
4239 4467 (
4240   - String sn,
4241 4468 Int width,
4242 4469 Int height,
4243 4470 Int content_width,
... ... @@ -4411,7 +4638,6 @@ define Printable_tree
4411 4638 format
4412 4639 (
4413 4640 CommonInfo cinfo,
4414   - String sn, // state_name
4415 4641 Var(Int) ic_v,
4416 4642 HTML_Any($T) element,
4417 4643 $T -> Printable_tree format_element, // able to format a datum of type $T
... ... @@ -4449,9 +4675,9 @@ define Printable_tree
4449 4675 any_mail_to(email,elem) then
4450 4676 ["<a href=\"mailto:",email,"\">",format_element(elem),"</a>"],
4451 4677 any_scroller(w,h,cw,ch,c) then
4452   - format_scroller(sn,w,h,cw,ch,new_idnum(ic_v),c,format_element),
  4678 + format_scroller(w,h,cw,ch,new_idnum(ic_v),c,format_element),
4453 4679 any_fixed_size(w,h,c) then
4454   - with url = create_secondary_document(site_directory,secret,sn,format_element,c,w),
  4680 + with url = create_secondary_document(site_directory,secret,format_element,c,w),
4455 4681 ["<object data=\"",url,"\" type=\"text/html\" width=\"",format(w),"\" height=\"",format(h),"\" >",
4456 4682 "secondary document",
4457 4683 "</object>"],
... ... @@ -4462,17 +4688,17 @@ define Printable_tree
4462 4688 "secondary document",
4463 4689 "</object>"],
4464 4690 any_actioner(c,t,a,an,eo,ja,fn) then
4465   - format_actioner(cinfo,sn,c,t,a,an,eo,ja,fn,is_https, action_count, ic_v, head_tags),
  4691 + format_actioner(cinfo,c,t,a,an,eo,ja,fn,is_https, action_count, ic_v, head_tags),
4466 4692  
4467 4693 any_foreign_link_new(target, aspect, url) then
4468   - format_foreign_link(target, aspect, url, is_https, cinfo, sn, action_count, ic_v, head_tags),
  4694 + format_foreign_link(target, aspect, url, is_https, cinfo, action_count, ic_v, head_tags),
4469 4695  
4470 4696 any_foreign_link(options,url) then
4471 4697 ["<a href=\"",url,"\" ", format_text_options(options), "></a>"], // IE7 doesn't support the form <a href="..." />
4472 4698 any_foreign_link(options,url,name) then
4473 4699 ["<a href=\"",url,"\"><span ", format_text_options(options), ">",name,"</span></a>"],
4474 4700 any_private_download(url,name,extra_ext,action) then
4475   - format_private_download(cinfo,sn,url,name,extra_ext,action),
  4701 + format_private_download(cinfo,url,name,extra_ext,action),
4476 4702 any_div(options, e) then
4477 4703 [format_div_option(options), format_element(e),"</div>\n"],
4478 4704 any_div_empty(options) then
... ... @@ -4610,7 +4836,6 @@ define Printable_tree
4610 4836 (
4611 4837 CommonInfo cinfo,
4612 4838 String fn, // form_name
4613   - String sn, // state_name
4614 4839 Var(Int) ic_v, // idnum counter variable
4615 4840 HTML_In_Form element,
4616 4841 Bool is_https,
... ... @@ -4618,7 +4843,7 @@ define Printable_tree
4618 4843 Var(List(HTML_Head_Tag)) head_tags
4619 4844 ) =
4620 4845 if cinfo is info(common_name,http_port,https_port,site_directory,secret) then
4621   - with format_element = (HTML_In_Form e) |-> format(cinfo, fn, sn, ic_v, e, is_https, action_count, head_tags),
  4846 + with format_element = (HTML_In_Form e) |-> format(cinfo, fn, ic_v, e, is_https, action_count, head_tags),
4622 4847 if element is
4623 4848 {
4624 4849 empty then [],
... ... @@ -4626,35 +4851,35 @@ define Printable_tree
4626 4851 literal(t) then [t],
4627 4852 sequence(l) then flat(map(format_element,l))
4628 4853 text(opts,t) then
4629   - format(cinfo,sn,ic_v,any_text(opts,t),format_element,is_https, action_count, head_tags),
  4854 + format(cinfo,ic_v,any_text(opts,t),format_element,is_https, action_count, head_tags),
4630 4855 preformated(o,s) then
4631   - format(cinfo,sn,ic_v,any_preformated(o,s),format_element,is_https, action_count, head_tags),
  4856 + format(cinfo,ic_v,any_preformated(o,s),format_element,is_https, action_count, head_tags),
4632 4857 paragraph(opts,t) then
4633   - format(cinfo,sn,ic_v,any_paragraph(opts,t),format_element,is_https, action_count, head_tags),
  4858 + format(cinfo,ic_v,any_paragraph(opts,t),format_element,is_https, action_count, head_tags),
4634 4859 image(opts, url, alt) then
4635   - format(cinfo,sn,ic_v,any_image(opts, url, alt),format_element,is_https, action_count, head_tags),
  4860 + format(cinfo,ic_v,any_image(opts, url, alt),format_element,is_https, action_count, head_tags),
4636 4861 image(opts, url, alt, w, h) then
4637   - format(cinfo,sn,ic_v,any_image(opts, url, alt, w, h),format_element,is_https, action_count, head_tags),
  4862 + format(cinfo,ic_v,any_image(opts, url, alt, w, h),format_element,is_https, action_count, head_tags),
4638 4863 table(opts,header_row,rows,footer_row) then
4639   - format(cinfo,sn,ic_v,any_table(opts, header_row, rows, footer_row),format_element,is_https, action_count, head_tags),
  4864 + format(cinfo,ic_v,any_table(opts, header_row, rows, footer_row),format_element,is_https, action_count, head_tags),
4640 4865 center(e) then
4641   - format(cinfo,sn,ic_v,any_center(e),format_element,is_https, action_count, head_tags),
  4866 + format(cinfo,ic_v,any_center(e),format_element,is_https, action_count, head_tags),
4642 4867 mail_to(a,e) then
4643   - format(cinfo,sn,ic_v,any_mail_to(a,e),format_element,is_https, action_count, head_tags),
  4868 + format(cinfo,ic_v,any_mail_to(a,e),format_element,is_https, action_count, head_tags),
4644 4869 scroller(w,h,cw,ch,c) then
4645   - format(cinfo,sn,ic_v,any_scroller(w,h,cw,ch,c),format_element,is_https, action_count, head_tags),
  4870 + format(cinfo,ic_v,any_scroller(w,h,cw,ch,c),format_element,is_https, action_count, head_tags),
4646 4871 actioner(c,t,a,an,eo,ja) then
4647   - format(cinfo,sn,ic_v,any_actioner(c,t,a,an,eo,ja,success(fn)),format_element,is_https, action_count, head_tags),
  4872 + format(cinfo,ic_v,any_actioner(c,t,a,an,eo,ja,success(fn)),format_element,is_https, action_count, head_tags),
4648 4873  
4649 4874 foreign_link_new(target, aspect, url) then
4650   - format(cinfo,sn,ic_v,any_foreign_link_new(target,aspect,url),format_element,is_https, action_count, head_tags),
  4875 + format(cinfo,ic_v,any_foreign_link_new(target,aspect,url),format_element,is_https, action_count, head_tags),
4651 4876  
4652 4877 foreign_link(options,url) then
4653   - format(cinfo,sn,ic_v,any_foreign_link(options,url),format_element,is_https, action_count, head_tags),
  4878 + format(cinfo,ic_v,any_foreign_link(options,url),format_element,is_https, action_count, head_tags),
4654 4879 foreign_link(options,url,name) then
4655   - format(cinfo,sn,ic_v,any_foreign_link(options,url,name),format_element,is_https, action_count, head_tags),
  4880 + format(cinfo,ic_v,any_foreign_link(options,url,name),format_element,is_https, action_count, head_tags),
4656 4881 private_download(url,name,extra,action) then
4657   - format(cinfo,sn,ic_v,any_private_download(url,name,extra,action),format_element,is_https, action_count, head_tags),
  4882 + format(cinfo,ic_v,any_private_download(url,name,extra,action),format_element,is_https, action_count, head_tags),
4658 4883 text_input(options, label_text, id, name, i, w) then
4659 4884 [ format_label(label_text, id),
4660 4885 "<input type=\"text\" name=\"",name,"\" id=\"",id,"\" size=\"",w,"\" value=\"",i,"\"",format_attrs([class("in") . options])," />"],
... ... @@ -4695,9 +4920,9 @@ define Printable_tree
4695 4920 [ "<input type=\"checkbox\" name=\"",n,"\" id=\"",id,"\" value=\"",v,"\"",(if c then " checked=\"checked\" " else ""),format_attrs([class("in") . options])," />",
4696 4921 format_label(label, id)]
4697 4922 div(options, e) then
4698   - format(cinfo,sn,ic_v,any_div(options, e),format_element,is_https, action_count, head_tags),
  4923 + format(cinfo,ic_v,any_div(options, e),format_element,is_https, action_count, head_tags),
4699 4924 div_empty(options) then
4700   - format(cinfo,sn,ic_v,any_div_empty(options),format_element,is_https, action_count, head_tags),
  4925 + format(cinfo,ic_v,any_div_empty(options),format_element,is_https, action_count, head_tags),
4701 4926 hidden(_id, name, value) then
4702 4927 since _id is html_Id(id),
4703 4928 ["<input type=\"hidden\"",(if id = "" then "" else " id=\""+id+"\"")," name=\"",name,"\" value=\"",value,"\" />"],
... ... @@ -4705,17 +4930,17 @@ define Printable_tree
4705 4930 if p_content is partial_content(tags, html_elements) then
4706 4931 head_tags <- *head_tags + tags;
4707 4932  
4708   - format(cinfo, sn, ic_v, html_elements, is_https, action_count, head_tags),
  4933 + format(cinfo, ic_v, html_elements, is_https, action_count, head_tags),
4709 4934 br then ["<br>"],
4710 4935 progress(options, value, max) then ["<progress max=\"",value,"\" value=\"",max,"\"",format_attrs(options),"></progress>"],
4711 4936 ol(opts, t) then
4712   - format(cinfo,sn,ic_v,any_ol(opts,t),format_element,is_https, action_count, head_tags),
  4937 + format(cinfo,ic_v,any_ol(opts,t),format_element,is_https, action_count, head_tags),
4713 4938 ul(opts, t) then
4714   - format(cinfo,sn,ic_v,any_ul(opts,t),format_element,is_https, action_count, head_tags),
  4939 + format(cinfo,ic_v,any_ul(opts,t),format_element,is_https, action_count, head_tags),
4715 4940 li(opts, t) then
4716   - format(cinfo,sn,ic_v,any_li(opts,t),format_element,is_https, action_count, head_tags),
  4941 + format(cinfo,ic_v,any_li(opts,t),format_element,is_https, action_count, head_tags),
4717 4942 button(options, e) then
4718   - format(cinfo,sn,ic_v,any_button(options, e),format_element,is_https, action_count, head_tags),
  4943 + format(cinfo,ic_v,any_button(options, e),format_element,is_https, action_count, head_tags),
4719 4944 }.
4720 4945  
4721 4946  
... ... @@ -4821,7 +5046,6 @@ define Printable_tree
4821 5046 format
4822 5047 (
4823 5048 CommonInfo cinfo,
4824   - String sn, // state_name
4825 5049 Var(Int) ic_v, // 'idnum' counter variable
4826 5050 HTML_Off_Form element,
4827 5051 Bool is_https,
... ... @@ -4829,7 +5053,7 @@ define Printable_tree
4829 5053 Var(List(HTML_Head_Tag)) head_tags
4830 5054 ) =
4831 5055 if cinfo is info(common_name,http_port,https_port,site_directory,secret) then
4832   - with format_element = (HTML_Off_Form e) |-> format(cinfo, sn, ic_v, e, is_https, action_count, head_tags),
  5056 + with format_element = (HTML_Off_Form e) |-> format(cinfo, ic_v, e, is_https, action_count, head_tags),
4833 5057 if element is
4834 5058 {
4835 5059 empty then [],
... ... @@ -4837,44 +5061,44 @@ define Printable_tree
4837 5061 literal(t) then [t],
4838 5062 sequence(l) then flat(map(format_element,l)),
4839 5063 text(opts,t) then
4840   - format(cinfo,sn,ic_v,any_text(opts,t),format_element,is_https, action_count, head_tags),
  5064 + format(cinfo,ic_v,any_text(opts,t),format_element,is_https, action_count, head_tags),
4841 5065 preformated(o,s) then
4842   - format(cinfo,sn,ic_v,any_preformated(o,s),format_element,is_https, action_count, head_tags),
  5066 + format(cinfo,ic_v,any_preformated(o,s),format_element,is_https, action_count, head_tags),
4843 5067 paragraph(opts,t) then
4844   - format(cinfo,sn,ic_v,any_paragraph(opts,t),format_element,is_https, action_count, head_tags),
  5068 + format(cinfo,ic_v,any_paragraph(opts,t),format_element,is_https, action_count, head_tags),
4845 5069 image(opts,url,alt) then
4846   - format(cinfo,sn,ic_v,any_image(opts,url,alt),format_element,is_https, action_count, head_tags),
  5070 + format(cinfo,ic_v,any_image(opts,url,alt),format_element,is_https, action_count, head_tags),
4847 5071 image(opts,url,alt,w,h) then
4848   - format(cinfo,sn,ic_v,any_image(opts,url,alt,w,h),format_element,is_https, action_count, head_tags),
  5072 + format(cinfo,ic_v,any_image(opts,url,alt,w,h),format_element,is_https, action_count, head_tags),
4849 5073 table(opts,header_row, rows, footer_row) then
4850   - format(cinfo,sn,ic_v,any_table(opts,header_row, rows, footer_row),format_element,is_https, action_count, head_tags),
  5074 + format(cinfo,ic_v,any_table(opts,header_row, rows, footer_row),format_element,is_https, action_count, head_tags),
4851 5075 center(e) then
4852   - format(cinfo,sn,ic_v,any_center(e),format_element,is_https, action_count, head_tags),
  5076 + format(cinfo,ic_v,any_center(e),format_element,is_https, action_count, head_tags),
4853 5077 mail_to(a,e) then
4854   - format(cinfo,sn,ic_v,any_mail_to(a,e),format_element,is_https, action_count, head_tags),
  5078 + format(cinfo,ic_v,any_mail_to(a,e),format_element,is_https, action_count, head_tags),
4855 5079 scroller(w,h,cw,ch,c) then
4856   - format(cinfo,sn,ic_v,any_scroller(w,h,cw,ch,c),format_element,is_https, action_count, head_tags),
  5080 + format(cinfo,ic_v,any_scroller(w,h,cw,ch,c),format_element,is_https, action_count, head_tags),
4857 5081 fixed_size(w,h,c) then
4858   - format(cinfo,sn,ic_v,any_fixed_size(w,h,c),format_element,is_https, action_count, head_tags),
  5082 + format(cinfo,ic_v,any_fixed_size(w,h,c),format_element,is_https, action_count, head_tags),
4859 5083 fixed_size_2(w,h,fn) then
4860   - format(cinfo,sn,ic_v,any_fixed_size_2(w,h,fn),format_element,is_https, action_count, head_tags),
  5084 + format(cinfo,ic_v,any_fixed_size_2(w,h,fn),format_element,is_https, action_count, head_tags),
4861 5085 actioner(c,t,a,an,eo,ja) then
4862   - format(cinfo,sn,ic_v,any_actioner(c,t,a,an,eo,ja,failure),format_element,is_https, action_count, head_tags),
  5086 + format(cinfo,ic_v,any_actioner(c,t,a,an,eo,ja,failure),format_element,is_https, action_count, head_tags),
4863 5087 actioner(c,t,a,an,eo,ja,fn) then
4864   - format(cinfo,sn,ic_v,any_actioner(c,t,a,an,eo,ja,success(fn)),format_element,is_https, action_count, head_tags),
  5088 + format(cinfo,ic_v,any_actioner(c,t,a,an,eo,ja,success(fn)),format_element,is_https, action_count, head_tags),
4865 5089 foreign_link_new(target, aspect, url) then
4866   - format(cinfo,sn,ic_v,any_foreign_link_new(target,aspect,url),format_element,is_https, action_count, head_tags),
  5090 + format(cinfo,ic_v,any_foreign_link_new(target,aspect,url),format_element,is_https, action_count, head_tags),
4867 5091 foreign_link(options,url) then
4868   - format(cinfo,sn,ic_v,any_foreign_link(options,url),format_element,is_https, action_count, head_tags),
  5092 + format(cinfo,ic_v,any_foreign_link(options,url),format_element,is_https, action_count, head_tags),
4869 5093 foreign_link(options,url,name) then
4870   - format(cinfo,sn,ic_v,any_foreign_link(options,url,name),format_element,is_https, action_count, head_tags),
  5094 + format(cinfo,ic_v,any_foreign_link(options,url,name),format_element,is_https, action_count, head_tags),
4871 5095 private_download(url,name,extra,action) then
4872   - format(cinfo,sn,ic_v,any_private_download(url,name,extra,action),format_element,is_https, action_count, head_tags),
  5096 + format(cinfo,ic_v,any_private_download(url,name,extra,action),format_element,is_https, action_count, head_tags),
4873 5097 label(n) then ["<a name=\"",n,"\">"],
4874 5098 form(fn,attributs, c) then
4875 5099 [
4876 5100 "<form id=\"",fn,"\"",
4877   - format(cinfo,sn,ic_v,any_coreattrs(attributs),format_element,is_https, action_count, head_tags),
  5101 + format(cinfo,ic_v,any_coreattrs(attributs),format_element,is_https, action_count, head_tags),
4878 5102 " method=\"post\"",
4879 5103 enctype(c),
4880 5104 " action=\"http",
... ... @@ -4883,15 +5107,15 @@ define Printable_tree
4883 5107 // action is set dynamically by
4884 5108 // the actioner using JavaScript
4885 5109 if fn is html_Id(id) then
4886   - format(cinfo,id,sn,ic_v,c,is_https, action_count, head_tags),
  5110 + format(cinfo,id,ic_v,c,is_https, action_count, head_tags),
4887 5111 "</form>"
4888 5112 ]
4889   - form(fn,attributs, action_name, extra_ops, c) then
  5113 + form(fn,attributs, action, extra_ops, c) then
4890 5114 with url = make_actioner_url(cinfo, same, same,
4891   - sn, action_name, extra_ops, is_https),
  5115 + action, extra_ops, is_https),
4892 5116 [
4893 5117 "<form id=\"",fn,"\"",
4894   - format(cinfo,sn,ic_v,any_coreattrs(attributs),format_element,is_https, action_count, head_tags),
  5118 + format(cinfo,ic_v,any_coreattrs(attributs),format_element,is_https, action_count, head_tags),
4895 5119 " method=\"post\"",
4896 5120 enctype(c),
4897 5121 " action=\"" + url + "\">",
... ... @@ -4901,20 +5125,20 @@ define Printable_tree
4901 5125 // action is set dynamically by
4902 5126 // the actioner using JavaScript
4903 5127 if fn is html_Id(id) then
4904   - format(cinfo,id,sn,ic_v,c,is_https, action_count, head_tags),
  5128 + format(cinfo,id,ic_v,c,is_https, action_count, head_tags),
4905 5129 "</form>"
4906 5130 ],
4907 5131 in_form(fn, content) then
4908 5132 if fn is html_Id(id) then
4909   - format(cinfo,id,sn,ic_v, content,is_https, action_count, head_tags),
  5133 + format(cinfo,id,ic_v, content,is_https, action_count, head_tags),
4910 5134 div(options, e) then
4911   - format(cinfo, sn, ic_v, any_div(options, e), format_element, is_https, action_count, head_tags),
  5135 + format(cinfo, ic_v, any_div(options, e), format_element, is_https, action_count, head_tags),
4912 5136 div(options, p_content) then
4913 5137 if p_content is partial_content(tags, html_elements) then
4914 5138 head_tags <- *head_tags +tags;
4915   - format(cinfo, sn, ic_v, any_div(options, html_elements), format_element, is_https, action_count, head_tags),
  5139 + format(cinfo, ic_v, any_div(options, html_elements), format_element, is_https, action_count, head_tags),
4916 5140 div_empty(options) then
4917   - format(cinfo, sn, ic_v, any_div_empty(options), format_element, is_https, action_count, head_tags),
  5141 + format(cinfo, ic_v, any_div_empty(options), format_element, is_https, action_count, head_tags),
4918 5142 iframe(options, css_styles, css_files, js_files, body) then
4919 5143 if body is body(body_options,elem) then
4920 5144 [ "<iframe", format_attrs(options), ">\n",
... ... @@ -4925,7 +5149,7 @@ define Printable_tree
4925 5149 add_js_files(js_files),
4926 5150 "</head>\n",
4927 5151 "<body ", format(body_options), ">\n", // format body options
4928   - format(cinfo,sn,ic_v,elem,is_https, action_count, head_tags),
  5152 + format(cinfo,ic_v,elem,is_https, action_count, head_tags),
4929 5153 "</body>\n",
4930 5154 "</html>\n",
4931 5155 "</iframe>\n",
... ... @@ -4933,17 +5157,17 @@ define Printable_tree
4933 5157 partial(p_content) then
4934 5158 if p_content is partial_content(tags, html_elements) then
4935 5159 head_tags <- *head_tags + tags;
4936   - format(cinfo, sn, ic_v, html_elements, is_https, action_count, head_tags),
  5160 + format(cinfo, ic_v, html_elements, is_https, action_count, head_tags),
4937 5161 br then ["<br>"],
4938 5162 progress(options, value, max) then ["<progress max=\"",value,"\" value=\"",max,"\"",format_attrs(options),"></progress>"],
4939 5163 ol(opts, t) then
4940   - format(cinfo,sn,ic_v,any_ol(opts,t),format_element,is_https, action_count, head_tags),
  5164 + format(cinfo,ic_v,any_ol(opts,t),format_element,is_https, action_count, head_tags),
4941 5165 ul(opts, t) then
4942   - format(cinfo,sn,ic_v,any_ul(opts,t),format_element,is_https, action_count, head_tags),
  5166 + format(cinfo,ic_v,any_ul(opts,t),format_element,is_https, action_count, head_tags),
4943 5167 li(opts, t) then
4944   - format(cinfo,sn,ic_v,any_li(opts,t),format_element,is_https, action_count, head_tags),
  5168 + format(cinfo,ic_v,any_li(opts,t),format_element,is_https, action_count, head_tags),
4945 5169 button(options, e) then
4946   - format(cinfo, sn, ic_v, any_button(options, e), format_element, is_https, action_count, head_tags),
  5170 + format(cinfo, ic_v, any_button(options, e), format_element, is_https, action_count, head_tags),
4947 5171 }.
4948 5172  
4949 5173  
... ... @@ -4966,29 +5190,29 @@ define Printable_tree
4966 5190  
4967 5191  
4968 5192 define Printable_tree
4969   - format
4970   - (
4971   - CommonInfo cinfo,
4972   - String state_name,
4973   - HTML_Meta m,
4974   - Bool is_https
4975   - ) =
4976   - if m is
4977   - {
4978   - keywords(l) then ["<meta name=\"keywords\" content=\"",format_keywords(l),"\" />\n"],
4979   - refresh(co,ta,an,delay) then
  5193 + format
  5194 + (
  5195 + CommonInfo cinfo,
  5196 + HTML_Meta m,
  5197 + Bool is_https
  5198 + ) =
  5199 + if m is
  5200 + {
  5201 + keywords(l) then ["<meta name=\"keywords\" content=\"",format_keywords(l),"\" />\n"],
  5202 + refresh(co,ta,an,delay) then
4980 5203 ["<meta http-equiv=\"Refresh\" content=\"",delay,"; URL=",
4981   - make_actioner_url(cinfo,co,ta,state_name,an,[],is_https),"\" />\n"],
4982   - refresh(url,delay) then
  5204 + make_actioner_url(cinfo,co,ta,an,[],is_https),"\" />\n"],
  5205 + refresh(url,delay) then
4983 5206 ["<meta http-equiv=\"Refresh\" content=\"",delay,"; URL=",url,"\" />\n"],
4984   - meta(n,c) then ["<meta name=\"",n,"\" content=\"",c,"\" />\n"],
4985   - http_equiv(n,c) then ["<meta http-equiv=\"",n,"\" content=\"",c,"\" />\n"],
4986   - generic_meta(l) then ["<meta ",
  5207 + meta(n,c) then ["<meta name=\"",n,"\" content=\"",c,"\" />\n"],
  5208 + http_equiv(n,c) then ["<meta http-equiv=\"",n,"\" content=\"",c,"\" />\n"],
  5209 + generic_meta(l) then ["<meta ",
4987 5210 flat(map(((String,String) p) |-> if p is (n,v) then [n,"=\"",v,"\" "],
4988 5211 l)),
4989 5212 " />\n"],
4990   - literal(s) then [s]
4991   - }.
  5213 + literal(s) then [s]
  5214 + }
  5215 +.
4992 5216  
4993 5217 define Printable_tree // c'est le nôtre et c'est meilleur
4994 5218 format
... ... @@ -5015,18 +5239,17 @@ define Printable_tree // c&#39;est le nôtre et c&#39;est meilleur
5015 5239 define Printable_tree
5016 5240 format
5017 5241 (
5018   - CommonInfo cinfo,
5019   - String state_name,
  5242 + CommonInfo cinfo,
5020 5243 List(HTML_Meta) metas,
5021 5244 Bool is_https,
5022 5245 String charset
5023 5246 ) =
5024 5247 if metas is
5025 5248 {
5026   - [] then [format(cinfo,state_name,http_equiv("content-type",
  5249 + [] then [format(cinfo,http_equiv("content-type",
5027 5250 "text/html; charset="+charset),is_https)],
5028   - [h . t] then [format(cinfo,state_name,h,is_https)
5029   - . format(cinfo,state_name,t,is_https,charset)]
  5251 + [h . t] then [format(cinfo,h,is_https)
  5252 + . format(cinfo,t,is_https,charset)]
5030 5253 }.
5031 5254  
5032 5255 define List(HTML_Head_Tag)
... ... @@ -5135,33 +5358,26 @@ public define HTML_ajax_content
5135 5358 to_html_ajax_content
5136 5359 (
5137 5360 HTML_Off_Form content_HTML,
5138   - CommonInfo cinfo,
5139   - String state_name
  5361 + CommonInfo cinfo
5140 5362 )=
5141 5363 with p_content_head_tags = var((List(HTML_Head_Tag))[]),
5142   - with content = format(cinfo, state_name, var((Int)0), content_HTML, false, var(0), p_content_head_tags),
  5364 + with content = format(cinfo, var((Int)0), content_HTML, false, var(0), p_content_head_tags),
5143 5365 if sort_head_tag(*p_content_head_tags, "", [], []) is html_ajax_content(_, script, js_file, css_file) then
5144 5366 html_ajax_content(to_String(content), script, js_file, css_file).
5145 5367  
5146   -public define HTML_ajax_content
5147   - to_html_ajax_content
5148   - (
5149   - HTML_Off_Form content_HTML,
5150   - CommonInfo cinfo
5151   - )= to_html_ajax_content(content_HTML, cinfo, "").
5152 5368  
5153 5369 public define HTML_ajax_content
5154 5370 to_html_ajax_content
5155 5371 (
5156 5372 HTML_Partial_Content content_HTML,
5157 5373 CommonInfo cinfo
5158   - )= to_html_ajax_content(partial(content_HTML), cinfo, "").
  5374 + )= to_html_ajax_content(partial(content_HTML), cinfo).
5159 5375  
5160 5376 public define Printable_tree
5161 5377 format
5162 5378 (
5163 5379 CommonInfo cinfo,
5164   - String state_name,
  5380 + //String state_name,
5165 5381 List(HTTP_header) additional_headers,
5166 5382 HTTP_Answer page,
5167 5383 Bool is_https,
... ... @@ -5178,7 +5394,7 @@ public define Printable_tree
5178 5394 with
5179 5395 answer_body_body = (Printable_tree)
5180 5396 [ "<body ", format(options), ">", // format body options
5181   - format(cinfo,state_name,ic_v,element,is_https, var(0), p_content_head_tags),
  5397 + format(cinfo,ic_v,element,is_https, var(0), p_content_head_tags),
5182 5398 "</body>\n",
5183 5399  
5184 5400 "</html>"],
... ... @@ -5201,7 +5417,14 @@ public define Printable_tree
5201 5417 html_page(status, title, metas, css_styles, css_files, js_files, script, body) then
5202 5418 if body is body(options,element) then
5203 5419 if format(status) is (status_string, status_headers) then
5204   - with answer_body =
  5420 + with
  5421 + answer_body_body = (Printable_tree)
  5422 + [ "<body ", format(options), ">", // format body options
  5423 + format(cinfo,ic_v,element,is_https, var(0), p_content_head_tags),
  5424 + "</body>\n",
  5425 + "</html>"
  5426 + ],
  5427 + answer_body_header =
5205 5428 [ doctype_w3c_header,
5206 5429 //html_header,
5207 5430 "<head>\n",
... ... @@ -5222,22 +5445,19 @@ public define Printable_tree
5222 5445 " { s[0]=0; d.style.visibility = 'hidden'; }; }",
5223 5446 "</script>\n",
5224 5447 "<title>",title,"</title>\n", // put title
5225   - format(cinfo,state_name,metas,is_https,charset), // format the metas
5226   - "</head>\n",
5227   - "<body ", format(options), ">", // format body options
5228   - //"<center>",
5229   - format(cinfo,state_name,ic_v,element,is_https, var(0), p_content_head_tags),
5230   - //"</center>",
5231   - "</body>\n",
5232   - "</html>"
5233   - ],
  5448 + format(cinfo,metas,is_https,charset), // format the metas
  5449 + format_html_head(*p_content_head_tags, charset),
  5450 + "</head>\n"
  5451 + ],
  5452 +
5234 5453 [ "HTTP/1.1 " + status_string, crlf,
5235 5454 format_headers(standard_headers),
5236   - format_headers(standard_headers_for("text/html", length(answer_body), success(charset))),
  5455 + format_headers(standard_headers_for("text/html", length(answer_body_header) + length(answer_body_body), success(charset))),
5237 5456 format_headers(status_headers),
5238 5457 format_headers(additional_headers),
5239   - crlf
5240   - . answer_body
  5458 + crlf,
  5459 + answer_body_header .
  5460 + answer_body_body
5241 5461 ],
5242 5462  
5243 5463 plain_text (HTTP_Status status, String text) then
... ... @@ -5300,7 +5520,7 @@ public define Printable_tree
5300 5520  
5301 5521 html_content(HTTP_Status status, HTML_Off_Form content_HTML) then
5302 5522 if format(status) is (status_string, status_headers) then
5303   - with content = format(cinfo, state_name, ic_v, content_HTML, is_https, var(0), p_content_head_tags),
  5523 + with content = format(cinfo, ic_v, content_HTML, is_https, var(0), p_content_head_tags),
5304 5524 [ "HTTP/1.1 " + status_string, crlf,
5305 5525 format_headers(standard_headers),
5306 5526 format_headers(standard_headers_for("text/html", length(content), success(charset))),
... ... @@ -5317,7 +5537,7 @@ public define Printable_tree
5317 5537 with
5318 5538 answer_body = (Printable_tree)
5319 5539 [
5320   - format(cinfo, state_name, ic_v, html_content, is_https, var(0), p_content_head_tags),
  5540 + format(cinfo, ic_v, html_content, is_https, var(0), p_content_head_tags),
5321 5541 ],
5322 5542 answer_header = (Printable_tree)
5323 5543 [
... ...
web/CXM_multihost_http_server.anubis
... ... @@ -4136,6 +4136,63 @@ global define One
4136 4136  
4137 4137  
4138 4138  
  4139 +
  4140 +
  4141 +public define String
  4142 + to_String
  4143 + (
  4144 + HTTP_Status status
  4145 + )=
  4146 + if status is
  4147 + {
  4148 + http_continue then "100 Continue",
  4149 + http_switching_protocol then "101 Switching Protocols",
  4150 +
  4151 + http_ok then "200 OK",
  4152 + http_created then "201 Created",
  4153 + http_accepted then "202 Accepted",
  4154 + http_non_authoritative_info then "203 Non-Authoritative Information",
  4155 + http_no_content then "204 No Content",
  4156 + http_reset_content then "205 Reset Content",
  4157 + http_partial_content then "206 Partial Content",
  4158 +
  4159 + http_multiple_choices then "300 Multiple Choices",
  4160 + http_moved_permanently(loc) then "301 Moved Permanently Location ="+loc,
  4161 + http_moved_temporarily(loc) then "302 Moved Temporarily Location ="+loc,
  4162 + http_see_other(loc) then "303 See Other Location ="+loc,
  4163 + http_not_modified then "304 Not Modified",
  4164 + http_use_proxy(loc) then "305 Use Proxy Location ="+loc,
  4165 + http_temporary_redirect(loc) then "307 Temporary Redirect Location ="+loc,
  4166 +
  4167 + http_bad_request then "400 Bad Request",
  4168 + http_unauthorized then "401 Unauthorized",
  4169 + http_payment_required then "402 Payment Required",
  4170 + http_forbidden then "403 Forbidden",
  4171 + http_not_found then "404 Not Found",
  4172 + http_method_not_allowed then "405 Method Not Allowed",
  4173 + http_not_acceptable then "406 Not Acceptable",
  4174 + http_proxy_authentification_required then "407 Proxy Authentication Required",
  4175 + http_request_timeout then "408 Request Time-out",
  4176 + http_conflict then "409 Conflict",
  4177 + http_gone then "410 Gone",
  4178 + http_length_required then "411 Length Required",
  4179 + http_precondition_failed then "412 Precondition Failed",
  4180 + http_request_entity_too_large then "413 Request Entity Too Large",
  4181 + http_request_uri_too_long then "414 Request-URI Too Long",
  4182 + http_unsupported_media_type then "415 Unsupported Media Type",
  4183 + http_request_range_unsatisfiable then "416 Requested range unsatisfiable",
  4184 + http_expectation_failed then "417 Expectation failed",
  4185 +
  4186 + http_internal_server_error then "500 Internal Server Error",
  4187 + http_not_implemented then "501 Not Implemented",
  4188 + http_bad_gateway then "502 Bad Gateway",
  4189 + http_service_unavailable then "503 Service Unavailable",
  4190 + http_gateway_timeout then "504 Gateway Time-out",
  4191 + http_version_not_supported then "505 HTTP Version not supported"
  4192 +
  4193 + http_error(code, message) then abs_to_decimal(code) + " " + message
  4194 + }.
  4195 +
4139 4196 public define (String, List(HTTP_header))
4140 4197 format
4141 4198 (
... ...
web/widgets/button.anubis
... ... @@ -52,7 +52,7 @@ public define HTML_Partial_Content
52 52 String url,
53 53 List((String, String)) extra_ops
54 54 )=
55   - partial_content(actioner(same, same, img_link(core_attrs+[style("cursor: pointer")], img_path, ""), url, extra_ops)).
  55 + partial_content(actioner(same, same, img_link(core_attrs+[style("cursor: pointer")], img_path, ""), action_name(url), extra_ops)).
56 56  
57 57 public define HTML_Partial_Content
58 58 img_button
... ...