diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..66984f5 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +ds_files/types/generated/ diff --git a/xlib b/xlib index e432216..068d794 160000 --- a/xlib +++ b/xlib @@ -1 +1 @@ -Subproject commit e4322160bc99742f8283441ca12a823993ab8793 +Subproject commit 068d794002eebc966981493bc3a54dd6b4ab48d6 diff --git a/xlib_web_controllers.aproj b/xlib_web_controllers.aproj new file mode 100644 index 0000000..8827816 --- /dev/null +++ b/xlib_web_controllers.aproj @@ -0,0 +1,35 @@ + + + {7FD79E96-A0AA-4BE4-97D5-151C56A47059} + Debug + AnyCPU + Exe + xlib_web_controllers + xlib_web_controllers + xlib_web_controllers\language\controller.anubis + ./ + + + bin\Debug\ + True + Full + False + + + bin\Release\ + False + None + True + + + + + + + + + + + + + \ No newline at end of file diff --git a/xlib_web_controllers.ide b/xlib_web_controllers.ide new file mode 100644 index 0000000..9e85c92 --- /dev/null +++ b/xlib_web_controllers.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}") = "xlib_web_controllers", "xlib_web_controllers.aproj", "{7FD79E96-A0AA-4BE4-97D5-151C56A47059}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7FD79E96-A0AA-4BE4-97D5-151C56A47059}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7FD79E96-A0AA-4BE4-97D5-151C56A47059}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7FD79E96-A0AA-4BE4-97D5-151C56A47059}.Release|Any CPU.Build.0 = Release|Any CPU + {7FD79E96-A0AA-4BE4-97D5-151C56A47059}.Release|Any CPU.ActiveCfg = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/xlib_web_controllers/language/controller.anubis b/xlib_web_controllers/language/controller.anubis new file mode 100644 index 0000000..d84fc8f --- /dev/null +++ b/xlib_web_controllers/language/controller.anubis @@ -0,0 +1,126 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 18/04/2020 + * Time: 00:50 + * © David RENÉ + */ + +read system/logger.anubis +read language_web_action_name.anubis +read hayamiki_lib/model/types/hk_database.anubis +read hayamiki_lib/view/view_table_manager_types.anubis +read xlib/web/controllers_web_site.anubis +read xlib/web_controllers/language/language_management.anubis +read xlib/web/plugin/plugin.anubis + +define WEB_Action + do_change_language + = + web_action( + do_change_language, + http_https, + (WEB_Session _session) |-> true, + (WEB_Session _session) |-> + + // + since _session is web_session(id, _old_lang, fields, current, previous, draw), + //increment 1 to message TTL + with step = get_Int(fields, "AWS_SESSION_STEP",0), + replace_Int(fields, "PAGE_MESSAGE_TTL", step+1); + + if web_arg_value(*current.lwa, "language_code") is + { + not_found then redirect_to_previous, //http_answer(web_session(id, _old_lang, fields, previous, previous), plain_text(http_no_content, "")) // + found(language_code) then //http_answer(web_session(id, language_code, fields, previous, previous), plain_text(http_no_content, "")) + with new_web_session = web_session(id, language_code, fields, draw, previous, draw), +// println("------- language change. New web session ---------"); +// println(dump(new_web_session)); +// println("--------------------------------------------------"); + + redirect(new_web_session) + } + ) +. +public define HTTP_Answer + ajax_translate_to_json + ( + WEB_Session _session, + String symbolic_names //list of symbolic names to translate separated by comma i.e. "JAN,FEB" + ) = + with _T = make_translate_function(_session), + + //construct a list of json_member with "symbolic_name: translated value" + with translated_list = map((String symbolic) |-> json_member(symbolic, json_string(_T(symbolic))), split_by_token(symbolic_names,',')), + json(http_ok, json_object(translated_list)) +. + +define WEB_Action + ajax_translate_json + = + web_action( + ajax_translate_json, + https, + (WEB_Session _session) |-> true, + (WEB_Session _session) |-> + //here the function really call for creating domain name + since _session is web_session(id, lang, _, web_request, _, _draw), + if web_arg_value(*web_request.lwa, "to_translate") is + { + not_found then redirect_to_previous + found(symbolic_names) then ajax(ajax_translate_to_json(_session, symbolic_names)) + } + ) +. + +public define List(WEB_Action) + make_language_actions = + [ + //action lors de la demande de création d'un user dans un domaine + do_change_language, + ajax_translate_json + ]. + +public define WEB_Controller + get_lang_controller + = + web_controller("language", var(make_language_actions)) +. + +public define List(WEB_Controller) + plugin_get_controller + ( + SQLite3DataBase db, + HK_Database hk_db, + VTM _vtm, + (LogLevel, String) -> One logger + ) = + [get_lang_controller] +. + + +define Maybe(HTML_Partial_Content) + plugin_get_typed_content + ( + SQLite3DataBase db, + WEB_Session _session, + String type + )= + println("plugin_get_typed_content for L3 type "+type); + if type = "LEFT_MENU" then failure + else if type = "TOOLBAR" then failure + else if type = "CONTROL_PANEL" then failure + else + failure +. + +global define WEB_Plugin + l3_lib + = + web_plugin( + "L3", + "BASE", + plugin_get_controller, + plugin_get_typed_content + ) +. diff --git a/xlib_web_controllers/language/language_web_action_name.anubis b/xlib_web_controllers/language/language_web_action_name.anubis new file mode 100644 index 0000000..d86447c --- /dev/null +++ b/xlib_web_controllers/language/language_web_action_name.anubis @@ -0,0 +1,13 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 18/04/2020 + * Time: 15:18 + * © David RENÉ + */ + + +read xlib/web/controllers_web_site.anubis + +public define WEB_Action_Name do_change_language = controller_action("language", "do_change_language"). +public define WEB_Action_Name ajax_translate_json = controller_action("language", "ajax_translate_json"). -- libgit2 0.21.4