From 6bc084483c6b845fb7ba125bd87aad4916d2248c Mon Sep 17 00:00:00 2001 From: totoro Date: Wed, 15 Mar 2017 02:03:52 +0100 Subject: [PATCH] add web_action_name in densaku type generator --- ds_files/ds_types.anubis | 15 +++++++++++++++ web/types/web_action_name.anubis | 105 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+), 0 deletions(-) create mode 100644 web/types/web_action_name.anubis diff --git a/ds_files/ds_types.anubis b/ds_files/ds_types.anubis index d0ca953..bfe07fb 100644 --- a/ds_files/ds_types.anubis +++ b/ds_files/ds_types.anubis @@ -65,6 +65,21 @@ public define List(DS_Type) calexium_lib_types_description = component(list, string, "file_extensions") ]) ]), + + ds_type("WEB_Action_Name", [ + alternative("controller_action", [ + component(string, "controller"), + component(string, "action_name") + ]), + alternative("action_name", [ + component(string, "action_name") + ]), + + //url is raw action, hence we will only copy that url in final link + alternative("url", comment("url is raw action, hence we will only copy that url in final link"), [ + component(string, "url_name", ) + ]) + ]) ] . diff --git a/web/types/web_action_name.anubis b/web/types/web_action_name.anubis new file mode 100644 index 0000000..d3d44a6 --- /dev/null +++ b/web/types/web_action_name.anubis @@ -0,0 +1,105 @@ +/* + * Created by 伝作 (Densaku). + * Types & Messages generator written by フランスのトトロ aka (David RENÉ) + * Date: 2017-03-14 + * Time: 05:53:28 + * + */ + +transmit system/muscle.anubis +transmit system/convert.anubis +transmit tools/basis.anubis + + +public type WEB_Action_Name: + controller_action( + String controller, + String action_name + ), + action_name( + String action_name + ), + //url is raw action, hence we will only copy that url in final link + + url( + String url_name + ) +. + + WEB_Action_Name message format + ============================== + + +public define Message + to_Message + ( + WEB_Action_Name _web_action_name + )= + with _web_action_name_message = message((Word32)0), // + forget(add_string(_web_action_name_message, "__TYPE__", "WEB_Action_Name")); + if _web_action_name is + { + //Alternative controller_action + controller_action(_controller, _action_name) then + forget(add_string(_web_action_name_message, "__TYPE_ALT__", "controller_action")); + // [type = String] controller_action.controller + forget(add_string(_web_action_name_message, "controller", _controller)); + // [type = String] controller_action.action_name + forget(add_string(_web_action_name_message, "action_name", _action_name)), + + //Alternative action_name + action_name(_action_name) then + forget(add_string(_web_action_name_message, "__TYPE_ALT__", "action_name")); + // [type = String] action_name.action_name + forget(add_string(_web_action_name_message, "action_name", _action_name)), + + //Alternative url + //url is raw action, hence we will only copy that url in final link + url(_url_name) then + forget(add_string(_web_action_name_message, "__TYPE_ALT__", "url")); + // [type = String] url.url_name + forget(add_string(_web_action_name_message, "url_name", _url_name)), + + }; + _web_action_name_message +. + +public define Maybe(WEB_Action_Name) + from_Message + ( + Message _web_action_name_message + )= + if find_string(_web_action_name_message, "__TYPE__") is {failure then failure, success(__type__) then + if find_string(_web_action_name_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then + if __type__ = "WEB_Action_Name" then + //Alternative controller_action + if __type_alt__ = "controller_action" then //Alternative controller_action + // [type = String] controller_action.controller + if find_string(_web_action_name_message, "controller") is {failure then failure, success(controller) then + // [type = String] controller_action.action_name + if find_string(_web_action_name_message, "action_name") is {failure then failure, success(action_name) then + + success(controller_action(controller, action_name)) + }} + else //Alternative action_name + if __type_alt__ = "action_name" then //Alternative action_name + // [type = String] action_name.action_name + if find_string(_web_action_name_message, "action_name") is {failure then failure, success(action_name) then + + success(action_name(action_name)) + } + else //Alternative url + //url is raw action, hence we will only copy that url in final link + if __type_alt__ = "url" then //Alternative url + // [type = String] url.url_name + if find_string(_web_action_name_message, "url_name") is {failure then failure, success(url_name) then + + success(url(url_name)) + } + else + failure //No valid Alternative found ! + else + failure //Type not found in message ! + }} +. + -- libgit2 0.21.4