From 33032f862e2deb8affa07c1b7fc0f0519086a728 Mon Sep 17 00:00:00 2001 From: totoro Date: Wed, 1 Apr 2020 09:56:04 +0900 Subject: [PATCH] data_to_send (email) change and some examples (minimal web site) in progress --- .gitmodules | 3 +++ calexium_lib | 2 +- calexium_lib_examples/web/minimal_web_site.anubis | 230 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ calexium_lib_examples/web/minimal_web_site_vc.anubis | 286 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ calexium_lib_test.ide | 18 ++++++++++++++++++ densaku_type.aproj | 5 +++-- examples.ide | 4 ++-- hayamiki_lib | 1 + minimal_web_site.aproj | 1090 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 9 files changed, 614 insertions(+), 1025 deletions(-) create mode 100644 calexium_lib_examples/web/minimal_web_site.anubis create mode 100644 calexium_lib_examples/web/minimal_web_site_vc.anubis create mode 100644 calexium_lib_test.ide create mode 160000 hayamiki_lib diff --git a/.gitmodules b/.gitmodules index c748b42..306ae50 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "densaku_lib"] path = densaku_lib url = git@gitlab.anubis-language.com:totoro/densaku_lib.git +[submodule "hayamiki_lib"] + path = hayamiki_lib + url = ssh://git@gitlab.anubis-lang.com:33000/totoro/hayamiki_lib.git diff --git a/calexium_lib b/calexium_lib index 8a88e4c..313825c 160000 --- a/calexium_lib +++ b/calexium_lib @@ -1 +1 @@ -Subproject commit 8a88e4c20deb121c7bf8ad57487451c79a85860f +Subproject commit 313825c85c61d112f5a0f8debb57c8aa2d5ebf82 diff --git a/calexium_lib_examples/web/minimal_web_site.anubis b/calexium_lib_examples/web/minimal_web_site.anubis new file mode 100644 index 0000000..a77815a --- /dev/null +++ b/calexium_lib_examples/web/minimal_web_site.anubis @@ -0,0 +1,230 @@ + + + *Project* The Anubis Project + + *Title* A minimal web site. + + *Copyright* Copyright © David RENÉ + + *Released* + + *Author* David RENÉ + + *Overview* + + This file is just an example which may help to start making a web site with + Anubis Calexium Library + It was based on the example for making a minimal web site made by Alain Prouté and located + in examples/network folder in standard library example + + This example is absolutely minimalist and manage only page. + + +read tools/basis.anubis // required for 'make_directory' and . +read system/convert.anubis +read web/CXM_common.anubis // required for type 'Web_arg' +read web/CXM_multihost_http_server.anubis // required for type 'HTTP_Info' +read web/CXM_making_a_web_site.anubis +read web/mime.anubis // required for list of known MIME types + + + + + *** Server directory. + + A directory for putting files for all web sites. There will be one subdirectory per web + site. + +define String web_sites_directory = my_anubis_directory+"/web_sites". + + + *** Example site 1. + + Computing the pages of site 1. There is just one page. The type '$State' (see + 'web/CXM_making_a_web_site.anubis') has been chosen as 'One'. If this type were more + elaborate, the function 'compute_page_1' could compute several different pages (for + example, one per alternative of this type). Anyway, there is only one such function for + each web site. + +define HTTP_Answer + compute_page_1 + ( + One state + )= + html_page + ( + "Example Site 1", // title of web site + [], // list of 'META' tags (empty for this site) + body // body of page + ( + // list of body options + [ + background_color(rgb(255,200,200)) + // add more body options here + ], + + // content of page + center(text([size(14)],"This is the 'Example 1' web site.")) + ) + ) +. + + + + Making the description of web site 1. In this description, several elements are the + bare minimum. There is no action at all, no data base, almost nothing. See + 'web/making_a_web_site.anubis' for the declaration of the function + 'make_web_site_description'. + +define Web_Site + example_site_1 + = + // make the directory for web site 1 + // (subdirectories of it will be created automatically by the HTTP server) + forget((String)make_directory(web_sites_directory+"/example_site_1")); + + // make a list of all possible 'host names' for web site 1: + with addresses = (List(String)) + [ + "example-site-1", + "127.0.0.1", + "192.168.0.1" + // add more adresses here + ], + + // now make the description of the web site + make_web_site_description( + + //this is the unique ID of the web site. This ID will be use for prepend the cookies + //names belonging to that web site + "example", + + // the list of addresses defined above + addresses, + + // directory for the files of web site 1 + web_sites_directory+"/example_site_1", + + // directory for the states of that web_site + web_sites_directory+"/example_site_1/states", + + // initializing function + (One u) |-> u, // nothing to initialize for web site 1 + + // the function producing the initial state + (HTTP_Info info, + List(Web_arg) lwa, + Bool is_https) |-> unique, // there is ony one possible state for web site 1 + + // the function for handling expired tickets + // (tickets are kept on the server's disk and represent states. They are used for + // passing session informations from pages to pages. See + // 'web/CXM_making_a_web_site.anubis' for detailed explanations.) + (One expired, + Maybe(String) mb_action_name, + HTTP_Info info, + List(Web_arg) lwa, + Bool is_https) |-> unique, // keep the same state + + // the function for handling lost tickets + (Maybe(String) mb_action_name, + HTTP_Info info, + List(Web_arg) lwa, + Bool is_https) |-> unique, // restart with default state + + // list of all actions + [ ], // no action for web site 1 + + // the function for computing the pages of web site 1 (it is defined above) + compute_page_1, + + // the function for producing additional HTTP headers + (One u) |-> [], + + // timeout for tickets (in seconds) + 3600, // does'nt matter since only one state + + // list of redirections (one for each address) + // (see 'web/CXM_common.anubis' for the type 'Redirection') + redirection_list(map((String address) |-> redirect("/",address,"/site1.awp"), addresses)), + + // character encoding for web site 1 + "UTF-8", + + // list of URI extensions producing a console/journal message + [ + ".awp", // pages computed by this program + ".jpg", // images, etc... + ".gif", + ".png" + // add more extensions here (they must be known; see 'web/mime.anubis') + ], + + // list of HTTP headers which are traced in the console/journal messages + [ + "host", + "user-agent" + // add more HTTP headers here + ], + + // secret string (used by 'private download') + "HUD76GRD56FD7GFDS4RT", // for a real site, please choose another one + // it must remain secret + + // list of known MIME types (taken from 'web/mime.anubis') + known_mime_types, + + // action to be performed before a file is sent + // (for example, this may be used for counting downloads) + (String action_name, + List(Web_arg) lwa) |-> unique // no action at all + ) +. + + + + + *** Example site 2. + + Imagine another web site here... + + + + + + *** Starting all our web sites together. + +global define One + minimal_web_site + ( + List(String) args + ) = + // make the directory for all web sites (if needed) + forget((String) make_directory(web_sites_directory)); + + with http_port = (Word32)8000, + https_port = (Word32)4430, + // create a variable for handling the shutdown of our web sites + with shutdown_required = var(false), + with is_shutdown = (One u) |-> *shutdown_required, + + // start all web sites + if start_web_sites( + 0, // listen on all IP addresses + http_port, // port for HTTP + https_port, // port for HTTPS + "www.georges.example.com", // common name of SSL certificate + [ + example_site_1 + // add other web sites here + ], + is_shutdown) is + { + cannot_bind_to_port(n) then println("Cannot bind to port: "+n), + cannot_bind_to_port(n,m) then println("Cannot bind to ports: "+n+", "+m), + ok(s1,s2) then println("Servers started on ports "+http_port+" (HTTP) and "+https_port+" (HTTPS).") + } +. + + + diff --git a/calexium_lib_examples/web/minimal_web_site_vc.anubis b/calexium_lib_examples/web/minimal_web_site_vc.anubis new file mode 100644 index 0000000..1a3ec96 --- /dev/null +++ b/calexium_lib_examples/web/minimal_web_site_vc.anubis @@ -0,0 +1,286 @@ + + + *Project* The Anubis Project + + *Title* A minimal web site. + + *Copyright* Copyright © David RENÉ. + + *Released* + + *Author* David RENÉ + + *Overview* + + This file is just an example which may help to start making a web site with + Anubis Calexium Library + It was based on the example for making a minimal web site made by Alain Prouté and located + in examples/network folder in standard library example + + This example is absolutely minimalist and manage only page. + + +read tools/basis.anubis // required for 'make_directory' and . +read system/convert.anubis +read system/logger.anubis +read calexium_lib/web/CXM_common.anubis // required for type 'Web_arg' +read calexium_lib/web/CXM_multihost_http_server.anubis // required for type 'HTTP_Info' +read calexium_lib/web/controllers_web_site.anubis +read calexium_lib/web/CXM_making_a_web_site.anubis +read web/mime.anubis // required for list of known MIME types +read calexium_lib/web/CXM_web_arg_utils.anubis +read calexium_lib/web/CXM_web_session.anubis +read calexium_lib/web/CXM_form.anubis +read calexium_lib/web/jQuery/CXM_jquery_button.anubis + + *** Server directory. + + A directory for putting files for all web sites. There will be one subdirectory per web + site. + +public define WEB_Action_Name show_login = controller_action("root", "show_login"). +public define WEB_Action_Name after_login = controller_action("root", "after_login"). + + +define String web_sites_directory = my_anubis_directory+"/web_sites". + + +define HTML_Partial_Content + create_login_form + = + + partial_content( + [css(css_file("css/login.css"))], + div([id("login")], + sequence([ + //BODY + div([id("login_body")], + cxm_form( "login_form", [], after_login, [], [], + [ + input (label(("LOGIN_NAME"), no_help), wan("login_name"), init(""), narrow, non_mandatory), + password_input(label(("PASSWORD"), no_help), wan("password"), init(""), narrow, non_mandatory), + partial(img_submit_button(("CONNECTION"), "login_form" )) + ]) + ), + ]) + )). + +define WEB_Controller_Result + show_login + ( + WEB_Session _session + )= + http_answer( + html_page + ( + "Example Site 1", // title of web site + [], // list of 'META' tags (empty for this site) + body // body of page + ( + // list of body options + [ + background_color(rgb(255,200,200)) + // add more body options here + ], + + // content of page + partial(create_login_form) + ) + )) +. + +define WEB_Controller_Result + after_login + ( + WEB_Session _session + )= + with lwa = _session.lwa + + http_answer( + html_page + ( + "Example Site 1", // title of web site + [], // list of 'META' tags (empty for this site) + body // body of page + ( + // list of body options + [ + background_color(rgb(255,200,200)) + // add more body options here + ], + + // content of the page + [center(text("This is the 'Example 1' web site.")), br, + text("Login from :"+] + ) + )) +. + +define List(WEB_Action) + root_controller_actions + = + [ + web_action(show_login, http_https, (WEB_Session _session) |-> true, show_login), + web_action(after_login, http_https, (WEB_Session _session) |-> true, after_login), + ]. + + +define WEB_Controller + make_root_controller + = + web_controller("root", var(root_controller_actions)) +. + + Making the description of web site 1. In this description, several elements are the + bare minimum. There is no action at all, no data base, almost nothing. See + 'web/making_a_web_site.anubis' for the declaration of the function + 'make_web_site_description'. + +define Web_Site + example_site_1 + = + // make the directory for web site 1 + // (subdirectories of it will be created automatically by the HTTP server) + forget((String)make_directory(web_sites_directory+"/example_site_1")); + + // make a list of all possible 'host names' for web site 1: + with addresses = (List(String)) + [ + "example-site-1", + "127.0.0.1", + "192.168.0.1" + // add more adresses here + ], + + // now make the description of the web site + make_web_site_controller_description( + + //this is the unique ID of the web site. This ID will be use for prepend the cookies + //names belonging to that web site + "example", + + // the list of addresses defined above + addresses, + + // directory for the files of web site 1 + web_sites_directory+"/example_site_1", + + // directory for the states of that web_site + web_sites_directory+"/example_site_1/states", + + // initializing function + (One u) |-> u, // nothing to initialize for web site 1 + + // the function producing the initial session + (HTTP_Info info, + Var(List(Web_arg)) lwa, + Bool is_https) |-> web_session(get_new_session_id, "en", empty_fields_list, web_request(info, var([web_arg("aws_c","root"), web_arg("aws_a", "show_login")]), is_https), web_request(info, lwa, is_https), web_request(info, lwa, is_https)), // + + // the function for handling expired tickets + // (tickets are kept on the server's disk and represent states. They are used for + // passing session informations from pages to pages. See + // 'web/CXM_making_a_web_site.anubis' for detailed explanations.) + (WEB_Session expired, + HTTP_Info info, + Var(List(Web_arg)) lwa, + Bool is_https) |-> expired, // keep the same session + + var([make_root_controller]), //controllers + var([]), //desktop renderer + var([]), //list of plugins + + // the function for producing additional HTTP headers depending of the session + (Maybe(WEB_Session) session) |-> [], + + //function for adding constant additional headers + [], + + // timeout for tickets (in seconds) + 3600, // does'nt matter since only one state + + // list of redirections (one for each address) + // (see 'web/CXM_common.anubis' for the type 'Redirection') + redirection_list(map((String address) |-> redirect("/",address,"/index.awp"), addresses)), + + // character encoding for web site 1 + "UTF-8", + + // list of URI extensions producing a console/journal message + [ + ".awp", // pages computed by this program + ".jpg", // images, etc... + ".gif", + ".png" + // add more extensions here (they must be known; see 'web/mime.anubis') + ], + + // list of HTTP headers which are traced in the console/journal messages + [ + "host", + "user-agent" + // add more HTTP headers here + ], + + (LogLevel level, String txt) |-> println(txt), //logger. Here is minimal logger which make only print + + // secret string (used by 'private download') + "HUD76GRD56FD7GFDS4RT", // for a real site, please choose another one + // it must remain secret + + // list of known MIME types (taken from 'web/mime.anubis') + known_mime_types, + + // action to be performed before a file is sent + // (for example, this may be used for counting downloads) + (String action_name, + List(Web_arg) lwa) |-> unique // no action at all + ) +. + + + + + *** Example site 2. + + Imagine another web site here... + + + + + + *** Starting all our web sites together. + +global define One + minimal_web_site_vc + ( + List(String) args + ) = + // make the directory for all web sites (if needed) + forget((String) make_directory(web_sites_directory)); + + with http_port = (Word32)80, + https_port = (Word32)443, + // create a variable for handling the shutdown of our web sites + with shutdown_required = var(false), + with is_shutdown = (One u) |-> *shutdown_required, + + // start all web sites + if start_web_sites( + 0, // listen on all IP addresses + http_port, // port for HTTP + https_port, // port for HTTPS + "www.georges.example.com", // common name of SSL certificate + [ + example_site_1 + // add other web sites here + ], + is_shutdown) is + { + cannot_bind_to_port(n) then println("Cannot bind to port: "+n), + cannot_bind_to_port(n,m) then println("Cannot bind to ports: "+n+", "+m), + ok(s1,s2) then println("Servers started on ports "+http_port+" (HTTP) and "+https_port+" (HTTPS).") + } +. + + + diff --git a/calexium_lib_test.ide b/calexium_lib_test.ide new file mode 100644 index 0000000..a7e9925 --- /dev/null +++ b/calexium_lib_test.ide @@ -0,0 +1,18 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +# SharpDevelop 1.0.12.108 +Project("{B6712916-30DE-4a3e-A54C-2A79AC984AEE}") = "ami_test", "ami_test.aproj", "{C1016FEA-33CF-4348-8EEA-E4E4243CD9D1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C1016FEA-33CF-4348-8EEA-E4E4243CD9D1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C1016FEA-33CF-4348-8EEA-E4E4243CD9D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C1016FEA-33CF-4348-8EEA-E4E4243CD9D1}.Release|Any CPU.Build.0 = Release|Any CPU + {C1016FEA-33CF-4348-8EEA-E4E4243CD9D1}.Release|Any CPU.ActiveCfg = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/densaku_type.aproj b/densaku_type.aproj index 35bf866..ff4a67b 100644 --- a/densaku_type.aproj +++ b/densaku_type.aproj @@ -27,13 +27,14 @@ + + - - + \ No newline at end of file diff --git a/examples.ide b/examples.ide index 45b3e57..101e58f 100644 --- a/examples.ide +++ b/examples.ide @@ -2,10 +2,10 @@ Microsoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 # SharpDevelop 1.0.12.108 -Project("{B6712916-30DE-4a3e-A54C-2A79AC984AEE}") = "minimal_web_site", "minimal_web_site.aproj", "{F2C65267-0D20-4964-A5D8-602BD42C01A4}" -EndProject Project("{B6712916-30DE-4a3e-A54C-2A79AC984AEE}") = "densaku_type", "densaku_type.aproj", "{DE869A94-DD37-407E-9BFC-358456CCC419}" EndProject +Project("{B6712916-30DE-4a3e-A54C-2A79AC984AEE}") = "minimal_web_site", "minimal_web_site.aproj", "{F2C65267-0D20-4964-A5D8-602BD42C01A4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/hayamiki_lib b/hayamiki_lib new file mode 160000 index 0000000..11c07a5 --- /dev/null +++ b/hayamiki_lib @@ -0,0 +1 @@ +Subproject commit 11c07a531623555ac1eee039056f25e7edfc7d5f diff --git a/minimal_web_site.aproj b/minimal_web_site.aproj index e91fabe..8825c04 100644 --- a/minimal_web_site.aproj +++ b/minimal_web_site.aproj @@ -6,8 +6,8 @@ Exe minimal_web_site minimal_web_site - calexium_lib\asterisk\ami.anubis - ./ + calexium_lib_examples\web\minimal_web_site_vc.anubis + ./%3b./../ bin\Debug\ @@ -24,288 +24,21 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - + + @@ -316,755 +49,35 @@ + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + @@ -1073,19 +86,15 @@ - - - - + + + + + + - - - - - - @@ -1093,27 +102,41 @@ + + + + - + + + + - + + + + + + + + + - @@ -1130,16 +153,19 @@ - + + + + @@ -1159,15 +185,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- libgit2 0.21.4