Browse Source

unwrap nitro:actions/0,1

221V 1 year ago
parent
commit
cd2567789b
4 changed files with 21 additions and 19 deletions
  1. 8 2
      CHANGELOG.md
  2. 1 1
      src/actions/action_manage.erl
  3. 1 5
      src/nitro.erl
  4. 11 11
      src/nitro_n2o.erl

+ 8 - 2
CHANGELOG.md

@@ -3,8 +3,14 @@
 
 
 ##### next version
-* unwrap nitro:jse -> nitro:js_escape  
-* unwrap nitro:hte -> nitro:html_encode  
+* unwrap:  
+```
+  nitro:jse/1 -> nitro:js_escape/1  
+  nitro:hte/1 -> nitro:html_encode/1  
+  nitro:actions/0 -> erlang:get(actions)  
+  nitro:actions/1 -> erlang:put(actions, Actions)  
+```
+* mv nitro_conv > nitro module  
 
 ##### 6.6.1-erl19
 * update to 6.6.1 tag by [@5HT Maksym Sokhatskyi/Namdak Tönpa](https://github.com/5HT)  

+ 1 - 1
src/actions/action_manage.erl

@@ -23,7 +23,7 @@ render_element(E) ->
   Pid = self(),
   Ref = make_ref(),
   spawn(fun() ->
-    Pid ! { nitro:render(E), Ref, wf:actions() }
+    Pid ! { nitro:render(E), Ref, erlang:get(actions) }
   end),
   receive
     {Rendered, Ref, Actions} -> {Rendered, Actions}

+ 1 - 5
src/nitro.erl

@@ -8,7 +8,7 @@
 
 -export([atom/1, q/1, q/2, qc/1, qc/2,
   config/3, pickle/1, depickle/1, unique_integer/0, temp_id/0,
-  script/0, script/1, actions/0, actions/1, state/1, state/2,
+  script/0, script/1, state/1, state/2,
   redirect/1, cookie_expire/1, cookie/2, cookie/3, cookies/0, cookie/1,
   f/1, f/2, coalesce/1,
   to_list/1, to_atom/1, to_binary/1, to_integer/1,
@@ -383,10 +383,6 @@ render_html(Elements) ->
   {Render, Ref, Actions}.
 
 
-actions() -> get(actions).
-actions(Ac) -> put(actions, Ac).
-
-
 insert_top(Target, Elements) when erlang:element(1, Elements) == tr ->
   insert_top(tbody, Target, Elements);
 insert_top(Target, Elements) ->

+ 11 - 11
src/nitro_n2o.erl

@@ -35,19 +35,19 @@ info(#init{token = Auth}, Req, State) ->
    Req, New};
 
 info(#client{data = Message}, Req, State) ->
-  nitro:actions([]),
+  erlang:put(actions, []),
   {reply, {bert, io(#client{data = Message}, State)}, Req, State};
 
 info(#pickle{} = Event, Req, State) ->
-  nitro:actions([]),
+  erlang:put(actions, []),
   {reply, {bert, html_events(Event, State)}, Req, State};
 
 info(#flush{data = Actions}, Req, State) ->
-  nitro:actions(Actions),
+  erlang:put(actions, Actions),
   {reply, {bert, io(<<>>)}, Req, State};
 
 info(#direct{data = Message}, Req, State) ->
-  nitro:actions([]),
+  erlang:put(actions, []),
   {reply, {bert,
      case io(Message, State) of
        {io, _, {stack, _}} = Io -> Io;
@@ -61,10 +61,10 @@ info(Message, Req, State) -> {unknown, Message, Req, State}.
 %% double render: actions could generate actions
 
 render_actions(Actions) ->
-  nitro:actions([]),
+  erlang:put(actions, []),
   First  = nitro:render(Actions),
-  Second = nitro:render(nitro:actions()),
-  nitro:actions([]),
+  Second = nitro:render(erlang:get(actions)),
+  erlang:put(actions, []),
   nitro:to_binary([First, Second]).
 
 
@@ -110,7 +110,7 @@ render_ev(#ev{module = M, name = F, msg = P, trigger = T}, _Source, Linked, Stat
 io(Event, #cx{module = Module}) ->
   try
     X = Module:event(Event),
-    {io, render_actions(nitro:actions()), X}
+    {io, render_actions(erlang:get(actions)), X}
   catch E:R:S ->
     ?LOG_EXCEPTION(E, R, S),
     {io, [], {stack, S}}
@@ -118,7 +118,7 @@ io(Event, #cx{module = Module}) ->
 
 
 io(Data) ->
-  try {io, render_actions(nitro:actions()), Data}
+  try {io, render_actions(erlang:get(actions)), Data}
   catch E:R:S ->
     ?LOG_EXCEPTION(E, R, S),
     {io, [], {stack, S}}
@@ -148,7 +148,7 @@ render_ev(#ev{module = M, name = F, msg = P, trigger = T}, _Source, Linked, Stat
 io(Event, #cx{module = Module}) ->
   try
     X = Module:event(Event),
-    {io, render_actions(nitro:actions()), X}
+    {io, render_actions(erlang:get(actions)), X}
   catch E:R ->
     S = erlang:get_stacktrace(),
     ?LOG_EXCEPTION(E, R, S),
@@ -157,7 +157,7 @@ io(Event, #cx{module = Module}) ->
 
 
 io(Data) ->
-  try {io, render_actions(nitro:actions()), Data}
+  try {io, render_actions(erlang:get(actions)), Data}
   catch E:R ->
     S = erlang:get_stacktrace(),
     ?LOG_EXCEPTION(E, R, S),