Commit 73d636355ece30b6eb54affdfe13d728e4b6e7e2

Authored by totoro
2 parents 2219a534 f3d0438f

Merge branch 'release/ANUBIS_1_14' of ssh://gitlab.calexium.com:33022/calexium/c…

…alexium_lib into release/ANUBIS_1_14
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 +
... ...
densaku_types.anubis 0 → 100644
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ aka (David RENÉ)
  4 + * Date: 07/02/2017
  5 + * Time: 23:01
  6 + * © Calexium
  7 + */
  8 +
  9 +
  10 +read tools/basis.anubis
  11 +read densaku_lib/ds_generator.anubis
  12 +read calexium_lib/ds_files/ds_types.anubis
  13 +read calexium_lib/ds_files/ds_messages.anubis
  14 +
  15 +
  16 +global define One
  17 + calexium_lib_ds
  18 + (
  19 + List(String) args
  20 + ) =
  21 + if load_ds_generator is
  22 + {
  23 + failure then println("Densaku generator can't be load"),
  24 + success(ds_gen) then forget(ds_gen.generate_type_files(calexium_lib_types_description, calexium_lib_messages_list, "ds_files/"))
  25 + }.
  26 +
  27 +execute anbexec calexium_lib_ds // generate the file
... ...
ds_files/ds_messages.anubis 0 → 100644
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ aka (David RENÉ)
  4 + * Date: 07/02/2017
  5 + * Time: 23:05
  6 + * © Calexium
  7 + */
  8 +
  9 +
  10 +read densaku_lib/types/densaku.anubis
  11 +
  12 +public define List(DS_Message) calexium_lib_messages_list =
  13 + [
  14 +
  15 + ].
... ...
ds_files/ds_types.anubis 0 → 100644
  1 +/*
  2 + * Created by PyramIDE.
  3 + * User: フランスのトトロ aka (David RENÉ)
  4 + * Date: 07/02/2017
  5 + * Time: 23:05
  6 + * © Calexium
  7 + */
  8 +
  9 +read densaku_lib/types/densaku.anubis
  10 +
  11 +public define List(DS_Type) calexium_lib_types_description =
  12 + [
  13 +// public type DB_id:
  14 +// none,
  15 +// db_id(Int value).
  16 + ds_type("DB_id", [
  17 + enum("none", comment("no database Primary Key ID")),
  18 + alternative("db_id", [
  19 + component( int, "value", comment("Integer value of the Primary Key ID"))
  20 + ])
  21 + ]),
  22 +
  23 +// public type DB_datetime:
  24 +// db_datetime(String datetime). //Date and time in ISO8601 format "YYYY-MM-DD hh:mm:ss"
  25 + ds_type("DB_datetime", [
  26 + alternative("db_datetime", [
  27 + component(string, "datetime", comment("Date and time in ISO8601 format \"YYYY-MM-DD hh:mm:ss\""))
  28 + ])
  29 + ]),
  30 +
  31 +// public type DB_date:
  32 +// db_date(String date). //Date in ISO8601 format "YYYY-MM-DD"
  33 + ds_type("DB_date", [
  34 + alternative("db_date", [
  35 + component(string, "date", comment("Date and time in ISO8601 format \"YYYY-MM-DD\""))
  36 + ])
  37 + ]),
  38 +
  39 +// public type DB_time:
  40 +// db_time(String time). //Time in ISO8601 format "hh:mm:ss"
  41 + ds_type("DB_time", [
  42 + alternative("db_time", [
  43 + component(string, "time", comment("Date and time in ISO8601 format \"hh:mm:ss\""))
  44 + ])
  45 + ]),
  46 +
  47 +// public type DB_integer:
  48 +// db_integer(Int value).
  49 +// calexium_lib/database/db_types.anubis
  50 + ds_type("DB_integer", [
  51 + alternative("db_integer", [
  52 + component(int, "value", comment("Integer from datatase"))
  53 + ])
  54 + ]),
  55 +
  56 +// public type MIME:
  57 +// mime(String type,
  58 +// String sybtype,
  59 +// List(String) file_extensions).
  60 +// library/web/mime.anubis
  61 + ds_type("MIME", [
  62 + alternative("mime", [
  63 + component(string, "type"),
  64 + component(string, "subtype"),
  65 + component(list, string, "file_extensions")
  66 + ])
  67 + ]),
  68 +
  69 + ]
  70 +.
... ...
examples.ide 0 → 100644
  1 +
  2 +Microsoft Visual Studio Solution File, Format Version 9.00
  3 +# Visual Studio 2005
  4 +# SharpDevelop 1.0.12.108
  5 +Project("{B6712916-30DE-4a3e-A54C-2A79AC984AEE}") = "minimal_web_site", "minimal_web_site.aproj", "{F2C65267-0D20-4964-A5D8-602BD42C01A4}"
  6 +EndProject
  7 +Global
  8 + GlobalSection(SolutionConfigurationPlatforms) = preSolution
  9 + Debug|Any CPU = Debug|Any CPU
  10 + Release|Any CPU = Release|Any CPU
  11 + EndGlobalSection
  12 + GlobalSection(ProjectConfigurationPlatforms) = postSolution
  13 + {F2C65267-0D20-4964-A5D8-602BD42C01A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
  14 + {F2C65267-0D20-4964-A5D8-602BD42C01A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
  15 + {F2C65267-0D20-4964-A5D8-602BD42C01A4}.Release|Any CPU.Build.0 = Release|Any CPU
  16 + {F2C65267-0D20-4964-A5D8-602BD42C01A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
  17 + EndGlobalSection
  18 +EndGlobal
... ...
examples/minimal_web_site.anubis 0 → 100644
  1 +
  2 +
  3 + *Project* The Anubis Project
  4 +
  5 + *Title* A minimal web site.
  6 +
  7 + *Copyright* Copyright © Calexium www.calexium.com.
  8 +
  9 + *Released*
  10 +
  11 + *Author* David RENÉ
  12 +
  13 + *Overview*
  14 +
  15 + This file is just an example which may help to start making a web site with
  16 + Anubis Calexium Library
  17 + It was based on the example for making a minimal web site made by Alain Prouté and located
  18 + in examples/network folder in standard library example
  19 +
  20 + This example is absolutely minimalist and manage only page.
  21 +
  22 +
  23 +read tools/basis.anubis // required for 'make_directory' and .
  24 +read system/convert.anubis
  25 +read web/CXM_common.anubis // required for type 'Web_arg'
  26 +read web/CXM_multihost_http_server.anubis // required for type 'HTTP_Info'
  27 +read web/CXM_making_a_web_site.anubis
  28 +read web/mime.anubis // required for list of known MIME types
  29 +
  30 +
  31 +
  32 +
  33 + *** Server directory.
  34 +
  35 + A directory for putting files for all web sites. There will be one subdirectory per web
  36 + site.
  37 +
  38 +define String web_sites_directory = my_anubis_directory+"/web_sites".
  39 +
  40 +
  41 + *** Example site 1.
  42 +
  43 + Computing the pages of site 1. There is just one page. The type '$State' (see
  44 + 'web/CXM_making_a_web_site.anubis') has been chosen as 'One'. If this type were more
  45 + elaborate, the function 'compute_page_1' could compute several different pages (for
  46 + example, one per alternative of this type). Anyway, there is only one such function for
  47 + each web site.
  48 +
  49 +define HTTP_Answer
  50 + compute_page_1
  51 + (
  52 + One state
  53 + )=
  54 + html_page
  55 + (
  56 + "Example Site 1", // title of web site
  57 + [], // list of 'META' tags (empty for this site)
  58 + body // body of page
  59 + (
  60 + // list of body options
  61 + [
  62 + background_color(rgb(255,200,200))
  63 + // add more body options here
  64 + ],
  65 +
  66 + // content of page
  67 + center(text([size(14)],"This is the 'Example 1' web site."))
  68 + )
  69 + )
  70 +.
  71 +
  72 +
  73 +
  74 + Making the description of web site 1. In this description, several elements are the
  75 + bare minimum. There is no action at all, no data base, almost nothing. See
  76 + 'web/making_a_web_site.anubis' for the declaration of the function
  77 + 'make_web_site_description'.
  78 +
  79 +define Web_Site
  80 + example_site_1
  81 + =
  82 + // make the directory for web site 1
  83 + // (subdirectories of it will be created automatically by the HTTP server)
  84 + forget((String)make_directory(web_sites_directory+"/example_site_1"));
  85 +
  86 + // make a list of all possible 'host names' for web site 1:
  87 + with addresses = (List(String))
  88 + [
  89 + "example-site-1",
  90 + "127.0.0.1",
  91 + "192.168.0.1"
  92 + // add more adresses here
  93 + ],
  94 +
  95 + // now make the description of the web site
  96 + make_web_site_description(
  97 +
  98 + //this is the unique ID of the web site. This ID will be use for prepend the cookies
  99 + //names belonging to that web site
  100 + "example",
  101 +
  102 + // the list of addresses defined above
  103 + addresses,
  104 +
  105 + // directory for the files of web site 1
  106 + web_sites_directory+"/example_site_1",
  107 +
  108 + // directory for the states of that web_site
  109 + web_sites_directory+"/example_site_1/states",
  110 +
  111 + // initializing function
  112 + (One u) |-> u, // nothing to initialize for web site 1
  113 +
  114 + // the function producing the initial state
  115 + (HTTP_Info info,
  116 + List(Web_arg) lwa,
  117 + Bool is_https) |-> unique, // there is ony one possible state for web site 1
  118 +
  119 + // the function for handling expired tickets
  120 + // (tickets are kept on the server's disk and represent states. They are used for
  121 + // passing session informations from pages to pages. See
  122 + // 'web/CXM_making_a_web_site.anubis' for detailed explanations.)
  123 + (One expired,
  124 + Maybe(String) mb_action_name,
  125 + HTTP_Info info,
  126 + List(Web_arg) lwa,
  127 + Bool is_https) |-> unique, // keep the same state
  128 +
  129 + // the function for handling lost tickets
  130 + (Maybe(String) mb_action_name,
  131 + HTTP_Info info,
  132 + List(Web_arg) lwa,
  133 + Bool is_https) |-> unique, // restart with default state
  134 +
  135 + // list of all actions
  136 + [ ], // no action for web site 1
  137 +
  138 + // the function for computing the pages of web site 1 (it is defined above)
  139 + compute_page_1,
  140 +
  141 + // the function for producing additional HTTP headers
  142 + (One u) |-> [],
  143 +
  144 + // timeout for tickets (in seconds)
  145 + 3600, // does'nt matter since only one state
  146 +
  147 + // list of redirections (one for each address)
  148 + // (see 'web/CXM_common.anubis' for the type 'Redirection')
  149 + redirection_list(map((String address) |-> redirect("/",address,"/site1.awp"), addresses)),
  150 +
  151 + // character encoding for web site 1
  152 + "UTF-8",
  153 +
  154 + // list of URI extensions producing a console/journal message
  155 + [
  156 + ".awp", // pages computed by this program
  157 + ".jpg", // images, etc...
  158 + ".gif",
  159 + ".png"
  160 + // add more extensions here (they must be known; see 'web/mime.anubis')
  161 + ],
  162 +
  163 + // list of HTTP headers which are traced in the console/journal messages
  164 + [
  165 + "host",
  166 + "user-agent"
  167 + // add more HTTP headers here
  168 + ],
  169 +
  170 + // secret string (used by 'private download')
  171 + "HUD76GRD56FD7GFDS4RT", // for a real site, please choose another one
  172 + // it must remain secret
  173 +
  174 + // list of known MIME types (taken from 'web/mime.anubis')
  175 + known_mime_types,
  176 +
  177 + // action to be performed before a file is sent
  178 + // (for example, this may be used for counting downloads)
  179 + (String action_name,
  180 + List(Web_arg) lwa) |-> unique // no action at all
  181 + )
  182 +.
  183 +
  184 +
  185 +
  186 +
  187 + *** Example site 2.
  188 +
  189 + Imagine another web site here...
  190 +
  191 +
  192 +
  193 +
  194 +
  195 + *** Starting all our web sites together.
  196 +
  197 +global define One
  198 + minimal_web_site
  199 + (
  200 + List(String) args
  201 + ) =
  202 + // make the directory for all web sites (if needed)
  203 + forget((String) make_directory(web_sites_directory));
  204 +
  205 + with http_port = (Word32)8000,
  206 + https_port = (Word32)4430,
  207 + // create a variable for handling the shutdown of our web sites
  208 + with shutdown_required = var(false),
  209 + with is_shutdown = (One u) |-> *shutdown_required,
  210 +
  211 + // start all web sites
  212 + if start_web_sites(
  213 + 0, // listen on all IP addresses
  214 + http_port, // port for HTTP
  215 + https_port, // port for HTTPS
  216 + "www.georges.example.com", // common name of SSL certificate
  217 + [
  218 + example_site_1
  219 + // add other web sites here
  220 + ],
  221 + is_shutdown) is
  222 + {
  223 + cannot_bind_to_port(n) then println("Cannot bind to port: "+n),
  224 + cannot_bind_to_port(n,m) then println("Cannot bind to ports: "+n+", "+m),
  225 + ok(s1,s2) then println("Servers started on ports "+http_port+" (HTTP) and "+https_port+" (HTTPS).")
  226 + }
  227 +.
  228 +
  229 +
  230 +
... ...
examples/minimal_web_site_vc.anubis 0 → 100644
  1 +
  2 +
  3 + *Project* The Anubis Project
  4 +
  5 + *Title* A minimal web site.
  6 +
  7 + *Copyright* Copyright © Calexium www.calexium.com.
  8 +
  9 + *Released*
  10 +
  11 + *Author* David RENÉ
  12 +
  13 + *Overview*
  14 +
  15 + This file is just an example which may help to start making a web site with
  16 + Anubis Calexium Library
  17 + It was based on the example for making a minimal web site made by Alain Prouté and located
  18 + in examples/network folder in standard library example
  19 +
  20 + This example is absolutely minimalist and manage only page.
  21 +
  22 +
  23 +read tools/basis.anubis // required for 'make_directory' and .
  24 +read system/convert.anubis
  25 +read calexium_lib/web/CXM_common.anubis // required for type 'Web_arg'
  26 +read calexium_lib/web/CXM_multihost_http_server.anubis // required for type 'HTTP_Info'
  27 +read calexium_lib/web/CXM_controller.anubis
  28 +read calexium_lib/web/CXM_making_a_web_site.anubis
  29 +read web/mime.anubis // required for list of known MIME types
  30 +read calexium_lib/web/CXM_web_arg_utils.anubis
  31 +read calexium_lib/web/CXM_form.anubis
  32 +read calexium_lib/web/jQuery/CXM_jquery_button.anubis
  33 +
  34 + *** Server directory.
  35 +
  36 + A directory for putting files for all web sites. There will be one subdirectory per web
  37 + site.
  38 +
  39 +define String web_sites_directory = my_anubis_directory+"/web_sites".
  40 +
  41 +
  42 +define HTML_Partial_Content
  43 + create_login_form
  44 + =
  45 +
  46 + partial_content(
  47 + [css(css_file("css/login.css"))],
  48 + div([id("login")],
  49 + sequence([
  50 + //BODY
  51 + div([id("login_body")],
  52 + cxm_form( "login_form", [], "do_login", [], [],
  53 + [
  54 + input (label(("LOGIN_NAME"), no_help), wan("login_name"), init(""), narrow, non_mandatory),
  55 + password_input(label(("PASSWORD"), no_help), wan("password"), init(""), narrow, non_mandatory),
  56 + partial(img_submit_button(("CONNECTION"), "login_form" ))
  57 + ])
  58 + ),
  59 + ])
  60 + )).
  61 +
  62 +define HTTP_Answer
  63 + go_login
  64 + (
  65 + One state
  66 + )=
  67 + html_page
  68 + (
  69 + "Example Site 1", // title of web site
  70 + [], // list of 'META' tags (empty for this site)
  71 + body // body of page
  72 + (
  73 + // list of body options
  74 + [
  75 + background_color(rgb(255,200,200))
  76 + // add more body options here
  77 + ],
  78 +
  79 + // content of page
  80 + partial(create_login_form)
  81 + )
  82 + )
  83 +.
  84 +
  85 +define HTTP_Answer
  86 + compute_page_1
  87 + (
  88 + One state
  89 + )=
  90 + html_page
  91 + (
  92 + "Example Site 1", // title of web site
  93 + [], // list of 'META' tags (empty for this site)
  94 + body // body of page
  95 + (
  96 + // list of body options
  97 + [
  98 + background_color(rgb(255,200,200))
  99 + // add more body options here
  100 + ],
  101 +
  102 + // content of page
  103 + center(text([size(14)],"This is the 'Example 1' web site."))
  104 + )
  105 + )
  106 +.
  107 +
  108 +define (One, HTTP_Answer)
  109 + root_controller
  110 + (
  111 + HTTP_Info http_info,
  112 + List(Web_arg) lwa,
  113 + Bool is_https,
  114 + One toto
  115 + )=
  116 +
  117 + with action = get_String(lwa, "action", "go_login"),
  118 + if action = "go_login" then
  119 + (unique, go_login(unique))
  120 + else
  121 + (unique, compute_page_1(unique)).
  122 +
  123 +
  124 +define WEB_Controller(One)
  125 + make_root_controller
  126 + =
  127 + web_controller("root", root_controller)
  128 +.
  129 +
  130 + Making the description of web site 1. In this description, several elements are the
  131 + bare minimum. There is no action at all, no data base, almost nothing. See
  132 + 'web/making_a_web_site.anubis' for the declaration of the function
  133 + 'make_web_site_description'.
  134 +
  135 +define Web_Site
  136 + example_site_1
  137 + =
  138 + // make the directory for web site 1
  139 + // (subdirectories of it will be created automatically by the HTTP server)
  140 + forget((String)make_directory(web_sites_directory+"/example_site_1"));
  141 +
  142 + // make a list of all possible 'host names' for web site 1:
  143 + with addresses = (List(String))
  144 + [
  145 + "example-site-1",
  146 + "127.0.0.1",
  147 + "192.168.0.1"
  148 + // add more adresses here
  149 + ],
  150 +
  151 + // now make the description of the web site
  152 + make_web_site_controller_description(
  153 +
  154 + //this is the unique ID of the web site. This ID will be use for prepend the cookies
  155 + //names belonging to that web site
  156 + "example",
  157 +
  158 + // the list of addresses defined above
  159 + addresses,
  160 +
  161 + // directory for the files of web site 1
  162 + web_sites_directory+"/example_site_1",
  163 +
  164 + // directory for the states of that web_site
  165 + web_sites_directory+"/example_site_1/states",
  166 +
  167 + // initializing function
  168 + (One u) |-> u, // nothing to initialize for web site 1
  169 +
  170 + // the function producing the initial state
  171 + (HTTP_Info info,
  172 + List(Web_arg) lwa,
  173 + Bool is_https) |-> unique, // there is ony one possible state for web site 1
  174 +
  175 + // the function for handling expired tickets
  176 + // (tickets are kept on the server's disk and represent states. They are used for
  177 + // passing session informations from pages to pages. See
  178 + // 'web/CXM_making_a_web_site.anubis' for detailed explanations.)
  179 + (One expired,
  180 + Maybe(String) mb_action_name,
  181 + HTTP_Info info,
  182 + List(Web_arg) lwa,
  183 + Bool is_https) |-> unique, // keep the same state
  184 +
  185 + // the function for handling lost tickets
  186 + (Maybe(String) mb_action_name,
  187 + HTTP_Info info,
  188 + List(Web_arg) lwa,
  189 + Bool is_https) |-> unique, // restart with default state
  190 +
  191 + var([make_root_controller]),
  192 +
  193 + // the function for producing additional HTTP headers
  194 + (One u) |-> [],
  195 +
  196 + // timeout for tickets (in seconds)
  197 + 3600, // does'nt matter since only one state
  198 +
  199 + // list of redirections (one for each address)
  200 + // (see 'web/CXM_common.anubis' for the type 'Redirection')
  201 + redirection_list(map((String address) |-> redirect("/",address,"/index.awp"), addresses)),
  202 +
  203 + // character encoding for web site 1
  204 + "UTF-8",
  205 +
  206 + // list of URI extensions producing a console/journal message
  207 + [
  208 + ".awp", // pages computed by this program
  209 + ".jpg", // images, etc...
  210 + ".gif",
  211 + ".png"
  212 + // add more extensions here (they must be known; see 'web/mime.anubis')
  213 + ],
  214 +
  215 + // list of HTTP headers which are traced in the console/journal messages
  216 + [
  217 + "host",
  218 + "user-agent"
  219 + // add more HTTP headers here
  220 + ],
  221 +
  222 + // secret string (used by 'private download')
  223 + "HUD76GRD56FD7GFDS4RT", // for a real site, please choose another one
  224 + // it must remain secret
  225 +
  226 + // list of known MIME types (taken from 'web/mime.anubis')
  227 + known_mime_types,
  228 +
  229 + // action to be performed before a file is sent
  230 + // (for example, this may be used for counting downloads)
  231 + (String action_name,
  232 + List(Web_arg) lwa) |-> unique // no action at all
  233 + )
  234 +.
  235 +
  236 +
  237 +
  238 +
  239 + *** Example site 2.
  240 +
  241 + Imagine another web site here...
  242 +
  243 +
  244 +
  245 +
  246 +
  247 + *** Starting all our web sites together.
  248 +
  249 +global define One
  250 + minimal_web_site_vc
  251 + (
  252 + List(String) args
  253 + ) =
  254 + // make the directory for all web sites (if needed)
  255 + forget((String) make_directory(web_sites_directory));
  256 +
  257 + with http_port = (Word32)8000,
  258 + https_port = (Word32)4430,
  259 + // create a variable for handling the shutdown of our web sites
  260 + with shutdown_required = var(false),
  261 + with is_shutdown = (One u) |-> *shutdown_required,
  262 +
  263 + // start all web sites
  264 + if start_web_sites(
  265 + 0, // listen on all IP addresses
  266 + http_port, // port for HTTP
  267 + https_port, // port for HTTPS
  268 + "www.georges.example.com", // common name of SSL certificate
  269 + [
  270 + example_site_1
  271 + // add other web sites here
  272 + ],
  273 + is_shutdown) is
  274 + {
  275 + cannot_bind_to_port(n) then println("Cannot bind to port: "+n),
  276 + cannot_bind_to_port(n,m) then println("Cannot bind to ports: "+n+", "+m),
  277 + ok(s1,s2) then println("Servers started on ports "+http_port+" (HTTP) and "+https_port+" (HTTPS).")
  278 + }
  279 +.
  280 +
  281 +
  282 +
... ...
minimal_web_site.aproj 0 → 100644
  1 +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  2 + <PropertyGroup>
  3 + <ProjectGuid>{F2C65267-0D20-4964-A5D8-602BD42C01A4}</ProjectGuid>
  4 + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
  5 + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
  6 + <OutputType>Exe</OutputType>
  7 + <RootNamespace>minimal_web_site</RootNamespace>
  8 + <AssemblyName>minimal_web_site</AssemblyName>
  9 + <StartupObject>examples\minimal_web_site.anubis</StartupObject>
  10 + <IncludePaths>./</IncludePaths>
  11 + </PropertyGroup>
  12 + <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
  13 + <OutputPath>bin\Debug\</OutputPath>
  14 + <DebugSymbols>True</DebugSymbols>
  15 + <DebugType>Full</DebugType>
  16 + <Optimize>False</Optimize>
  17 + </PropertyGroup>
  18 + <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
  19 + <OutputPath>bin\Release\</OutputPath>
  20 + <DebugSymbols>False</DebugSymbols>
  21 + <DebugType>None</DebugType>
  22 + <Optimize>True</Optimize>
  23 + </PropertyGroup>
  24 + <Import Project="$(AnubisBinPath)\Anubis.Build.targets" />
  25 + <ItemGroup>
  26 + <Compile Include="examples\minimal_web_site.anubis" />
  27 + <Compile Include="web\counter.anubis" />
  28 + <Compile Include="web\CXM_common.anubis" />
  29 + <Compile Include="web\CXM_cookies.anubis" />
  30 + <Compile Include="web\CXM_dojo.anubis" />
  31 + <Compile Include="web\CXM_dropzone.anubis" />
  32 + <Compile Include="web\CXM_form.anubis" />
  33 + <Compile Include="web\CXM_generic_form.anubis" />
  34 + <Compile Include="web\CXM_generic_login.anubis" />
  35 + <Compile Include="web\CXM_generic_table.anubis" />
  36 + <Compile Include="web\CXM_html_tooltip.anubis" />
  37 + <Compile Include="web\CXM_https_get.anubis" />
  38 + <Compile Include="web\CXM_http_get.anubis" />
  39 + <Compile Include="web\CXM_http_get_common.anubis" />
  40 + <Compile Include="web\CXM_jquery.anubis" />
  41 + <Compile Include="web\CXM_json.anubis" />
  42 + <Compile Include="web\CXM_making_a_web_site.anubis" />
  43 + <Compile Include="web\CXM_mime.anubis" />
  44 + <Compile Include="web\CXM_multihost_http_server.anubis" />
  45 + <Compile Include="web\CXM_style_tools.anubis" />
  46 + <Compile Include="web\CXM_urllib.anubis" />
  47 + <Compile Include="web\CXM_web_arg_encode.anubis" />
  48 + <Compile Include="web\CXM_web_arg_utils.anubis" />
  49 + <Compile Include="web\CXM_web_dump.anubis" />
  50 + <Compile Include="web\CXM_widgets.anubis" />
  51 + <Compile Include="web\CXM_xml_rpc.anubis" />
  52 + <Compile Include="web\CXM_xml_rpc_parser.anubis" />
  53 + <Compile Include="web\CXM_xml_rpc_types.anubis" />
  54 + <Compile Include="web\jQuery\CXM_jquery_animate.anubis" />
  55 + <Compile Include="web\jQuery\CXM_jquery_button.anubis" />
  56 + <Compile Include="web\jQuery\CXM_jquery_datatable.anubis" />
  57 + <Compile Include="web\jQuery\CXM_jquery_datatable_plugins.anubis" />
  58 + <Compile Include="web\jQuery\CXM_jquery_datatable_server_side.anubis" />
  59 + <Compile Include="web\jQuery\CXM_jquery_datatable_translation.anubis" />
  60 + <Compile Include="web\jQuery\CXM_jquery_datatable_types.anubis" />
  61 + <Compile Include="web\jQuery\CXM_jquery_dialog.anubis" />
  62 + <Compile Include="web\jQuery\CXM_jquery_easing.anubis" />
  63 + <Compile Include="web\jQuery\CXM_jquery_eudock.anubis" />
  64 + <Compile Include="web\jQuery\CXM_jquery_eudock_types.anubis" />
  65 + <Compile Include="web\jQuery\CXM_jquery_icons.anubis" />
  66 + <Compile Include="web\jQuery\CXM_jquery_jqplot.anubis" />
  67 + <Compile Include="web\jQuery\CXM_jquery_tabs.anubis" />
  68 + <Compile Include="web\jQuery\CXM_jquery_tiptip.anubis" />
  69 + <Compile Include="web\jQuery\CXM_jquery_toolbar.anubis" />
  70 + <Compile Include="web\jQuery\CXM_jq_checkbox.anubis" />
  71 + <Compile Include="web\jQuery\CXM_jq_form.anubis" />
  72 + <Compile Include="web\jQuery\CXM_jq_radio.anubis" />
  73 + <Compile Include="web\jQuery\jq_flot.anubis" />
  74 + <Compile Include="web\jQuery\ui-addon\datetimepicker.anubis" />
  75 + <Compile Include="web\js_tools.anubis" />
  76 + <Compile Include="web\piwik\CXM_piwik.anubis" />
  77 + <Compile Include="web\widgets\button.anubis" />
  78 + <Compile Include="web\widgets\css_helper.anubis" />
  79 + <Compile Include="web\widgets\dashboard.anubis" />
  80 + <Compile Include="web\widgets\fisheye_menu.anubis" />
  81 + <Compile Include="web\widgets\icons_set.anubis" />
  82 + <Compile Include="web\widgets\left_menu.anubis" />
  83 + <None Include="web\CXM_making_a_web_site.anubis.bak" />
  84 + <None Include="web\js\cxm_jquery_animate.js" />
  85 + </ItemGroup>
  86 + <ItemGroup>
  87 + <Folder Include="examples" />
  88 + <Folder Include="web" />
  89 + <Folder Include="web\jQuery" />
  90 + <Folder Include="web\jQuery\ui-addon" />
  91 + <Folder Include="web\js" />
  92 + <Folder Include="web\piwik" />
  93 + <Folder Include="web\widgets" />
  94 + </ItemGroup>
  95 +</Project>
0 96 \ No newline at end of file
... ...
web/CXM_common.anubis
... ... @@ -4,12 +4,12 @@
4 4  
5 5 *Copyright*
6 6 Copyright (c) Alain Prouté 2003~2007.
7   - © Calexium 2007~2016
  7 + © Calexium 2007~2017
8 8  
9 9  
10 10 *Authors:*
11 11 Alain Prouté
12   - David René
  12 + David RENÉ
13 13  
14 14 *Public*
15 15 *Name* HTTP_header
... ... @@ -21,27 +21,31 @@ transmit system/string.anubis
21 21 /**
22 22 * The type 'HTTP_header' describes HTTP headers, which are just pairs '(name,value)'.
23 23 */
  24 +
24 25 public type HTTP_header:
25   - http_header(String name,
26   - String value).
27   -
  26 + http_header(
  27 + String name,
  28 + String value
  29 + )
  30 +.
28 31  
29 32 public define Maybe(String)
30 33 http_header_value
31   - (
32   - List(HTTP_header) l,
33   - String name
34   - ) =
  34 + (
  35 + List(HTTP_header) l,
  36 + String name
  37 + )=
35 38 if l is
36   - {
37   - [ ] then failure,
38   - [h . t] then if h is
39   - {
40   - http_header(n, v) then //print("DEBUG: http_header_value --> HEADER = " + n + ":" + v + "\n");
41   - if insensitive_equal(name, n) then success(v)
42   - else http_header_value(t, name),
43   - }
44   - }.
  39 + {
  40 + [ ] then failure,
  41 + [h . t] then if h is
  42 + {
  43 + http_header(n, v) then //print("DEBUG: http_header_value --> HEADER = " + n + ":" + v + "\n");
  44 + if insensitive_equal(name, n) then success(v)
  45 + else http_header_value(t, name),
  46 + }
  47 + }
  48 +.
45 49  
46 50 public define List(String)
47 51 to_List_String
... ... @@ -49,7 +53,7 @@ public define List(String)
49 53 List(HTTP_header) l
50 54 )=
51 55 map((HTTP_header h) |-> h.name +": "+h.value, l ).
52   -
  56 +
53 57 public define String
54 58 to_String
55 59 (
... ... @@ -57,7 +61,19 @@ public define String
57 61 )=
58 62 join("\n\r",to_List_String(l)).
59 63  
60   -
  64 +
  65 +public type HTTP_Info:
  66 + http_info
  67 + (
  68 + Word32 ip_address, // IP address of the client
  69 + String hostname, // hostname requested by the client
  70 + String uri, // URI requested by the client
  71 + List(HTTP_header) http_headers, // HTTP headers sent by the client
  72 + Bool is_https
  73 + //One -> String generate_trust_ticket // may be used against denial of
  74 + // service attacks
  75 + ).
  76 +
61 77 *Name* Web_arg
62 78 *Description*
63 79  
... ... @@ -71,13 +87,16 @@ public define String
71 87 'web/html.anubis').
72 88  
73 89 public type Web_arg:
74   - web_arg(String name,
75   - String value),
76   - upload (String name, // name of corresponding 'upload' Web_item
77   - String value, // name of uploaded file
78   - String temp_file_path). // temporary file path (relative to server directory)
  90 + web_arg(
  91 + String name,
  92 + String value
  93 + ),
  94 + upload (
  95 + String name, // name of corresponding 'upload' Web_item
  96 + String value, // name of uploaded file
  97 + String temp_file_path) // temporary file path (relative to server directory)
  98 +.
79 99  
80   -
81 100 *Name* Web_arg_value
82 101 *Description*
83 102 Of course, within the body of a 'web page' operation, you may want to recover the value
... ... @@ -103,26 +122,27 @@ public type Web_arg_value:
103 122  
104 123 public define Web_arg_value
105 124 web_arg_value
106   - (
107   - List(Web_arg) l,
108   - String name
109   - ) =
  125 + (
  126 + List(Web_arg) l,
  127 + String name
  128 + )=
110 129 if l is
111   - {
112   - [ ] then not_found,
113   - [h . t] then if h is
114   - {
115   - web_arg(n,v) then
116   - if name=n
117   - then found(v)
118   - else web_arg_value(t,name),
119   -
120   - upload(n,v,tfn) then
121   - if name=n
122   - then found(v)
123   - else web_arg_value(t,name)
124   - }
125   - }.
  130 + {
  131 + [ ] then not_found,
  132 + [h . t] then if h is
  133 + {
  134 + web_arg(n,v) then
  135 + if name=n
  136 + then found(v)
  137 + else web_arg_value(t,name),
  138 +
  139 + upload(n,v,tfn) then
  140 + if name=n
  141 + then found(v)
  142 + else web_arg_value(t,name)
  143 + }
  144 + }
  145 +.
126 146  
127 147 public define Web_arg_value
128 148 web_arg_value_not_null
... ... @@ -143,23 +163,24 @@ public define Web_arg_value
143 163 *Ignore*
144 164  
145 165 public define Maybe((String,String))
146   - file_upload_value
147   - (
148   - List(Web_arg) l,
149   - String name
150   - ) =
151   - if l is
152   - {
153   - [ ] then failure,
154   - [h . t] then if h is
155   - {
156   - web_arg(_,_) then file_upload_value(t,name),
157   - upload(n,v,tfn) then
158   - if n = name
159   - then success((v,tfn))
160   - else file_upload_value(t,name)
161   - }
162   - }.
  166 + file_upload_value
  167 + (
  168 + List(Web_arg) l,
  169 + String name
  170 + )=
  171 + if l is
  172 + {
  173 + [ ] then failure,
  174 + [h . t] then
  175 + if h is
  176 + {
  177 + web_arg(_,_) then file_upload_value(t,name),
  178 + upload(n,v,tfn) then
  179 + if n = name
  180 + then success((v,tfn))
  181 + else file_upload_value(t,name)
  182 + }
  183 + }.
163 184  
164 185 public define List((String,String))
165 186 file_upload_value
... ...
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,13 +310,18 @@ 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 +public define CXM_Form_Field //Helper for older project wich use only String as Action name
  321 + submit(String _action_name, Maybe(String) label, String button_text, List((String,String)) extra_operands)
  322 + = submit([], htmlClass(""), action_name(_action_name), label, button_text, extra_operands).
  323 +
  324 +
320 325 public define CXM_Form_Field
321 326 upload(HTML_Label label, HTML_Id id, WebArgName name, Width width)
322 327 = upload([], label, id, name, width, non_mandatory).
... ... @@ -559,7 +564,7 @@ public define HTML_In_Form
559 564 sequence([
560 565 literal("<fieldset" + format_attrs(options) + ">"),
561 566 literal(if length(legend) > 0 then "<legend>" + legend + "</legend>" else ""),
562   - sequence( map((CXM_Form_Field ff) |-> div([class("form_field")], format_CXM_Form_Field(ff, lwa)), fields) ),
  567 + sequence( map((CXM_Form_Field ffield) |-> div([class("form_field")], format_CXM_Form_Field(ffield, lwa)), fields) ),
563 568 literal("</fieldset>")
564 569 ]),
565 570  
... ... @@ -619,9 +624,9 @@ public define HTML_In_Form
619 624 public define HTML_Off_Form
620 625 cxm_form
621 626 (
622   - HTML_Id form_Id,
  627 + HTML_Id form_Id,
623 628 List(CoreAttrs) options,
624   - String action_name,
  629 + WEB_Action_Name action,
625 630 List((String,String)) extra_ops,
626 631 List(Web_arg) lwa,
627 632 List(CXM_Form_Field) fields
... ... @@ -630,7 +635,30 @@ public define HTML_Off_Form
630 635 form(
631 636 form_Id,
632 637 [class("cxm_form") . options],
633   - action_name,
  638 + action,
  639 + extra_ops,
  640 + format_CXM_Form_Field(fields, lwa)
  641 + ).
  642 +
  643 +public define HTML_Off_Form
  644 +/* older manner to call CXM_form with action as String.
  645 + * this function only exists for compatibility with older projects. Please consider
  646 + * to use the above function with WEB_Action_Name instead of String
  647 +*/
  648 + cxm_form
  649 + (
  650 + HTML_Id form_Id,
  651 + List(CoreAttrs) options,
  652 + String action, //older manner to call action with String
  653 + List((String,String)) extra_ops,
  654 + List(Web_arg) lwa,
  655 + List(CXM_Form_Field) fields
  656 + ) =
  657 +
  658 + form(
  659 + form_Id,
  660 + [class("cxm_form") . options],
  661 + action_name(action),
634 662 extra_ops,
635 663 format_CXM_Form_Field(fields, lwa)
636 664 ).
... ... @@ -640,23 +668,25 @@ public define HTML_Off_Form
640 668 (
641 669 String form_name,
642 670 List(CoreAttrs) options,
643   - String action_name,
  671 + WEB_Action_Name action,
644 672 List((String,String)) extra_ops,
645 673 List(Web_arg) lwa,
646 674 List(CXM_Form_Field) form_fields
647 675 )=
648   - cxm_form(html_Id(form_name), options, action_name, extra_ops, lwa, form_fields).
649   -
650   - public define HTML_In_Form
651   - cxm_fieldset
  676 + cxm_form(html_Id(form_name), options, action, extra_ops, lwa, form_fields).
  677 +
  678 +public define HTML_Off_Form
  679 + cxm_form
652 680 (
653   - HTML_Id fieldSetId,
  681 + String form_name,
  682 + List(CoreAttrs) options,
  683 + String action,
  684 + List((String,String)) extra_ops,
654 685 List(Web_arg) lwa,
655   - List(CXM_Form_Field) fields
656   - ) =
657   - cxm_fieldset([id(fieldSetId.id), class("aligned")], "", lwa, fields).
658   -
659   -
  686 + List(CXM_Form_Field) form_fields
  687 + )=
  688 + cxm_form(html_Id(form_name), options, action_name(action), extra_ops, lwa, form_fields).
  689 +
660 690  
661 691 public define HTML_Off_Form
662 692 cxm_form
... ... @@ -665,7 +695,7 @@ public define HTML_Off_Form
665 695 List(CoreAttrs) options,
666 696 List(HTML_In_Form) fields
667 697 ) =
668   - cxm_form(html_Id(form_id), options, "", [], [], map((HTML_In_Form field) |-> raw_in_form(field), fields) ).
  698 + cxm_form(html_Id(form_id), options, action_name(""), [], [], map((HTML_In_Form field) |-> raw_in_form(field), fields) ).
669 699  
670 700 public define HTML_Off_Form
671 701 cxm_form
... ... @@ -675,7 +705,7 @@ public define HTML_Off_Form
675 705 List(Web_arg) lwa,
676 706 List(CXM_Form_Field) fields
677 707 ) =
678   - cxm_form(html_Id(form_id), options, "", [], lwa, fields).
  708 + cxm_form(html_Id(form_id), options, action_name(""), [], lwa, fields).
679 709  
680 710 public define HTML_Off_Form
681 711 cxm_form
... ... @@ -683,7 +713,7 @@ public define HTML_Off_Form
683 713 String form_id,
684 714 List(HTML_In_Form) fields
685 715 ) =
686   - cxm_form(html_Id(form_id), [], "", [], [], map((HTML_In_Form field) |-> raw_in_form(field), fields) ).
  716 + cxm_form(html_Id(form_id), [], action_name(""), [], [], map((HTML_In_Form field) |-> raw_in_form(field), fields) ).
687 717  
688 718 public define HTML_Off_Form
689 719 cxm_form
... ... @@ -700,4 +730,4 @@ public define HTML_Off_Form
700 730 String form_id,
701 731 List(CXM_Form_Field) fields
702 732 ) =
703   - cxm_form(html_Id(form_id), [], "", [], [], fields).
  733 + 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,11 +55,14 @@ 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 +transmit CXM_web_dump.anubis
  64 +transmit CXM_web_arg_utils.anubis
  65 +
63 66 //read CXM_html_tooltip.anubis
64 67  
65 68 * (1) Structure of a web site.
... ... @@ -274,64 +277,6 @@ public type Web_Action($State):
274 277 In most cases, HTTP informations are not used. This is the reason why they are gathered
275 278 for simplicity into a unique datum of type 'HTTP_Info'.
276 279  
277   -// For your convenience, we introduce the following simpler variants:
278   -//
279   -//public define Web_Action($State)
280   -// http_action
281   -// (
282   -// String name,
283   -// $State -> Bool allow,
284   -// (List(Web_arg),$State) -> $State do_it
285   -// ) =
286   -// http_action(name,
287   -// (Maybe($State) ms) |-> if ms is
288   -// {
289   -// failure then true,
290   -// success(s) then allow(s)
291   -// },
292   -// (HTTP_Info h, List(Web_arg) l, Maybe($State) s) |-> if s is
293   -// {
294   -// failure then (failure, []),
295   -// success(s2) then (success(do_it(l,s2)), [])
296   -// }).
297   -//
298   -//public define Web_Action($State)
299   -// https_action
300   -// (
301   -// String name,
302   -// $State -> Bool allow,
303   -// (List(Web_arg),$State) -> $State do_it
304   -// ) =
305   -// https_action(name,
306   -// (Maybe($State) ms) |-> if ms is
307   -// {
308   -// failure then true,
309   -// success(s) then allow(s)
310   -// },
311   -// (HTTP_Info h, List(Web_arg) l, Maybe($State) s) |-> if s is
312   -// {
313   -// failure then (failure, []),
314   -// success(s2) then (success(do_it(l,s2)), [])
315   -// }).
316   -//
317   -//public define Web_Action($State)
318   -// http_https_action
319   -// (
320   -// String name,
321   -// $State -> Bool allow,
322   -// (List(Web_arg),$State) -> $State do_it
323   -// ) =
324   -// http_https_action(name,
325   -// (Maybe($State) ms) |-> if ms is
326   -// {
327   -// failure then true,
328   -// success(s) then allow(s)
329   -// },
330   -// (HTTP_Info h, List(Web_arg) l, Maybe($State) s) |-> if s is
331   -// {
332   -// failure then (failure, []),
333   -// success(s2) then (success(do_it(l,s2)), [])
334   -// }).
335 280  
336 281  
337 282  
... ... @@ -351,10 +296,189 @@ public type HTTP_Answer:...
351 296 understand the page shown to the client as a representation of the current state of the
352 297 conversation between the client and the web site, but also containing informations
353 298 taken from the data bases.
  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:
  366 + web_controller(
  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
  370 + )
  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 +.
354 405  
355 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
356 415  
357   -
  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 +.
358 482  
359 483 ** (1.5) States.
360 484  
... ... @@ -1225,7 +1349,7 @@ public type HTML_In_Form:
1225 1349 Int content_width, Int content_height,
1226 1350 HTML_In_Form content),
1227 1351 actioner (Actioner_Connection, Actioner_Target, Actioner_Aspect,
1228   - String action_name, List((String,String)) extra_ops,
  1352 + WEB_Action_Name action_name, List((String,String)) extra_ops,
1229 1353 List(Actioner_Local_Action)),
1230 1354 foreign_link_new (Actioner_Target, Actioner_Aspect, String url),
1231 1355 foreign_link (List(Text_Option), String url),
... ... @@ -1282,15 +1406,32 @@ public define HTML_In_Form
1282 1406 foreign_link([size(tsize)],url,name).
1283 1407  
1284 1408 public define HTML_In_Form
1285   - actioner
1286   - (
  1409 + actioner
  1410 + (
1287 1411 Actioner_Connection conn,
1288 1412 Actioner_Target targ,
1289 1413 Actioner_Aspect asp,
1290   - String action_name,
  1414 + WEB_Action_Name action,
1291 1415 List((String,String)) extra_ops
1292   - ) =
1293   - actioner(conn,targ,asp,action_name,extra_ops,[]).
  1416 + )=
  1417 + actioner(conn,targ,asp,action,extra_ops,[])
  1418 +.
  1419 +
  1420 +public define HTML_In_Form
  1421 +/* Older call with String as action instead of WEB_Action_Name.
  1422 + * This function exists only for compatibility with older project.
  1423 + * Please condiser to use above function instead
  1424 + */
  1425 + actioner
  1426 + (
  1427 + Actioner_Connection conn,
  1428 + Actioner_Target targ,
  1429 + Actioner_Aspect asp,
  1430 + String action,
  1431 + List((String,String)) extra_ops
  1432 + )=
  1433 + actioner(conn,targ,asp,action_name(action),extra_ops,[])
  1434 +.
1294 1435  
1295 1436 public define HTML_In_Form
1296 1437 actioner
... ... @@ -1299,7 +1440,7 @@ public define HTML_In_Form
1299 1440 Actioner_Target targ,
1300 1441 Actioner_Aspect asp,
1301 1442 ) =
1302   - actioner(conn, targ, asp, "", [], []).
  1443 + actioner(conn, targ, asp, action_name(""), [], []).
1303 1444  
1304 1445  
1305 1446 public define HTML_In_Form
... ... @@ -1443,10 +1584,10 @@ public type HTML_Off_Form:
1443 1584 fixed_size (HTML_Size width, HTML_Size height, HTML_Off_Form content),
1444 1585 fixed_size_2 (HTML_Size width, HTML_Size height, String name_of_HTML_file),
1445 1586 actioner (Actioner_Connection, Actioner_Target, Actioner_Aspect,
1446   - String action_name, List((String,String)) extra_ops,
  1587 + WEB_Action_Name action_name, List((String,String)) extra_ops,
1447 1588 List(Actioner_Local_Action)),
1448 1589 actioner (Actioner_Connection, Actioner_Target, Actioner_Aspect,
1449   - String action_name, List((String,String)) extra_ops,
  1590 + WEB_Action_Name action_name, List((String,String)) extra_ops,
1450 1591 List(Actioner_Local_Action), String form_name),
1451 1592 foreign_link_new (Actioner_Target, Actioner_Aspect, String url),
1452 1593 foreign_link (List(Text_Option), String url),
... ... @@ -1456,7 +1597,7 @@ public type HTML_Off_Form:
1456 1597 label (String name),
1457 1598 form (HTML_Id form_id, List(CoreAttrs), HTML_In_Form content),
1458 1599 form (HTML_Id form_id, List(CoreAttrs),
1459   - String action_name, List((String,String)) extra_ops,
  1600 + WEB_Action_Name action, List((String,String)) extra_ops,
1460 1601 HTML_In_Form content),
1461 1602 in_form (HTML_Id form_id, HTML_In_Form content),
1462 1603 div (List(CoreAttrs), HTML_Off_Form content),
... ... @@ -1496,11 +1637,11 @@ public define HTML_Off_Form
1496 1637 (
1497 1638 String form_name,
1498 1639 List(CoreAttrs) options,
1499   - String action_name,
  1640 + WEB_Action_Name action,
1500 1641 List((String,String)) extra_ops,
1501 1642 HTML_In_Form content
1502 1643 ) =
1503   - form(html_Id(form_name), options, action_name, extra_ops, content).
  1644 + form(html_Id(form_name), options, action, extra_ops, content).
1504 1645  
1505 1646  
1506 1647 public define HTML_Off_Form literal(Printable_tree t) = literal_pt(t).
... ... @@ -1524,10 +1665,26 @@ public define HTML_Off_Form
1524 1665 Actioner_Connection conn,
1525 1666 Actioner_Target targ,
1526 1667 Actioner_Aspect asp,
1527   - String action_name,
  1668 + WEB_Action_Name action,
1528 1669 List((String,String)) extra_ops
1529 1670 ) =
1530   - actioner(conn,targ,asp,action_name,extra_ops,[]).
  1671 + actioner(conn,targ,asp,action,extra_ops,[]).
  1672 +
  1673 +public define HTML_Off_Form
  1674 +/* Older call with String as action instead of WEB_Action_Name.
  1675 + * This function exists only for compatibility with older project.
  1676 + * Please condiser to use above function instead
  1677 + */
  1678 + actioner
  1679 + (
  1680 + Actioner_Connection conn,
  1681 + Actioner_Target targ,
  1682 + Actioner_Aspect asp,
  1683 + String action,
  1684 + List((String,String)) extra_ops
  1685 + )=
  1686 + actioner(conn,targ,asp,action_name(action),extra_ops,[])
  1687 +.
1531 1688  
1532 1689 public define HTML_Off_Form
1533 1690 table
... ... @@ -1761,8 +1918,8 @@ define Printable_tree
1761 1918 public type HTML_Meta:
1762 1919 keywords (List(String)),
1763 1920 refresh (Actioner_Connection connection,
1764   - Actioner_Target target,
1765   - String action_name,
  1921 + Actioner_Target target,
  1922 + WEB_Action_Name action,
1766 1923 Int delay), // in seconds
1767 1924 refresh (String url, Int delay), // in seconds
1768 1925 meta (String name, String content),
... ... @@ -1771,7 +1928,19 @@ public type HTML_Meta:
1771 1928 literal (String).
1772 1929  
1773 1930 Meta tags are put in the 'head' of the HTML page.
1774   -
  1931 +
  1932 +public define HTML_Meta
  1933 + refresh
  1934 + (
  1935 + Actioner_Connection connection,
  1936 + Actioner_Target target,
  1937 + String action,
  1938 + Int delay
  1939 + )=
  1940 + refresh(connection, target, action_name(action), delay)
  1941 +.
  1942 +
  1943 +
1775 1944  
1776 1945 public type Body_Option:
1777 1946 core_attrs(List(CoreAttrs)),
... ... @@ -1998,22 +2167,26 @@ public define HTTP_Answer
1998 2167 *** [1] States.
1999 2168 *** [1.1] Saving and retrieving states.
2000 2169 *** [1.2] Deleting out of date states.
  2170 +
  2171 + *** [2] Sessions.
  2172 + *** [2.1] Saving and retrieving sessions.
  2173 + *** [2.2] Deleting out of date sessions.
  2174 +
  2175 + *** [3] Tools.
  2176 + *** [3.1] Directories.
  2177 + *** [3.2] Secondary documents.
2001 2178  
2002   - *** [2] Tools.
2003   - *** [2.1] Directories.
2004   - *** [2.2] Secondary documents.
2005   -
2006   - *** [3] Managing web arguments.
  2179 + *** [4] Managing web arguments.
2007 2180 *** [3.1] Prefixing web arguments names.
2008 2181 *** [3.2] Separating web arguments.
2009 2182 *** [3.3] Applying an action.
2010 2183  
2011   - *** [4] Web site descriptions and the 'awp handlers'.
  2184 + *** [5] Web site descriptions and the 'awp handlers'.
2012 2185 *** [4.1] The type 'Web_Site'.
2013 2186 *** [4.2] Making a web site description.
2014 2187 *** [4.3] Starting the servers.
2015 2188  
2016   - *** [5] HTML Formating.
  2189 + *** [6] HTML Formating.
2017 2190 *** [5.1] The type 'HTML_Any($T)'.
2018 2191 *** [5.2] Formating a color.
2019 2192 *** [5.3] Creating buttons.
... ... @@ -2032,7 +2205,7 @@ define Printable_tree
2032 2205 format
2033 2206 (
2034 2207 CommonInfo cinfo,
2035   - String sn, // state_name
  2208 + //String sn, // state_name
2036 2209 Var(Int) ic_v, // 'idnum' counter variable
2037 2210 HTML_Off_Form element,
2038 2211 Bool is_https,
... ... @@ -2075,7 +2248,8 @@ read CXM_web_arg_encode.anubis
2075 2248  
2076 2249 The tool below constructs the function which is able to save a state on the server's
2077 2250 disk.
2078   -
  2251 +
  2252 +
2079 2253 define ($State s) -> String // the function constructed returns the name of the state
2080 2254 make_save_state_function
2081 2255 (
... ... @@ -2118,7 +2292,9 @@ define (String state_name) -&gt; PreviousState($State)
2118 2292 )
2119 2293 else still_valid(s) // state has been successfully retrieved
2120 2294 )
2121   - else not_found.
  2295 + else
  2296 + forget(remove(file_path));
  2297 + not_found.
2122 2298  
2123 2299  
2124 2300  
... ... @@ -2139,7 +2315,7 @@ define (List(String) file_names) -&gt; One
2139 2315 {
2140 2316 [ ] then unique,
2141 2317 [h . t] then
2142   - with file_path = state_directory+"/"+h,
  2318 + with file_path = state_directory+"/s"+h,
2143 2319 if (RetrieveResult((Int,$State)))retrieve(file_path) is ok(d)
2144 2320 then (
2145 2321 if d is (time_stamp,data) then
... ... @@ -2148,7 +2324,7 @@ define (List(String) file_names) -&gt; One
2148 2324 else df(t)
2149 2325 )
2150 2326 else (forget(remove(file_path)); df(t))
2151   - }.
  2327 + }.
2152 2328  
2153 2329  
2154 2330 The 'labelled arrow' |-df-> is documented in 'documentation/en/anubis_doc.txt'.
... ... @@ -2212,7 +2388,7 @@ define One
2212 2388 else if now > next_time
2213 2389 then
2214 2390 (
2215   - delete_out_of_date_states(directories_and_functions);
  2391 + delete_out_of_date_states(directories_and_functions);
2216 2392 delete_states_loop(directories_and_functions,
2217 2393 timeout,
2218 2394 now+timeout,
... ... @@ -2265,7 +2441,6 @@ define String
2265 2441 (
2266 2442 String sd, // site directory
2267 2443 String as, // authorization_secret
2268   - String sn, // state name
2269 2444 $T -> Printable_tree format_element,
2270 2445 $T content,
2271 2446 HTML_Size width
... ... @@ -2417,8 +2592,6 @@ define (List(Web_arg) lwa, HTTP_Info info) -&gt; Separated_Web_Args($State)
2417 2592  
2418 2593  
2419 2594  
2420   -
2421   -
2422 2595  
2423 2596 *** [3.3] Applying an action.
2424 2597  
... ... @@ -2535,7 +2708,7 @@ public define Printable_tree
2535 2708 format
2536 2709 (
2537 2710 CommonInfo cinfo,
2538   - String state_name,
  2711 + //String state_name,
2539 2712 List(HTTP_header) headers,
2540 2713 HTTP_Answer page,
2541 2714 Bool is_https,
... ... @@ -2670,7 +2843,7 @@ public define Web_Site
2670 2843 },
2671 2844  
2672 2845 format(info(host_name, http_port, https_port, site_directory, secret),
2673   - state_name,
  2846 + //state_name,
2674 2847 additional_headers(new_state) + cookie_headers,
2675 2848 compute_page(new_state),
2676 2849 is_https,
... ... @@ -2706,7 +2879,287 @@ public define Web_Site
2706 2879 ),
2707 2880 delete_out_of_date).
2708 2881  
  2882 + public type WEB_Controller:
  2883 + web_controller(
  2884 + String name, //controller name
  2885 + (HTTP_Info http_info,
  2886 + List(Web_arg) lwa,
  2887 + Bool is_https
  2888 + ) -> HTTP_Answer view //view renderer
  2889 + )
  2890 +
  2891 +
  2892 +
  2893 +define HTTP_Answer
  2894 + error_page
  2895 + (
  2896 + HTTP_Status http_status
  2897 + )
  2898 + =
  2899 + html_page
  2900 + (
  2901 + http_status, // status
  2902 + [], // list of 'META' tags (empty for this site)
  2903 + body // body of page
  2904 + (
  2905 + // list of body options
  2906 + [
  2907 + background_color(rgb(255,200,200))
  2908 + ],
  2909 +
  2910 + // content of page
  2911 + sequence([
  2912 + text([size(16)], "Anubis Web Server 1.14"),
  2913 + br,
  2914 + text([size(16)],"Error "+to_String(http_status))
  2915 + ])
  2916 + )
  2917 + )
  2918 +.
  2919 +
  2920 +define WEB_Controller_Result
  2921 + apply_action
  2922 + (
  2923 + WEB_Session _session,
  2924 + String requested_action_name,
  2925 + List(WEB_Action) actions_list
  2926 + ) =
  2927 + if actions_list is
  2928 + {
  2929 + [] then http_answer(error_page(http_not_found)),
  2930 + [h . t] then
  2931 + with action_name = if h.name is
  2932 + {
  2933 + controller_action(_, name) then name,
  2934 + action_name(name) then name
  2935 + },
  2936 + if requested_action_name = action_name then
  2937 + if h.allowed_proto is
  2938 + {
  2939 + //Action only in HTTP
  2940 + http then
  2941 + if _session.web_request.is_https then
  2942 + http_answer(error_page(http_forbidden))
  2943 + else
  2944 + //ask to the server the authorization to execute that action
  2945 + if h.allow(_session) then
  2946 + h.do_it(_session)
  2947 + else
  2948 + http_answer(error_page(http_unauthorized))
  2949 +
  2950 + //Action only in HTTPS
  2951 + https then
  2952 + if _session.web_request.is_https then
  2953 + //ask to the server the authorization to execute that action
  2954 + if h.allow(_session) then
  2955 + h.do_it(_session)
  2956 + else
  2957 + http_answer(error_page(http_unauthorized))
  2958 + else
  2959 + http_answer(error_page(http_forbidden))
  2960 + //Action in both HTTP / HTTPS
  2961 + http_https then
  2962 + //ask to the server the authorization to execute that action
  2963 + if h.allow(_session) then
  2964 + h.do_it(_session)
  2965 + else
  2966 + http_answer(error_page(http_unauthorized))
  2967 +
  2968 + }
  2969 + else
  2970 + apply_action(_session, requested_action_name, t)
  2971 + }
  2972 +.
  2973 +
  2974 +define Maybe(WEB_Controller)
  2975 + get_controller
  2976 + (
  2977 + String controller_name,
  2978 + List(WEB_Controller) controllers,
  2979 + )=
  2980 + if controllers is
  2981 + {
  2982 + [] then failure,
  2983 + [h . t] then
  2984 + if h.name = controller_name then
  2985 + success(h)
  2986 + else
  2987 + get_controller(controller_name, t)
  2988 + }
  2989 +.
  2990 +
  2991 +define (Maybe(WEB_Session), HTTP_Answer)
  2992 + apply_controller_action
  2993 + (
  2994 + WEB_Controller controller,
  2995 + List(WEB_Controller) controllers,
  2996 + WEB_Session _session
  2997 + )=
  2998 + //get the action name
  2999 + if get_String(_session.web_request.lwa, "aws_action") is
  3000 + {
  3001 + failure then (failure, error_page(http_not_found)),
  3002 + success(action_name) then
  3003 +
  3004 + if apply_action(_session, action_name, *controller.controller_actions) is
  3005 + {
  3006 + http_answer(session, answer) then (success(session), answer),
  3007 + http_answer(answer) then (success(_session), answer),
  3008 + redirect(new_session) then
  3009 + if get_controller(get_String(new_session.web_request.lwa, "aws_controller", "root"), controllers) is
  3010 + {
  3011 + failure then (failure, error_page(http_not_found)),
  3012 + success(new_controller) then apply_controller_action(new_controller, controllers, new_session),
  3013 + }
  3014 +
  3015 + redirect_to_previous then
  3016 + if get_controller(get_String(_session.previous_request.lwa, "aws_controller", "root"), controllers) is
  3017 + {
  3018 + failure then (failure, error_page(http_not_found)),
  3019 + success(new_controller) then
  3020 + since _session is web_session(lang, entries, _, previous),
  3021 + apply_controller_action(new_controller, controllers, web_session(lang, entries, previous, previous)),
  3022 + }
  3023 +
  3024 + ajax(answer) then (failure, answer),
  3025 + }
  3026 + }
  3027 +.
  3028 +
  3029 +public define Web_Site
  3030 + make_web_site_controller_description
  3031 + (
  3032 + String website_name, // site_UID
  3033 + List(String) common_names, // for example: ["www.our-business.com"]
  3034 + String site_directory,
  3035 + String state_directory,
  3036 + One -> One init,
  3037 + (HTTP_Info,
  3038 + List(Web_arg),
  3039 + Bool is_https) -> WEB_Session initial_session,
  3040 + (WEB_Session,
  3041 + HTTP_Info,
  3042 + List(Web_arg),
  3043 + Bool is_https) -> WEB_Session expired_session,
  3044 + Var(List(WEB_Controller)) web_controllers,
  3045 + Maybe(WEB_Session) -> List(HTTP_header) additional_headers,
  3046 + Int timeout,
  3047 + Redirections redirections,
  3048 + String charset,
  3049 + List(String) journal_extensions,
  3050 + List(String) journal_headers,
  3051 + String secret,
  3052 + List(MIME) known_mime_types,
  3053 + (String action_name,
  3054 + List(Web_arg) args) -> One before_send_file
  3055 + )=
  3056 + //call the initialization function
  3057 + init(unique);
  3058 +
  3059 +
  3060 + //
  3061 + // make required directories (if needed)
  3062 + //
  3063 + with //web_sites_directory = (String) make_directory(my_anubis_directory+"/web_sites"),
  3064 + base_directory = (String) make_directory(site_directory),
  3065 + // state_directory = make_directory(site_directory+"/states"),
  3066 + forget((String)make_directory(site_directory+"/public"));
  3067 + //
  3068 + // construct tool functions
  3069 + // TODO 'make_separate_web_args_function' must retrieve state_cookies before parsing web_args if using_state_cookies is true
  3070 + with save_session = make_save_session_function(timeout, state_directory),
  3071 + // retrieve_session = make_retrieve_session_function(state_directory, website_name),
  3072 + //separate_web_args = make_separate_web_args_function(state_directory, retrieve_state),
  3073 + //apply_action = make_apply_action_function(actions),
  3074 +
  3075 + //
  3076 + // construct the site handler
  3077 + //
  3078 + site_handler = (Word32 http_port, Word32 https_port) |->
  3079 + ((String host_name,
  3080 + HTTP_Info http_info,
  3081 + List(Web_arg) _lwa,
  3082 + Bool is_https) |->
  3083 + //(Printable_tree)
  3084 + println("host_name "+host_name);
  3085 + println(dump_http_info(http_info));
  3086 + println(dump_web_arg_values(_lwa));
  3087 +
  3088 +
  3089 + //retrieve the previous session and determine the new one
  3090 + with current_session = if retrieve_session(http_info, state_directory, website_name) is
  3091 + {
  3092 + not_found then
  3093 + //println("previous state not found");
  3094 + initial_session(http_info, _lwa, is_https),
  3095 +
  3096 + out_of_date(previous_session) then
  3097 + //println("previous out_of_date");
  3098 + expired_session(previous_session, http_info, _lwa, is_https),
2709 3099  
  3100 + still_valid(previous_session) then
  3101 + since previous_session is web_session(lang, entries, previous, _),
  3102 + web_session(lang, entries, web_request(http_info, _lwa, is_https), previous)
  3103 + },
  3104 +
  3105 +
  3106 + //apply the action according to current session
  3107 + //since apply_controller_action(get_controller(get_String(lwa, "aws_controller", "root"), *web_controllers), *web_controllers, current_session)
  3108 + since if get_controller(get_String(current_session.web_request.lwa, "aws_controller", "root"), *web_controllers) is
  3109 + {
  3110 + failure then (failure, error_page(http_not_found)),
  3111 + success(new_controller) then apply_controller_action(new_controller, *web_controllers, current_session),
  3112 + }
  3113 + is (mb_new_session, http_answer),
  3114 +
  3115 + //save the session if need and construct the according cookie
  3116 + with cookie_headers =
  3117 + if mb_new_session is
  3118 + {
  3119 + failure then [],
  3120 + success(new_session) then
  3121 + with session_name = save_session(new_session),
  3122 + make_session_cookie_headers(website_name, session_name)
  3123 + },
  3124 +
  3125 + //formatting and send http answer because this is the last function
  3126 + format(info(host_name, http_port, https_port, site_directory, secret),
  3127 + //state_name,
  3128 + additional_headers(mb_new_session) + cookie_headers,
  3129 + http_answer,
  3130 + is_https,
  3131 + charset)
  3132 + ),
  3133 + //
  3134 + // make the delete_out_of_date function
  3135 + //
  3136 + delete_out_of_date =
  3137 + make_delete_out_of_date_sessions_function(site_directory+"/states"),
  3138 + //
  3139 + // construct the web site description
  3140 + //
  3141 + web_site((Word32 http_port, Word32 https_port) |->
  3142 + web_site_description(common_names,
  3143 + site_directory,
  3144 + redirections,
  3145 + charset,
  3146 + journal_extensions,
  3147 + journal_headers,
  3148 + secret,
  3149 + known_mime_types,
  3150 + site_handler(http_port,https_port),
  3151 + (HTTP_Info http_info, List(Web_arg) lwa) |-> unique
  3152 +// if separate_web_args(lwa, http_info ) is
  3153 +// swa(mb_previous_state,mb_action_name,operands) then
  3154 +// if mb_action_name is
  3155 +// {
  3156 +// failure then unique
  3157 +// success(an) then before_send_file(an,operands)
  3158 +// }
  3159 + //using_state_cookies
  3160 + ),
  3161 + delete_out_of_date).
  3162 +
2710 3163  
2711 3164 define String
2712 3165 get_site_uid
... ... @@ -2831,17 +3284,17 @@ public define Start_Web_Sites_Result
2831 3284  
2832 3285  
2833 3286 public define One
2834   - start_web_sites
2835   - (
2836   - Word32 ip_address, // the IP address shared by the web sites
2837   - Word32 http_port, // usually: 80
2838   - Word32 https_port, // usually: 443
2839   - String ssl_certificate_common_name,
2840   - List(Web_Site) web_sites, // web sites to be started
2841   - (One) -> Bool shutdown_required,
2842   - Logger log
2843   - ) =
2844   - if (Start_Web_Sites_Result)start_web_sites(ip_address,
  3287 + start_web_sites
  3288 + (
  3289 + Word32 ip_address, // the IP address shared by the web sites
  3290 + Word32 http_port, // usually: 80
  3291 + Word32 https_port, // usually: 443
  3292 + String ssl_certificate_common_name,
  3293 + List(Web_Site) web_sites, // web sites to be started
  3294 + (One) -> Bool shutdown_required,
  3295 + Logger log //logger where to report the error
  3296 + )=
  3297 + if (Start_Web_Sites_Result)start_web_sites(ip_address,
2845 3298 http_port,
2846 3299 https_port,
2847 3300 ssl_certificate_common_name,
... ... @@ -2899,7 +3352,7 @@ type HTML_Any($T):
2899 3352 any_actioner (Actioner_Connection,
2900 3353 Actioner_Target,
2901 3354 Actioner_Aspect,
2902   - String action_name,
  3355 + WEB_Action_Name action,
2903 3356 List((String,String)) extra_ops,
2904 3357 List(Actioner_Local_Action),
2905 3358 Maybe(String) form_name),
... ... @@ -3095,25 +3548,39 @@ define Int
3095 3548 window.
3096 3549  
3097 3550 define String
3098   - make_actioner_url
3099   - (
3100   - CommonInfo cinfo,
3101   - Actioner_Connection connection,
3102   - Actioner_Target target,
3103   - String state_name,
3104   - String action_name,
3105   - List((String,String)) extra_ops,
3106   - Bool is_https
3107   - ) =
  3551 + make_actioner_url
  3552 + (
  3553 + CommonInfo cinfo,
  3554 + Actioner_Connection connection,
  3555 + Actioner_Target target,
  3556 + WEB_Action_Name action,
  3557 + List((String,String)) extra_ops,
  3558 + Bool is_https
  3559 + ) =
3108 3560 if cinfo is info(common_name,http_port,https_port,site_directory,secret) then
3109 3561 with strict_url =
3110 3562 if connection is
3111 3563 {
3112 3564 same then "/",
3113   - http then "http://"+common_name+":"+http_port+"/",
3114   - https then "https://"+common_name+":"+https_port+"/",
  3565 + http then
  3566 + if http_port = 80 then
  3567 + "http://"+common_name+"/"
  3568 + else
  3569 + "http://"+common_name+":"+http_port+"/",
  3570 + https then
  3571 + if https_port = 443 then
  3572 + "https://"+common_name+"/"
  3573 + else
  3574 + "https://"+common_name+":"+https_port+"/",
3115 3575 } +
3116   - "?a=" + action_name +
  3576 + //with action_string =
  3577 + if action is
  3578 + {
  3579 + controller_action(controller, action_name) then "?aws_controller="+controller+"&amp;aws_action="+action_name,
  3580 + action_name(action_name) then "?aws_action="+action_name
  3581 + }
  3582 + //"?a=" + action_name +
  3583 + +
3117 3584 format_extra_operands(extra_ops),
3118 3585 if target is
3119 3586 {
... ... @@ -3535,7 +4002,7 @@ define Printable_tree
3535 4002 String url,
3536 4003 Bool is_https,
3537 4004 CommonInfo cinfo,
3538   - String state_name,
  4005 +// String state_name,
3539 4006 Var(Int) action_count,
3540 4007 Var(Int) ic_v, // 'idnum' counter variable
3541 4008 Var(List(HTML_Head_Tag)) head_tags
... ... @@ -3578,7 +4045,7 @@ define Printable_tree
3578 4045 html(html_off_form) then
3579 4046 [
3580 4047 "<a href=\"", full_url, "\">",
3581   - format(cinfo, state_name, ic_v, html_off_form, is_https, action_count, head_tags),
  4048 + format(cinfo, ic_v, html_off_form, is_https, action_count, head_tags),
3582 4049 "</a>"
3583 4050 ]
3584 4051 }.
... ... @@ -3587,11 +4054,10 @@ define Printable_tree
3587 4054 format_actioner
3588 4055 (
3589 4056 CommonInfo cinfo,
3590   - String state_name,
3591 4057 Actioner_Connection connection,
3592 4058 Actioner_Target target,
3593 4059 Actioner_Aspect aspect,
3594   - String action_name,
  4060 + WEB_Action_Name action,
3595 4061 List((String,String)) extra_ops,
3596 4062 List(Actioner_Local_Action) local_actions,
3597 4063 Maybe(String) mb_form_name,
... ... @@ -3604,8 +4070,8 @@ define Printable_tree
3604 4070  
3605 4071 if cinfo is info(common_name,http_port,https_port,site_dir,secret) then
3606 4072 with url = make_actioner_url(cinfo,connection,target,
3607   - state_name,action_name,extra_ops,is_https),
3608   - with action = format_action(url, aspect, extract_id(aspect), mb_form_name, action_count),
  4073 + action,extra_ops,is_https),
  4074 + with formatted_action = format_action(url, aspect, extract_id(aspect), mb_form_name, action_count),
3609 4075 if aspect is
3610 4076 {
3611 4077  
... ... @@ -3618,6 +4084,10 @@ define Printable_tree
3618 4084 ],
3619 4085 img_link(options, img, alt_text) then
3620 4086 //if action name is empty, format options on image because maybe there onclick action
  4087 + with action_name = if action is {
  4088 + controller_action(_, an) then an,
  4089 + action_name(an) then an
  4090 + },
3621 4091 if action_name ="" then
3622 4092 [
3623 4093 "<img src=\"", img,"\"",
... ... @@ -3630,12 +4100,18 @@ define Printable_tree
3630 4100 ],
3631 4101 push_button(options, text) then
3632 4102 [
3633   - if action is
  4103 + if formatted_action is
3634 4104 {
3635 4105 url(u) then ["<a href=\"",u,"\"", format_attrs(options), ">",
3636 4106 text, "</a>"
3637 4107 ],
3638 4108 javascript(s,h) then
  4109 + with action_name =
  4110 + if action is
  4111 + {
  4112 + controller_action(_, an) then an,
  4113 + action_name(an) then an
  4114 + },
3639 4115 if action_name = "" then
3640 4116 ["<input type=\"button\" value=\"",text,"\"", format_attrs(options), " />"]
3641 4117 else
... ... @@ -3643,7 +4119,7 @@ define Printable_tree
3643 4119 }
3644 4120 ],
3645 4121 button(url_off,url_on) then
3646   - [ if action is
  4122 + [ if formatted_action is
3647 4123 {
3648 4124 url(u) then ["<a href=\"",u],
3649 4125 javascript(s,h) then [s,"<a onMouseDown=\"",h]
... ... @@ -3656,7 +4132,7 @@ define Printable_tree
3656 4132 ],
3657 4133  
3658 4134 button(url_off,url_on,w,h) then
3659   - [ if action is
  4135 + [ if formatted_action is
3660 4136 {
3661 4137 url(u) then ["<a href=\"",u],
3662 4138 javascript(s,h2) then [s,"<a onMouseDown=\"",h2]
... ... @@ -3670,12 +4146,16 @@ define Printable_tree
3670 4146  
3671 4147 submit(options, text) then
3672 4148 [
3673   - if action is
  4149 + if formatted_action is
3674 4150 {
3675 4151 url(u) then ["<a href=\"",u,"\"", format_attrs(options), ">",
3676 4152 text, "</a>"
3677 4153 ],
3678 4154 javascript(s,h) then
  4155 + with action_name = if action is {
  4156 + controller_action(_, an) then an,
  4157 + action_name(an) then an
  4158 + },
3679 4159 if action_name = "" then // special case where URL (so the action_name) is provided by the form itself
3680 4160 // so javascript isn't needed. This is the standard HMTL way.
3681 4161 ["<input type=\"submit\" value=\"",text,"\"", format_attrs(options), " />"]
... ... @@ -3697,7 +4177,7 @@ define Printable_tree
3697 4177 [
3698 4178 //if custom function name is provided, that name is used instead of autogenerated js function
3699 4179 if custom_function_name = "" then
3700   - if action is
  4180 + if formatted_action is
3701 4181 {
3702 4182 url(u) then ["<select href=\"",u]
3703 4183 javascript(s,h) then [s,"<select onchange=\"",h]
... ... @@ -3711,7 +4191,7 @@ define Printable_tree
3711 4191 html(html_off_form) then
3712 4192 [
3713 4193 "<a href=\"", url, "\">",
3714   - format(cinfo, state_name, ic_v, html_off_form, is_https, action_count, head_tags),
  4194 + format(cinfo, ic_v, html_off_form, is_https, action_count, head_tags),
3715 4195 "</a>"
3716 4196 ]
3717 4197 }.
... ... @@ -3730,19 +4210,17 @@ define Printable_tree
3730 4210  
3731 4211  
3732 4212 define Printable_tree
3733   - format_private_download
3734   - (
3735   - CommonInfo cinfo,
3736   - String sn, // state name
3737   - String abs_path, // absolute file path on server
3738   - String name, // name of file as it appears in the browser
3739   - String extra, // extra extension
3740   - Maybe((String,List((String,String)))) action
3741   -
3742   - ) =
3743   - if cinfo is info(common_name,http_port,https_port,site_directory,secret) then
3744   - with private_download_directory = site_directory+"/private_download",
3745   - with auth = make_authorization(site_directory,secret,abs_path),
  4213 + format_private_download
  4214 + (
  4215 + CommonInfo cinfo,
  4216 + String abs_path, // absolute file path on server
  4217 + String name, // name of file as it appears in the browser
  4218 + String extra, // extra extension
  4219 + Maybe((String,List((String,String)))) action
  4220 + ) =
  4221 + if cinfo is info(common_name,http_port,https_port,site_directory,secret) then
  4222 + with private_download_directory = site_directory+"/private_download",
  4223 + with auth = make_authorization(site_directory,secret,abs_path),
3746 4224 [
3747 4225 "<a href=\"",name,extra,"?zauth=",auth,
3748 4226 if action is
... ... @@ -3756,9 +4234,6 @@ define Printable_tree
3756 4234 "</a>"
3757 4235 ].
3758 4236  
3759   -
3760   -
3761   -
3762 4237 *** [5.6] Formating rows and cells in a table.
3763 4238  
3764 4239 define Int
... ... @@ -4034,7 +4509,6 @@ define String
4034 4509 define Printable_tree
4035 4510 format_scroller
4036 4511 (
4037   - String sn,
4038 4512 Int width,
4039 4513 Int height,
4040 4514 Int content_width,
... ... @@ -4208,7 +4682,6 @@ define Printable_tree
4208 4682 format
4209 4683 (
4210 4684 CommonInfo cinfo,
4211   - String sn, // state_name
4212 4685 Var(Int) ic_v,
4213 4686 HTML_Any($T) element,
4214 4687 $T -> Printable_tree format_element, // able to format a datum of type $T
... ... @@ -4246,9 +4719,9 @@ define Printable_tree
4246 4719 any_mail_to(email,elem) then
4247 4720 ["<a href=\"mailto:",email,"\">",format_element(elem),"</a>"],
4248 4721 any_scroller(w,h,cw,ch,c) then
4249   - format_scroller(sn,w,h,cw,ch,new_idnum(ic_v),c,format_element),
  4722 + format_scroller(w,h,cw,ch,new_idnum(ic_v),c,format_element),
4250 4723 any_fixed_size(w,h,c) then
4251   - with url = create_secondary_document(site_directory,secret,sn,format_element,c,w),
  4724 + with url = create_secondary_document(site_directory,secret,format_element,c,w),
4252 4725 ["<object data=\"",url,"\" type=\"text/html\" width=\"",format(w),"\" height=\"",format(h),"\" >",
4253 4726 "secondary document",
4254 4727 "</object>"],
... ... @@ -4259,17 +4732,17 @@ define Printable_tree
4259 4732 "secondary document",
4260 4733 "</object>"],
4261 4734 any_actioner(c,t,a,an,eo,ja,fn) then
4262   - format_actioner(cinfo,sn,c,t,a,an,eo,ja,fn,is_https, action_count, ic_v, head_tags),
  4735 + format_actioner(cinfo,c,t,a,an,eo,ja,fn,is_https, action_count, ic_v, head_tags),
4263 4736  
4264 4737 any_foreign_link_new(target, aspect, url) then
4265   - format_foreign_link(target, aspect, url, is_https, cinfo, sn, action_count, ic_v, head_tags),
  4738 + format_foreign_link(target, aspect, url, is_https, cinfo, action_count, ic_v, head_tags),
4266 4739  
4267 4740 any_foreign_link(options,url) then
4268 4741 ["<a href=\"",url,"\" ", format_text_options(options), "></a>"], // IE7 doesn't support the form <a href="..." />
4269 4742 any_foreign_link(options,url,name) then
4270 4743 ["<a href=\"",url,"\"><span ", format_text_options(options), ">",name,"</span></a>"],
4271 4744 any_private_download(url,name,extra_ext,action) then
4272   - format_private_download(cinfo,sn,url,name,extra_ext,action),
  4745 + format_private_download(cinfo,url,name,extra_ext,action),
4273 4746 any_div(options, e) then
4274 4747 [format_div_option(options), format_element(e),"</div>\n"],
4275 4748 any_div_empty(options) then
... ... @@ -4407,7 +4880,6 @@ define Printable_tree
4407 4880 (
4408 4881 CommonInfo cinfo,
4409 4882 String fn, // form_name
4410   - String sn, // state_name
4411 4883 Var(Int) ic_v, // idnum counter variable
4412 4884 HTML_In_Form element,
4413 4885 Bool is_https,
... ... @@ -4415,7 +4887,7 @@ define Printable_tree
4415 4887 Var(List(HTML_Head_Tag)) head_tags
4416 4888 ) =
4417 4889 if cinfo is info(common_name,http_port,https_port,site_directory,secret) then
4418   - with format_element = (HTML_In_Form e) |-> format(cinfo, fn, sn, ic_v, e, is_https, action_count, head_tags),
  4890 + with format_element = (HTML_In_Form e) |-> format(cinfo, fn, ic_v, e, is_https, action_count, head_tags),
4419 4891 if element is
4420 4892 {
4421 4893 empty then [],
... ... @@ -4423,35 +4895,35 @@ define Printable_tree
4423 4895 literal(t) then [t],
4424 4896 sequence(l) then flat(map(format_element,l))
4425 4897 text(opts,t) then
4426   - format(cinfo,sn,ic_v,any_text(opts,t),format_element,is_https, action_count, head_tags),
  4898 + format(cinfo,ic_v,any_text(opts,t),format_element,is_https, action_count, head_tags),
4427 4899 preformated(o,s) then
4428   - format(cinfo,sn,ic_v,any_preformated(o,s),format_element,is_https, action_count, head_tags),
  4900 + format(cinfo,ic_v,any_preformated(o,s),format_element,is_https, action_count, head_tags),
4429 4901 paragraph(opts,t) then
4430   - format(cinfo,sn,ic_v,any_paragraph(opts,t),format_element,is_https, action_count, head_tags),
  4902 + format(cinfo,ic_v,any_paragraph(opts,t),format_element,is_https, action_count, head_tags),
4431 4903 image(opts, url, alt) then
4432   - format(cinfo,sn,ic_v,any_image(opts, url, alt),format_element,is_https, action_count, head_tags),
  4904 + format(cinfo,ic_v,any_image(opts, url, alt),format_element,is_https, action_count, head_tags),
4433 4905 image(opts, url, alt, w, h) then
4434   - format(cinfo,sn,ic_v,any_image(opts, url, alt, w, h),format_element,is_https, action_count, head_tags),
  4906 + format(cinfo,ic_v,any_image(opts, url, alt, w, h),format_element,is_https, action_count, head_tags),
4435 4907 table(opts,header_row,rows,footer_row) then
4436   - format(cinfo,sn,ic_v,any_table(opts, header_row, rows, footer_row),format_element,is_https, action_count, head_tags),
  4908 + format(cinfo,ic_v,any_table(opts, header_row, rows, footer_row),format_element,is_https, action_count, head_tags),
4437 4909 center(e) then
4438   - format(cinfo,sn,ic_v,any_center(e),format_element,is_https, action_count, head_tags),
  4910 + format(cinfo,ic_v,any_center(e),format_element,is_https, action_count, head_tags),
4439 4911 mail_to(a,e) then
4440   - format(cinfo,sn,ic_v,any_mail_to(a,e),format_element,is_https, action_count, head_tags),
  4912 + format(cinfo,ic_v,any_mail_to(a,e),format_element,is_https, action_count, head_tags),
4441 4913 scroller(w,h,cw,ch,c) then
4442   - format(cinfo,sn,ic_v,any_scroller(w,h,cw,ch,c),format_element,is_https, action_count, head_tags),
  4914 + format(cinfo,ic_v,any_scroller(w,h,cw,ch,c),format_element,is_https, action_count, head_tags),
4443 4915 actioner(c,t,a,an,eo,ja) then
4444   - format(cinfo,sn,ic_v,any_actioner(c,t,a,an,eo,ja,success(fn)),format_element,is_https, action_count, head_tags),
  4916 + format(cinfo,ic_v,any_actioner(c,t,a,an,eo,ja,success(fn)),format_element,is_https, action_count, head_tags),
4445 4917  
4446 4918 foreign_link_new(target, aspect, url) then
4447   - format(cinfo,sn,ic_v,any_foreign_link_new(target,aspect,url),format_element,is_https, action_count, head_tags),
  4919 + format(cinfo,ic_v,any_foreign_link_new(target,aspect,url),format_element,is_https, action_count, head_tags),
4448 4920  
4449 4921 foreign_link(options,url) then
4450   - format(cinfo,sn,ic_v,any_foreign_link(options,url),format_element,is_https, action_count, head_tags),
  4922 + format(cinfo,ic_v,any_foreign_link(options,url),format_element,is_https, action_count, head_tags),
4451 4923 foreign_link(options,url,name) then
4452   - format(cinfo,sn,ic_v,any_foreign_link(options,url,name),format_element,is_https, action_count, head_tags),
  4924 + format(cinfo,ic_v,any_foreign_link(options,url,name),format_element,is_https, action_count, head_tags),
4453 4925 private_download(url,name,extra,action) then
4454   - format(cinfo,sn,ic_v,any_private_download(url,name,extra,action),format_element,is_https, action_count, head_tags),
  4926 + format(cinfo,ic_v,any_private_download(url,name,extra,action),format_element,is_https, action_count, head_tags),
4455 4927 text_input(options, label_text, id, name, i, w) then
4456 4928 [ format_label(label_text, id),
4457 4929 "<input type=\"text\" name=\"",name,"\" id=\"",id,"\" size=\"",w,"\" value=\"",i,"\"",format_attrs([class("in") . options])," />"],
... ... @@ -4492,9 +4964,9 @@ define Printable_tree
4492 4964 [ "<input type=\"checkbox\" name=\"",n,"\" id=\"",id,"\" value=\"",v,"\"",(if c then " checked=\"checked\" " else ""),format_attrs([class("in") . options])," />",
4493 4965 format_label(label, id)]
4494 4966 div(options, e) then
4495   - format(cinfo,sn,ic_v,any_div(options, e),format_element,is_https, action_count, head_tags),
  4967 + format(cinfo,ic_v,any_div(options, e),format_element,is_https, action_count, head_tags),
4496 4968 div_empty(options) then
4497   - format(cinfo,sn,ic_v,any_div_empty(options),format_element,is_https, action_count, head_tags),
  4969 + format(cinfo,ic_v,any_div_empty(options),format_element,is_https, action_count, head_tags),
4498 4970 hidden(_id, name, value) then
4499 4971 since _id is html_Id(id),
4500 4972 ["<input type=\"hidden\"",(if id = "" then "" else " id=\""+id+"\"")," name=\"",name,"\" value=\"",value,"\" />"],
... ... @@ -4502,17 +4974,17 @@ define Printable_tree
4502 4974 if p_content is partial_content(tags, html_elements) then
4503 4975 head_tags <- *head_tags + tags;
4504 4976  
4505   - format(cinfo, sn, ic_v, html_elements, is_https, action_count, head_tags),
  4977 + format(cinfo, ic_v, html_elements, is_https, action_count, head_tags),
4506 4978 br then ["<br>"],
4507 4979 progress(options, value, max) then ["<progress max=\"",value,"\" value=\"",max,"\"",format_attrs(options),"></progress>"],
4508 4980 ol(opts, t) then
4509   - format(cinfo,sn,ic_v,any_ol(opts,t),format_element,is_https, action_count, head_tags),
  4981 + format(cinfo,ic_v,any_ol(opts,t),format_element,is_https, action_count, head_tags),
4510 4982 ul(opts, t) then
4511   - format(cinfo,sn,ic_v,any_ul(opts,t),format_element,is_https, action_count, head_tags),
  4983 + format(cinfo,ic_v,any_ul(opts,t),format_element,is_https, action_count, head_tags),
4512 4984 li(opts, t) then
4513   - format(cinfo,sn,ic_v,any_li(opts,t),format_element,is_https, action_count, head_tags),
  4985 + format(cinfo,ic_v,any_li(opts,t),format_element,is_https, action_count, head_tags),
4514 4986 button(options, e) then
4515   - format(cinfo,sn,ic_v,any_button(options, e),format_element,is_https, action_count, head_tags),
  4987 + format(cinfo,ic_v,any_button(options, e),format_element,is_https, action_count, head_tags),
4516 4988 }.
4517 4989  
4518 4990  
... ... @@ -4618,7 +5090,6 @@ define Printable_tree
4618 5090 format
4619 5091 (
4620 5092 CommonInfo cinfo,
4621   - String sn, // state_name
4622 5093 Var(Int) ic_v, // 'idnum' counter variable
4623 5094 HTML_Off_Form element,
4624 5095 Bool is_https,
... ... @@ -4626,7 +5097,7 @@ define Printable_tree
4626 5097 Var(List(HTML_Head_Tag)) head_tags
4627 5098 ) =
4628 5099 if cinfo is info(common_name,http_port,https_port,site_directory,secret) then
4629   - with format_element = (HTML_Off_Form e) |-> format(cinfo, sn, ic_v, e, is_https, action_count, head_tags),
  5100 + with format_element = (HTML_Off_Form e) |-> format(cinfo, ic_v, e, is_https, action_count, head_tags),
4630 5101 if element is
4631 5102 {
4632 5103 empty then [],
... ... @@ -4634,44 +5105,44 @@ define Printable_tree
4634 5105 literal(t) then [t],
4635 5106 sequence(l) then flat(map(format_element,l)),
4636 5107 text(opts,t) then
4637   - format(cinfo,sn,ic_v,any_text(opts,t),format_element,is_https, action_count, head_tags),
  5108 + format(cinfo,ic_v,any_text(opts,t),format_element,is_https, action_count, head_tags),
4638 5109 preformated(o,s) then
4639   - format(cinfo,sn,ic_v,any_preformated(o,s),format_element,is_https, action_count, head_tags),
  5110 + format(cinfo,ic_v,any_preformated(o,s),format_element,is_https, action_count, head_tags),
4640 5111 paragraph(opts,t) then
4641   - format(cinfo,sn,ic_v,any_paragraph(opts,t),format_element,is_https, action_count, head_tags),
  5112 + format(cinfo,ic_v,any_paragraph(opts,t),format_element,is_https, action_count, head_tags),
4642 5113 image(opts,url,alt) then
4643   - format(cinfo,sn,ic_v,any_image(opts,url,alt),format_element,is_https, action_count, head_tags),
  5114 + format(cinfo,ic_v,any_image(opts,url,alt),format_element,is_https, action_count, head_tags),
4644 5115 image(opts,url,alt,w,h) then
4645   - format(cinfo,sn,ic_v,any_image(opts,url,alt,w,h),format_element,is_https, action_count, head_tags),
  5116 + format(cinfo,ic_v,any_image(opts,url,alt,w,h),format_element,is_https, action_count, head_tags),
4646 5117 table(opts,header_row, rows, footer_row) then
4647   - format(cinfo,sn,ic_v,any_table(opts,header_row, rows, footer_row),format_element,is_https, action_count, head_tags),
  5118 + format(cinfo,ic_v,any_table(opts,header_row, rows, footer_row),format_element,is_https, action_count, head_tags),
4648 5119 center(e) then
4649   - format(cinfo,sn,ic_v,any_center(e),format_element,is_https, action_count, head_tags),
  5120 + format(cinfo,ic_v,any_center(e),format_element,is_https, action_count, head_tags),
4650 5121 mail_to(a,e) then
4651   - format(cinfo,sn,ic_v,any_mail_to(a,e),format_element,is_https, action_count, head_tags),
  5122 + format(cinfo,ic_v,any_mail_to(a,e),format_element,is_https, action_count, head_tags),
4652 5123 scroller(w,h,cw,ch,c) then
4653   - format(cinfo,sn,ic_v,any_scroller(w,h,cw,ch,c),format_element,is_https, action_count, head_tags),
  5124 + format(cinfo,ic_v,any_scroller(w,h,cw,ch,c),format_element,is_https, action_count, head_tags),
4654 5125 fixed_size(w,h,c) then
4655   - format(cinfo,sn,ic_v,any_fixed_size(w,h,c),format_element,is_https, action_count, head_tags),
  5126 + format(cinfo,ic_v,any_fixed_size(w,h,c),format_element,is_https, action_count, head_tags),
4656 5127 fixed_size_2(w,h,fn) then
4657   - format(cinfo,sn,ic_v,any_fixed_size_2(w,h,fn),format_element,is_https, action_count, head_tags),
  5128 + format(cinfo,ic_v,any_fixed_size_2(w,h,fn),format_element,is_https, action_count, head_tags),
4658 5129 actioner(c,t,a,an,eo,ja) then
4659   - format(cinfo,sn,ic_v,any_actioner(c,t,a,an,eo,ja,failure),format_element,is_https, action_count, head_tags),
  5130 + format(cinfo,ic_v,any_actioner(c,t,a,an,eo,ja,failure),format_element,is_https, action_count, head_tags),
4660 5131 actioner(c,t,a,an,eo,ja,fn) then
4661   - format(cinfo,sn,ic_v,any_actioner(c,t,a,an,eo,ja,success(fn)),format_element,is_https, action_count, head_tags),
  5132 + format(cinfo,ic_v,any_actioner(c,t,a,an,eo,ja,success(fn)),format_element,is_https, action_count, head_tags),
4662 5133 foreign_link_new(target, aspect, url) then
4663   - format(cinfo,sn,ic_v,any_foreign_link_new(target,aspect,url),format_element,is_https, action_count, head_tags),
  5134 + format(cinfo,ic_v,any_foreign_link_new(target,aspect,url),format_element,is_https, action_count, head_tags),
4664 5135 foreign_link(options,url) then
4665   - format(cinfo,sn,ic_v,any_foreign_link(options,url),format_element,is_https, action_count, head_tags),
  5136 + format(cinfo,ic_v,any_foreign_link(options,url),format_element,is_https, action_count, head_tags),
4666 5137 foreign_link(options,url,name) then
4667   - format(cinfo,sn,ic_v,any_foreign_link(options,url,name),format_element,is_https, action_count, head_tags),
  5138 + format(cinfo,ic_v,any_foreign_link(options,url,name),format_element,is_https, action_count, head_tags),
4668 5139 private_download(url,name,extra,action) then
4669   - format(cinfo,sn,ic_v,any_private_download(url,name,extra,action),format_element,is_https, action_count, head_tags),
  5140 + format(cinfo,ic_v,any_private_download(url,name,extra,action),format_element,is_https, action_count, head_tags),
4670 5141 label(n) then ["<a name=\"",n,"\">"],
4671 5142 form(fn,attributs, c) then
4672 5143 [
4673 5144 "<form id=\"",fn,"\"",
4674   - format(cinfo,sn,ic_v,any_coreattrs(attributs),format_element,is_https, action_count, head_tags),
  5145 + format(cinfo,ic_v,any_coreattrs(attributs),format_element,is_https, action_count, head_tags),
4675 5146 " method=\"post\"",
4676 5147 enctype(c),
4677 5148 " action=\"http",
... ... @@ -4680,15 +5151,15 @@ define Printable_tree
4680 5151 // action is set dynamically by
4681 5152 // the actioner using JavaScript
4682 5153 if fn is html_Id(id) then
4683   - format(cinfo,id,sn,ic_v,c,is_https, action_count, head_tags),
  5154 + format(cinfo,id,ic_v,c,is_https, action_count, head_tags),
4684 5155 "</form>"
4685 5156 ]
4686   - form(fn,attributs, action_name, extra_ops, c) then
  5157 + form(fn,attributs, action, extra_ops, c) then
4687 5158 with url = make_actioner_url(cinfo, same, same,
4688   - sn, action_name, extra_ops, is_https),
  5159 + action, extra_ops, is_https),
4689 5160 [
4690 5161 "<form id=\"",fn,"\"",
4691   - format(cinfo,sn,ic_v,any_coreattrs(attributs),format_element,is_https, action_count, head_tags),
  5162 + format(cinfo,ic_v,any_coreattrs(attributs),format_element,is_https, action_count, head_tags),
4692 5163 " method=\"post\"",
4693 5164 enctype(c),
4694 5165 " action=\"" + url + "\">",
... ... @@ -4698,20 +5169,20 @@ define Printable_tree
4698 5169 // action is set dynamically by
4699 5170 // the actioner using JavaScript
4700 5171 if fn is html_Id(id) then
4701   - format(cinfo,id,sn,ic_v,c,is_https, action_count, head_tags),
  5172 + format(cinfo,id,ic_v,c,is_https, action_count, head_tags),
4702 5173 "</form>"
4703 5174 ],
4704 5175 in_form(fn, content) then
4705 5176 if fn is html_Id(id) then
4706   - format(cinfo,id,sn,ic_v, content,is_https, action_count, head_tags),
  5177 + format(cinfo,id,ic_v, content,is_https, action_count, head_tags),
4707 5178 div(options, e) then
4708   - format(cinfo, sn, ic_v, any_div(options, e), format_element, is_https, action_count, head_tags),
  5179 + format(cinfo, ic_v, any_div(options, e), format_element, is_https, action_count, head_tags),
4709 5180 div(options, p_content) then
4710 5181 if p_content is partial_content(tags, html_elements) then
4711 5182 head_tags <- *head_tags +tags;
4712   - format(cinfo, sn, ic_v, any_div(options, html_elements), format_element, is_https, action_count, head_tags),
  5183 + format(cinfo, ic_v, any_div(options, html_elements), format_element, is_https, action_count, head_tags),
4713 5184 div_empty(options) then
4714   - format(cinfo, sn, ic_v, any_div_empty(options), format_element, is_https, action_count, head_tags),
  5185 + format(cinfo, ic_v, any_div_empty(options), format_element, is_https, action_count, head_tags),
4715 5186 iframe(options, css_styles, css_files, js_files, body) then
4716 5187 if body is body(body_options,elem) then
4717 5188 [ "<iframe", format_attrs(options), ">\n",
... ... @@ -4722,7 +5193,7 @@ define Printable_tree
4722 5193 add_js_files(js_files),
4723 5194 "</head>\n",
4724 5195 "<body ", format(body_options), ">\n", // format body options
4725   - format(cinfo,sn,ic_v,elem,is_https, action_count, head_tags),
  5196 + format(cinfo,ic_v,elem,is_https, action_count, head_tags),
4726 5197 "</body>\n",
4727 5198 "</html>\n",
4728 5199 "</iframe>\n",
... ... @@ -4730,17 +5201,17 @@ define Printable_tree
4730 5201 partial(p_content) then
4731 5202 if p_content is partial_content(tags, html_elements) then
4732 5203 head_tags <- *head_tags + tags;
4733   - format(cinfo, sn, ic_v, html_elements, is_https, action_count, head_tags),
  5204 + format(cinfo, ic_v, html_elements, is_https, action_count, head_tags),
4734 5205 br then ["<br>"],
4735 5206 progress(options, value, max) then ["<progress max=\"",value,"\" value=\"",max,"\"",format_attrs(options),"></progress>"],
4736 5207 ol(opts, t) then
4737   - format(cinfo,sn,ic_v,any_ol(opts,t),format_element,is_https, action_count, head_tags),
  5208 + format(cinfo,ic_v,any_ol(opts,t),format_element,is_https, action_count, head_tags),
4738 5209 ul(opts, t) then
4739   - format(cinfo,sn,ic_v,any_ul(opts,t),format_element,is_https, action_count, head_tags),
  5210 + format(cinfo,ic_v,any_ul(opts,t),format_element,is_https, action_count, head_tags),
4740 5211 li(opts, t) then
4741   - format(cinfo,sn,ic_v,any_li(opts,t),format_element,is_https, action_count, head_tags),
  5212 + format(cinfo,ic_v,any_li(opts,t),format_element,is_https, action_count, head_tags),
4742 5213 button(options, e) then
4743   - format(cinfo, sn, ic_v, any_button(options, e), format_element, is_https, action_count, head_tags),
  5214 + format(cinfo, ic_v, any_button(options, e), format_element, is_https, action_count, head_tags),
4744 5215 }.
4745 5216  
4746 5217  
... ... @@ -4763,29 +5234,29 @@ define Printable_tree
4763 5234  
4764 5235  
4765 5236 define Printable_tree
4766   - format
4767   - (
4768   - CommonInfo cinfo,
4769   - String state_name,
4770   - HTML_Meta m,
4771   - Bool is_https
4772   - ) =
4773   - if m is
4774   - {
4775   - keywords(l) then ["<meta name=\"keywords\" content=\"",format_keywords(l),"\" />\n"],
4776   - refresh(co,ta,an,delay) then
  5237 + format
  5238 + (
  5239 + CommonInfo cinfo,
  5240 + HTML_Meta m,
  5241 + Bool is_https
  5242 + ) =
  5243 + if m is
  5244 + {
  5245 + keywords(l) then ["<meta name=\"keywords\" content=\"",format_keywords(l),"\" />\n"],
  5246 + refresh(co,ta,an,delay) then
4777 5247 ["<meta http-equiv=\"Refresh\" content=\"",delay,"; URL=",
4778   - make_actioner_url(cinfo,co,ta,state_name,an,[],is_https),"\" />\n"],
4779   - refresh(url,delay) then
  5248 + make_actioner_url(cinfo,co,ta,an,[],is_https),"\" />\n"],
  5249 + refresh(url,delay) then
4780 5250 ["<meta http-equiv=\"Refresh\" content=\"",delay,"; URL=",url,"\" />\n"],
4781   - meta(n,c) then ["<meta name=\"",n,"\" content=\"",c,"\" />\n"],
4782   - http_equiv(n,c) then ["<meta http-equiv=\"",n,"\" content=\"",c,"\" />\n"],
4783   - generic_meta(l) then ["<meta ",
  5251 + meta(n,c) then ["<meta name=\"",n,"\" content=\"",c,"\" />\n"],
  5252 + http_equiv(n,c) then ["<meta http-equiv=\"",n,"\" content=\"",c,"\" />\n"],
  5253 + generic_meta(l) then ["<meta ",
4784 5254 flat(map(((String,String) p) |-> if p is (n,v) then [n,"=\"",v,"\" "],
4785 5255 l)),
4786 5256 " />\n"],
4787   - literal(s) then [s]
4788   - }.
  5257 + literal(s) then [s]
  5258 + }
  5259 +.
4789 5260  
4790 5261 define Printable_tree // c'est le nôtre et c'est meilleur
4791 5262 format
... ... @@ -4812,18 +5283,17 @@ define Printable_tree // c&#39;est le nôtre et c&#39;est meilleur
4812 5283 define Printable_tree
4813 5284 format
4814 5285 (
4815   - CommonInfo cinfo,
4816   - String state_name,
  5286 + CommonInfo cinfo,
4817 5287 List(HTML_Meta) metas,
4818 5288 Bool is_https,
4819 5289 String charset
4820 5290 ) =
4821 5291 if metas is
4822 5292 {
4823   - [] then [format(cinfo,state_name,http_equiv("content-type",
  5293 + [] then [format(cinfo,http_equiv("content-type",
4824 5294 "text/html; charset="+charset),is_https)],
4825   - [h . t] then [format(cinfo,state_name,h,is_https)
4826   - . format(cinfo,state_name,t,is_https,charset)]
  5295 + [h . t] then [format(cinfo,h,is_https)
  5296 + . format(cinfo,t,is_https,charset)]
4827 5297 }.
4828 5298  
4829 5299 define List(HTML_Head_Tag)
... ... @@ -4932,33 +5402,26 @@ public define HTML_ajax_content
4932 5402 to_html_ajax_content
4933 5403 (
4934 5404 HTML_Off_Form content_HTML,
4935   - CommonInfo cinfo,
4936   - String state_name
  5405 + CommonInfo cinfo
4937 5406 )=
4938 5407 with p_content_head_tags = var((List(HTML_Head_Tag))[]),
4939   - with content = format(cinfo, state_name, var((Int)0), content_HTML, false, var(0), p_content_head_tags),
  5408 + with content = format(cinfo, var((Int)0), content_HTML, false, var(0), p_content_head_tags),
4940 5409 if sort_head_tag(*p_content_head_tags, "", [], []) is html_ajax_content(_, script, js_file, css_file) then
4941 5410 html_ajax_content(to_String(content), script, js_file, css_file).
4942 5411  
4943   -public define HTML_ajax_content
4944   - to_html_ajax_content
4945   - (
4946   - HTML_Off_Form content_HTML,
4947   - CommonInfo cinfo
4948   - )= to_html_ajax_content(content_HTML, cinfo, "").
4949 5412  
4950 5413 public define HTML_ajax_content
4951 5414 to_html_ajax_content
4952 5415 (
4953 5416 HTML_Partial_Content content_HTML,
4954 5417 CommonInfo cinfo
4955   - )= to_html_ajax_content(partial(content_HTML), cinfo, "").
  5418 + )= to_html_ajax_content(partial(content_HTML), cinfo).
4956 5419  
4957 5420 public define Printable_tree
4958 5421 format
4959 5422 (
4960 5423 CommonInfo cinfo,
4961   - String state_name,
  5424 + //String state_name,
4962 5425 List(HTTP_header) additional_headers,
4963 5426 HTTP_Answer page,
4964 5427 Bool is_https,
... ... @@ -4975,7 +5438,7 @@ public define Printable_tree
4975 5438 with
4976 5439 answer_body_body = (Printable_tree)
4977 5440 [ "<body ", format(options), ">", // format body options
4978   - format(cinfo,state_name,ic_v,element,is_https, var(0), p_content_head_tags),
  5441 + format(cinfo,ic_v,element,is_https, var(0), p_content_head_tags),
4979 5442 "</body>\n",
4980 5443  
4981 5444 "</html>"],
... ... @@ -4998,7 +5461,14 @@ public define Printable_tree
4998 5461 html_page(status, title, metas, css_styles, css_files, js_files, script, body) then
4999 5462 if body is body(options,element) then
5000 5463 if format(status) is (status_string, status_headers) then
5001   - with answer_body =
  5464 + with
  5465 + answer_body_body = (Printable_tree)
  5466 + [ "<body ", format(options), ">", // format body options
  5467 + format(cinfo,ic_v,element,is_https, var(0), p_content_head_tags),
  5468 + "</body>\n",
  5469 + "</html>"
  5470 + ],
  5471 + answer_body_header =
5002 5472 [ doctype_w3c_header,
5003 5473 //html_header,
5004 5474 "<head>\n",
... ... @@ -5019,22 +5489,19 @@ public define Printable_tree
5019 5489 " { s[0]=0; d.style.visibility = 'hidden'; }; }",
5020 5490 "</script>\n",
5021 5491 "<title>",title,"</title>\n", // put title
5022   - format(cinfo,state_name,metas,is_https,charset), // format the metas
5023   - "</head>\n",
5024   - "<body ", format(options), ">", // format body options
5025   - //"<center>",
5026   - format(cinfo,state_name,ic_v,element,is_https, var(0), p_content_head_tags),
5027   - //"</center>",
5028   - "</body>\n",
5029   - "</html>"
5030   - ],
  5492 + format(cinfo,metas,is_https,charset), // format the metas
  5493 + format_html_head(*p_content_head_tags, charset),
  5494 + "</head>\n"
  5495 + ],
  5496 +
5031 5497 [ "HTTP/1.1 " + status_string, crlf,
5032 5498 format_headers(standard_headers),
5033   - format_headers(standard_headers_for("text/html", length(answer_body), success(charset))),
  5499 + format_headers(standard_headers_for("text/html", length(answer_body_header) + length(answer_body_body), success(charset))),
5034 5500 format_headers(status_headers),
5035 5501 format_headers(additional_headers),
5036   - crlf
5037   - . answer_body
  5502 + crlf,
  5503 + answer_body_header .
  5504 + answer_body_body
5038 5505 ],
5039 5506  
5040 5507 plain_text (HTTP_Status status, String text) then
... ... @@ -5097,7 +5564,7 @@ public define Printable_tree
5097 5564  
5098 5565 html_content(HTTP_Status status, HTML_Off_Form content_HTML) then
5099 5566 if format(status) is (status_string, status_headers) then
5100   - with content = format(cinfo, state_name, ic_v, content_HTML, is_https, var(0), p_content_head_tags),
  5567 + with content = format(cinfo, ic_v, content_HTML, is_https, var(0), p_content_head_tags),
5101 5568 [ "HTTP/1.1 " + status_string, crlf,
5102 5569 format_headers(standard_headers),
5103 5570 format_headers(standard_headers_for("text/html", length(content), success(charset))),
... ... @@ -5114,7 +5581,7 @@ public define Printable_tree
5114 5581 with
5115 5582 answer_body = (Printable_tree)
5116 5583 [
5117   - format(cinfo, state_name, ic_v, html_content, is_https, var(0), p_content_head_tags),
  5584 + format(cinfo, ic_v, html_content, is_https, var(0), p_content_head_tags),
5118 5585 ],
5119 5586 answer_header = (Printable_tree)
5120 5587 [
... ...
web/CXM_multihost_http_server.anubis
... ... @@ -181,17 +181,7 @@ read web/mime.anubis
181 181 informations are rarely used for composing HTML pages. Nevertheless, they are at your
182 182 disposal.
183 183  
184   -public type HTTP_Info:
185   - http_info
186   - (
187   - Word32 ip_address, // IP address of the client
188   - String hostname, // hostname requested by the client
189   - String uri, // URI requested by the client
190   - List(HTTP_header) http_headers, // HTTP headers sent by the client
191   - Bool is_https
192   - //One -> String generate_trust_ticket // may be used against denial of
193   - // service attacks
194   - ).
  184 +
195 185  
196 186  
197 187  
... ... @@ -2350,13 +2340,6 @@ define One
2350 2340 else log_journal_msg(desc,"Cannot find or read authorization file.\n")
2351 2341 }.
2352 2342  
2353   -
2354   -
2355   -
2356   -
2357   -
2358   -
2359   -
2360 2343 *** [5.6] Answering a www-url encoded request.
2361 2344  
2362 2345 Standard headers are for answering ".awp" requests.
... ... @@ -4153,6 +4136,63 @@ global define One
4153 4136  
4154 4137  
4155 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 +
4156 4196 public define (String, List(HTTP_header))
4157 4197 format
4158 4198 (
... ...
web/CXM_web_dump.anubis
... ... @@ -10,8 +10,8 @@
10 10 read tools/basis.anubis
11 11 read system/string.anubis
12 12 read system/convert.anubis
13   -read calexium_lib/web/CXM_common.anubis
14   -read calexium_lib/web/CXM_multihost_http_server.anubis
  13 +read CXM_common.anubis
  14 +read CXM_multihost_http_server.anubis
15 15  
16 16 /* Provides a dump of Web_arg List */
17 17 public define String
... ...
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
... ...