Commit 6bc084483c6b845fb7ba125bd87aad4916d2248c

Authored by totoro
1 parent fa49a949

add web_action_name in densaku type generator

Showing 2 changed files with 120 additions and 0 deletions   Show diff stats
ds_files/ds_types.anubis
@@ -65,6 +65,21 @@ public define List(DS_Type) calexium_lib_types_description = @@ -65,6 +65,21 @@ public define List(DS_Type) calexium_lib_types_description =
65 component(list, string, "file_extensions") 65 component(list, string, "file_extensions")
66 ]) 66 ])
67 ]), 67 ]),
  68 +
  69 + ds_type("WEB_Action_Name", [
  70 + alternative("controller_action", [
  71 + component(string, "controller"),
  72 + component(string, "action_name")
  73 + ]),
  74 + alternative("action_name", [
  75 + component(string, "action_name")
  76 + ]),
  77 +
  78 + //url is raw action, hence we will only copy that url in final link
  79 + alternative("url", comment("url is raw action, hence we will only copy that url in final link"), [
  80 + component(string, "url_name", )
  81 + ])
  82 + ])
68 83
69 ] 84 ]
70 . 85 .
web/types/web_action_name.anubis 0 → 100644
  1 +/*
  2 + * Created by 伝作 (Densaku).
  3 + * Types & Messages generator written by フランスのトトロ aka (David RENÉ)
  4 + * Date: 2017-03-14
  5 + * Time: 05:53:28
  6 + *
  7 + */
  8 +
  9 +transmit system/muscle.anubis
  10 +transmit system/convert.anubis
  11 +transmit tools/basis.anubis
  12 +
  13 +
  14 +public type WEB_Action_Name:
  15 + controller_action(
  16 + String controller,
  17 + String action_name
  18 + ),
  19 + action_name(
  20 + String action_name
  21 + ),
  22 + //url is raw action, hence we will only copy that url in final link
  23 +
  24 + url(
  25 + String url_name
  26 + )
  27 +.
  28 +
  29 + WEB_Action_Name message format
  30 + ==============================
  31 +
  32 +
  33 +public define Message
  34 + to_Message
  35 + (
  36 + WEB_Action_Name _web_action_name
  37 + )=
  38 + with _web_action_name_message = message((Word32)0), //
  39 + forget(add_string(_web_action_name_message, "__TYPE__", "WEB_Action_Name"));
  40 + if _web_action_name is
  41 + {
  42 + //Alternative controller_action
  43 + controller_action(_controller, _action_name) then
  44 + forget(add_string(_web_action_name_message, "__TYPE_ALT__", "controller_action"));
  45 + // [type = String] controller_action.controller
  46 + forget(add_string(_web_action_name_message, "controller", _controller));
  47 + // [type = String] controller_action.action_name
  48 + forget(add_string(_web_action_name_message, "action_name", _action_name)),
  49 +
  50 + //Alternative action_name
  51 + action_name(_action_name) then
  52 + forget(add_string(_web_action_name_message, "__TYPE_ALT__", "action_name"));
  53 + // [type = String] action_name.action_name
  54 + forget(add_string(_web_action_name_message, "action_name", _action_name)),
  55 +
  56 + //Alternative url
  57 + //url is raw action, hence we will only copy that url in final link
  58 + url(_url_name) then
  59 + forget(add_string(_web_action_name_message, "__TYPE_ALT__", "url"));
  60 + // [type = String] url.url_name
  61 + forget(add_string(_web_action_name_message, "url_name", _url_name)),
  62 +
  63 + };
  64 + _web_action_name_message
  65 +.
  66 +
  67 +public define Maybe(WEB_Action_Name)
  68 + from_Message
  69 + (
  70 + Message _web_action_name_message
  71 + )=
  72 + if find_string(_web_action_name_message, "__TYPE__") is {failure then failure, success(__type__) then
  73 + if find_string(_web_action_name_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then
  74 + if __type__ = "WEB_Action_Name" then
  75 + //Alternative controller_action
  76 + if __type_alt__ = "controller_action" then //Alternative controller_action
  77 + // [type = String] controller_action.controller
  78 + if find_string(_web_action_name_message, "controller") is {failure then failure, success(controller) then
  79 + // [type = String] controller_action.action_name
  80 + if find_string(_web_action_name_message, "action_name") is {failure then failure, success(action_name) then
  81 +
  82 + success(controller_action(controller, action_name))
  83 + }}
  84 + else //Alternative action_name
  85 + if __type_alt__ = "action_name" then //Alternative action_name
  86 + // [type = String] action_name.action_name
  87 + if find_string(_web_action_name_message, "action_name") is {failure then failure, success(action_name) then
  88 +
  89 + success(action_name(action_name))
  90 + }
  91 + else //Alternative url
  92 + //url is raw action, hence we will only copy that url in final link
  93 + if __type_alt__ = "url" then //Alternative url
  94 + // [type = String] url.url_name
  95 + if find_string(_web_action_name_message, "url_name") is {failure then failure, success(url_name) then
  96 +
  97 + success(url(url_name))
  98 + }
  99 + else
  100 + failure //No valid Alternative found !
  101 + else
  102 + failure //Type not found in message !
  103 + }}
  104 +.
  105 +