Commit a65a9fdea6535804b08fcafbc784d7c98346147a

Authored by David RENÉ
1 parent 165ecd86

data_to_send type has 2 content component (text and html)

ds_files/ds_types.anubis
... ... @@ -123,7 +123,8 @@ public define List(DS_Type_File) calexium_lib_types_description =
123 123 component(list, ds_type("Email_Address"), "cc", comment("email sent as copy to that list of recipients")),
124 124 component(list, ds_type("Email_Address"), "bcc", comment("email sent as blank carbon copy to that list of recipients")),
125 125 component(string, "subject", comment("subject of email. Supposed to be UTF8")),
126   - component(string, "content", comment("content of the email")),
  126 + component(string, "text_content", comment("content of the email in text format")),
  127 + component(string, "html_content", comment("content of the email in html format")),
127 128 component(list, ds_type("File_ref"), "attached_files", comment("list of files to attach to this email")),
128 129 component(bool, "send_copy",comment("send copy to sender by bcc (useful when the email is sent by an automat)")),
129 130 component(string, "reply_to", comment("reply to !!"))
... ...
examples/minimal_web_site.anubis deleted
1   -
2   -
3   - *Project* The Anubis Project
4   -
5   - *Title* A minimal web site.
6   -
7   - *Copyright* Copyright © David RENÉ
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 deleted
1   -
2   -
3   - *Project* The Anubis Project
4   -
5   - *Title* A minimal web site.
6   -
7   - *Copyright* Copyright © David RENÉ.
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   -
mail/types/generated/email_to_send.anubis
1   -/*
  1 +/*
2 2 * Created by 伝作 (Densaku).
3 3 * Types & Messages generator written by フランスのトトロ aka (David RENÉ)
4   - * Date: 2019-05-17
5   - * Time: 19:05:20
  4 + * Date: 2020-04-01
  5 + * Time: 09:43:06
6 6 *
7 7 */
8 8  
... ... @@ -10,8 +10,8 @@ transmit system/muscle.anubis
10 10 transmit system/convert.anubis
11 11 transmit tools/basis.anubis
12 12  
13   -transmit calexium_lib/types/generated/file_ref.anubis
14   -transmit calexium_lib/mail/types/generated/email_address.anubis
  13 +transmit types/generated/file_ref.anubis
  14 +transmit types/generated/email_address.anubis
15 15  
16 16  
17 17  
... ... @@ -22,7 +22,8 @@ public type Email_to_send:
22 22 List(Email_Address) cc, //email sent as copy to that list of recipients
23 23 List(Email_Address) bcc, //email sent as blank carbon copy to that list of recipients
24 24 String subject, //subject of email. Supposed to be UTF8
25   - String content, //content of the email
  25 + String text_content, //content of the email in text format
  26 + String html_content, //content of the email in html format
26 27 List(File_ref) attached_files, //list of files to attach to this email
27 28 Bool send_copy, //send copy to sender by bcc (useful when the email is sent by an automat)
28 29 String reply_to //reply to !!
... ... @@ -43,7 +44,7 @@ public define Message
43 44 if _email_to_send is
44 45 {
45 46 //Alternative data_to_send
46   - data_to_send(_from, __to, __cc, __bcc, _subject, _content, __attached_files, _send_copy, _reply_to) then
  47 + data_to_send(_from, __to, __cc, __bcc, _subject, _text_content, _html_content, __attached_files, _send_copy, _reply_to) then
47 48 forget(add_string(_email_to_send_message, "__TYPE_ALT__", "data_to_send"));
48 49 // [type = Email_Address] data_to_send.from
49 50 forget(add_message(_email_to_send_message, "from", to_Message(_from)));
... ... @@ -55,8 +56,10 @@ public define Message
55 56 map_forget((Email_Address _bcc) |-> add_message(_email_to_send_message, "bcc", to_Message(_bcc)), __bcc);
56 57 // [type = String] data_to_send.subject
57 58 forget(add_string(_email_to_send_message, "subject", _subject));
58   - // [type = String] data_to_send.content
59   - forget(add_string(_email_to_send_message, "content", _content));
  59 + // [type = String] data_to_send.text_content
  60 + forget(add_string(_email_to_send_message, "text_content", _text_content));
  61 + // [type = String] data_to_send.html_content
  62 + forget(add_string(_email_to_send_message, "html_content", _html_content));
60 63 // [type = List(File_ref)] data_to_send.attached_files
61 64 map_forget((File_ref _attached_files) |-> add_message(_email_to_send_message, "attached_files", to_Message(_attached_files)), __attached_files);
62 65 // [type = Bool] data_to_send.send_copy
... ... @@ -92,8 +95,10 @@ public define Maybe(Email_to_send)
92 95 if mb__bcc_ is {failure then failure, success(_bcc_) then
93 96 // [type = String] data_to_send.subject
94 97 if find_string(_email_to_send_message, "subject") is {failure then failure, success(_subject_) then
95   - // [type = String] data_to_send.content
96   - if find_string(_email_to_send_message, "content") is {failure then failure, success(_content_) then
  98 + // [type = String] data_to_send.text_content
  99 + if find_string(_email_to_send_message, "text_content") is {failure then failure, success(_text_content_) then
  100 + // [type = String] data_to_send.html_content
  101 + if find_string(_email_to_send_message, "html_content") is {failure then failure, success(_html_content_) then
97 102 // [type = List(File_ref)] data_to_send.attached_files
98 103 with mb__attached_files_ = map_escape(( Message msg ) |-> (Maybe(File_ref)) from_Message(msg), find_messages(_email_to_send_message, "attached_files")),
99 104 if mb__attached_files_ is {failure then failure, success(_attached_files_) then
... ... @@ -102,8 +107,8 @@ public define Maybe(Email_to_send)
102 107 // [type = String] data_to_send.reply_to
103 108 if find_string(_email_to_send_message, "reply_to") is {failure then failure, success(_reply_to_) then
104 109  
105   - success(data_to_send(_from_, _to_, _cc_, _bcc_, _subject_, _content_, _attached_files_, _send_copy_, _reply_to_))
106   - }}}}}}}}}}
  110 + success(data_to_send(_from_, _to_, _cc_, _bcc_, _subject_, _text_content_, _html_content_, _attached_files_, _send_copy_, _reply_to_))
  111 + }}}}}}}}}}}
107 112 else
108 113 failure //No valid Alternative found !
109 114 else
... ...