Commit 20cfbacf25997d0660ee98988c8cc58c148b8a30
1 parent
fd32b38b
add L3 web controller
Showing
6 changed files
with
194 additions
and
1 deletions
Show diff stats
| 1 | +ds_files/types/generated/ |
xlib @ 068d794002e
| 1 | +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| 2 | + <PropertyGroup> | ||
| 3 | + <ProjectGuid>{7FD79E96-A0AA-4BE4-97D5-151C56A47059}</ProjectGuid> | ||
| 4 | + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
| 5 | + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
| 6 | + <OutputType>Exe</OutputType> | ||
| 7 | + <RootNamespace>xlib_web_controllers</RootNamespace> | ||
| 8 | + <AssemblyName>xlib_web_controllers</AssemblyName> | ||
| 9 | + <StartupObject>xlib_web_controllers\language\controller.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 | + <Folder Include="xlib" /> | ||
| 27 | + <Folder Include="xlib\web_controllers" /> | ||
| 28 | + <Folder Include="xlib\web_controllers\language" /> | ||
| 29 | + <Folder Include="xlib_web_controllers" /> | ||
| 30 | + <Folder Include="xlib_web_controllers\language" /> | ||
| 31 | + <Compile Include="xlib\web_controllers\language\language_management.anubis" /> | ||
| 32 | + <Compile Include="xlib_web_controllers\language\controller.anubis" /> | ||
| 33 | + <Compile Include="xlib_web_controllers\language\language_web_action_name.anubis" /> | ||
| 34 | + </ItemGroup> | ||
| 35 | +</Project> | ||
| 0 | \ No newline at end of file | 36 | \ No newline at end of file |
| 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}") = "xlib_web_controllers", "xlib_web_controllers.aproj", "{7FD79E96-A0AA-4BE4-97D5-151C56A47059}" | ||
| 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 | + {7FD79E96-A0AA-4BE4-97D5-151C56A47059}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| 14 | + {7FD79E96-A0AA-4BE4-97D5-151C56A47059}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| 15 | + {7FD79E96-A0AA-4BE4-97D5-151C56A47059}.Release|Any CPU.Build.0 = Release|Any CPU | ||
| 16 | + {7FD79E96-A0AA-4BE4-97D5-151C56A47059}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
| 17 | + EndGlobalSection | ||
| 18 | +EndGlobal |
| 1 | +/* | ||
| 2 | + * Created by PyramIDE. | ||
| 3 | + * User: フランスのトトロ aka (David RENÉ) | ||
| 4 | + * Date: 18/04/2020 | ||
| 5 | + * Time: 00:50 | ||
| 6 | + * © David RENÉ | ||
| 7 | + */ | ||
| 8 | + | ||
| 9 | +read system/logger.anubis | ||
| 10 | +read language_web_action_name.anubis | ||
| 11 | +read hayamiki_lib/model/types/hk_database.anubis | ||
| 12 | +read hayamiki_lib/view/view_table_manager_types.anubis | ||
| 13 | +read xlib/web/controllers_web_site.anubis | ||
| 14 | +read xlib/web_controllers/language/language_management.anubis | ||
| 15 | +read xlib/web/plugin/plugin.anubis | ||
| 16 | + | ||
| 17 | +define WEB_Action | ||
| 18 | + do_change_language | ||
| 19 | + = | ||
| 20 | + web_action( | ||
| 21 | + do_change_language, | ||
| 22 | + http_https, | ||
| 23 | + (WEB_Session _session) |-> true, | ||
| 24 | + (WEB_Session _session) |-> | ||
| 25 | + | ||
| 26 | + // | ||
| 27 | + since _session is web_session(id, _old_lang, fields, current, previous, draw), | ||
| 28 | + //increment 1 to message TTL | ||
| 29 | + with step = get_Int(fields, "AWS_SESSION_STEP",0), | ||
| 30 | + replace_Int(fields, "PAGE_MESSAGE_TTL", step+1); | ||
| 31 | + | ||
| 32 | + if web_arg_value(*current.lwa, "language_code") is | ||
| 33 | + { | ||
| 34 | + not_found then redirect_to_previous, //http_answer(web_session(id, _old_lang, fields, previous, previous), plain_text(http_no_content, "")) // | ||
| 35 | + found(language_code) then //http_answer(web_session(id, language_code, fields, previous, previous), plain_text(http_no_content, "")) | ||
| 36 | + with new_web_session = web_session(id, language_code, fields, draw, previous, draw), | ||
| 37 | +// println("------- language change. New web session ---------"); | ||
| 38 | +// println(dump(new_web_session)); | ||
| 39 | +// println("--------------------------------------------------"); | ||
| 40 | + | ||
| 41 | + redirect(new_web_session) | ||
| 42 | + } | ||
| 43 | + ) | ||
| 44 | +. | ||
| 45 | +public define HTTP_Answer | ||
| 46 | + ajax_translate_to_json | ||
| 47 | + ( | ||
| 48 | + WEB_Session _session, | ||
| 49 | + String symbolic_names //list of symbolic names to translate separated by comma i.e. "JAN,FEB" | ||
| 50 | + ) = | ||
| 51 | + with _T = make_translate_function(_session), | ||
| 52 | + | ||
| 53 | + //construct a list of json_member with "symbolic_name: translated value" | ||
| 54 | + with translated_list = map((String symbolic) |-> json_member(symbolic, json_string(_T(symbolic))), split_by_token(symbolic_names,',')), | ||
| 55 | + json(http_ok, json_object(translated_list)) | ||
| 56 | +. | ||
| 57 | + | ||
| 58 | +define WEB_Action | ||
| 59 | + ajax_translate_json | ||
| 60 | + = | ||
| 61 | + web_action( | ||
| 62 | + ajax_translate_json, | ||
| 63 | + https, | ||
| 64 | + (WEB_Session _session) |-> true, | ||
| 65 | + (WEB_Session _session) |-> | ||
| 66 | + //here the function really call for creating domain name | ||
| 67 | + since _session is web_session(id, lang, _, web_request, _, _draw), | ||
| 68 | + if web_arg_value(*web_request.lwa, "to_translate") is | ||
| 69 | + { | ||
| 70 | + not_found then redirect_to_previous | ||
| 71 | + found(symbolic_names) then ajax(ajax_translate_to_json(_session, symbolic_names)) | ||
| 72 | + } | ||
| 73 | + ) | ||
| 74 | +. | ||
| 75 | + | ||
| 76 | +public define List(WEB_Action) | ||
| 77 | + make_language_actions = | ||
| 78 | + [ | ||
| 79 | + //action lors de la demande de création d'un user dans un domaine | ||
| 80 | + do_change_language, | ||
| 81 | + ajax_translate_json | ||
| 82 | + ]. | ||
| 83 | + | ||
| 84 | +public define WEB_Controller | ||
| 85 | + get_lang_controller | ||
| 86 | + = | ||
| 87 | + web_controller("language", var(make_language_actions)) | ||
| 88 | +. | ||
| 89 | + | ||
| 90 | +public define List(WEB_Controller) | ||
| 91 | + plugin_get_controller | ||
| 92 | + ( | ||
| 93 | + SQLite3DataBase db, | ||
| 94 | + HK_Database hk_db, | ||
| 95 | + VTM _vtm, | ||
| 96 | + (LogLevel, String) -> One logger | ||
| 97 | + ) = | ||
| 98 | + [get_lang_controller] | ||
| 99 | +. | ||
| 100 | + | ||
| 101 | + | ||
| 102 | +define Maybe(HTML_Partial_Content) | ||
| 103 | + plugin_get_typed_content | ||
| 104 | + ( | ||
| 105 | + SQLite3DataBase db, | ||
| 106 | + WEB_Session _session, | ||
| 107 | + String type | ||
| 108 | + )= | ||
| 109 | + println("plugin_get_typed_content for L3 type "+type); | ||
| 110 | + if type = "LEFT_MENU" then failure | ||
| 111 | + else if type = "TOOLBAR" then failure | ||
| 112 | + else if type = "CONTROL_PANEL" then failure | ||
| 113 | + else | ||
| 114 | + failure | ||
| 115 | +. | ||
| 116 | + | ||
| 117 | +global define WEB_Plugin | ||
| 118 | + l3_lib | ||
| 119 | + = | ||
| 120 | + web_plugin( | ||
| 121 | + "L3", | ||
| 122 | + "BASE", | ||
| 123 | + plugin_get_controller, | ||
| 124 | + plugin_get_typed_content | ||
| 125 | + ) | ||
| 126 | +. |
xlib_web_controllers/language/language_web_action_name.anubis
0 → 100644
| 1 | +/* | ||
| 2 | + * Created by PyramIDE. | ||
| 3 | + * User: フランスのトトロ aka (David RENÉ) | ||
| 4 | + * Date: 18/04/2020 | ||
| 5 | + * Time: 15:18 | ||
| 6 | + * © David RENÉ | ||
| 7 | + */ | ||
| 8 | + | ||
| 9 | + | ||
| 10 | +read xlib/web/controllers_web_site.anubis | ||
| 11 | + | ||
| 12 | +public define WEB_Action_Name do_change_language = controller_action("language", "do_change_language"). | ||
| 13 | +public define WEB_Action_Name ajax_translate_json = controller_action("language", "ajax_translate_json"). |