221V 3 лет назад
Родитель
Сommit
c8a0c2a434

+ 2 - 2
README.md

@@ -58,9 +58,9 @@ All Features in One snippet
 
 ```erlang
 -module(index).
--compile(export_all).
+-compile([export_all, nowarn_export_all]).
 -include_lib("nitro/include/nitro.hrl").
--include_lib("n4u/include/wf.hrl").
+-include_lib("n4u/include/n4u.hrl").
 
 peer()    -> io_lib:format("~p",[wf:peer(?REQ)]).
 message() -> wf:js_escape(wf:html_encode(wf:q(message))).

+ 1 - 1
include/api.hrl

@@ -1,4 +1,4 @@
--include("wf.hrl").
+%-include("n4u.hrl").
 
 % n4u types
 

+ 8 - 17
include/wf.hrl → include/n4u.hrl

@@ -1,32 +1,23 @@
--ifndef(N4U_HRL).
--define(N4U_HRL, true).
 
 -record(handler, { name, module, class, group, config, state}).
 -record(cx,      { handlers, actions, req, module, lang, path, session, formatter=false, params, form, state=[] }).
 
--define(CTX, (get(context))).
--define(REQ, (get(context))#cx.req).
+-define(CTX, (erlang:get(context))).
+-define(REQ, (erlang:get(context))#cx.req).
 
-% API
-
--define(HANDLER_API, [init/2, finish/2]).
--define(FAULTER_API, [error_page/2]).
--define(ROUTING_API, [init/2, finish/2]).
--define(QUERING_API, [init/2, finish/2]).
--define(SESSION_API, [init/2, finish/2, get_value/2, set_value/2, clear/0]).
--define(PICKLES_API, [pickle/1, depickle/1]).
--define(MESSAGE_API, [send/2, reg/1, reg/2, unreg/1]).
 
 % IO protocol
 
 -record(io,      { eval, data }).
 -record(bin,     { data }).
 
+
 % Client/Server protocol
 
 -record(client,  { data }).
 -record(server,  { data }).
 
+
 % Nitrogen Protocol
 
 -record(pickle,  { source, pickled, args }).
@@ -34,12 +25,12 @@
 -record(direct,  { data }).
 -record(ev,      { module, msg, trigger, name }).
 
+
 % File Transfer Protocol
 
--record(ftp,     { id, sid, filename, meta, other1 = <<"">>, other2 = <<"">>, other3 = <<"">>, size, offset, block, data, status }).
+-record(ftp,     { id, sid, filename, meta, other1 = <<"">>, other2 = <<"">>, other3 = <<"">>, 'size', offset, block, data, status }).
 
-% HTTP
 
--record(http,     { url, method, body, headers = [] }).
+% HTTP
 
--endif.
+-record(http,    { url, method, body, headers = [] }).

+ 1 - 1
src/endpoints/cowboy/n2o_cowboy.erl

@@ -2,7 +2,7 @@
 -description('N2O Cowboy Server Bridge to HTTP Server Pages').
 -author('Roman Shestakov').
 -behaviour(cowboy_http_handler).
--include_lib("n4u/include/wf.hrl").
+-include_lib("n4u/include/n4u.hrl").
 -export([init/3, handle/2, terminate/3]).
 -compile([export_all, nowarn_export_all]).
 -record(state, {headers, body}).

+ 1 - 1
src/endpoints/n2o_document.erl

@@ -1,7 +1,7 @@
 -module(n2o_document).
 -description('N2O Server Pages HTTP endpoint handler').
 -author('Maxim Sokhatsky').
--include_lib("n4u/include/wf.hrl").
+-include_lib("n4u/include/n4u.hrl").
 -compile([export_all, nowarn_export_all]).
 
 transition(Actions) ->

+ 1 - 1
src/endpoints/n2o_proto.erl

@@ -1,7 +1,7 @@
 -module(n2o_proto).
 -description('N2O Protocol WebSocket endpoint handler').
 -author('Maxim Sokhatsky').
--include_lib("n4u/include/wf.hrl").
+-include_lib("n4u/include/n4u.hrl").
 -compile([export_all, nowarn_export_all]).
 
 formatter(O)-> case lists:keyfind(formatter,1,O) of {formatter,F} -> F; X -> X end.

+ 1 - 1
src/formatters/wf_convert.erl

@@ -1,7 +1,7 @@
 -module (wf_convert).
 -author('Maxim Sokhatsky').
 -compile([export_all, nowarn_export_all]).
--include_lib("n4u/include/wf.hrl").
+-include_lib("n4u/include/n4u.hrl").
 
 % WF to_atom to_list to_binary
 

+ 1 - 1
src/formatters/wf_utils.erl

@@ -1,6 +1,6 @@
 -module(wf_utils).
 -author('Rusty Klophaus').
--include_lib("n4u/include/wf.hrl").
+-include_lib("n4u/include/n4u.hrl").
 -compile([export_all, nowarn_export_all]).
 
 f(S) -> f(S, []).

+ 1 - 1
src/handlers/n2o_async.erl

@@ -1,6 +1,6 @@
 -module(n2o_async).
 -author('Maxim Sokhatsky').
--include_lib("n4u/include/wf.hrl").
+-include_lib("n4u/include/n4u.hrl").
 -behaviour(gen_server).
 -export([start_link/1]).
 -export([init/1,handle_call/3,handle_cast/2,handle_info/2,terminate/2,code_change/3]).

+ 2 - 2
src/handlers/n2o_error.erl

@@ -1,7 +1,7 @@
 -module(n2o_error).
--include_lib("n4u/include/wf.hrl").
+-include_lib("n4u/include/n4u.hrl").
 -compile([export_all, nowarn_export_all]).
--export(?FAULTER_API).
+-export([error_page/2]).
 
 % Plain Text Error Page Render
 % Here is sample

+ 2 - 2
src/handlers/n2o_mq.erl

@@ -1,6 +1,6 @@
 -module(n2o_mq).
--include_lib("n4u/include/wf.hrl").
--export(?MESSAGE_API).
+-include_lib("n4u/include/n4u.hrl").
+-export([send/2, reg/1, reg/2, unreg/1]).
 
 send(Pool, Message) -> gproc:send({p,l,Pool},Message).
 reg(Pool) -> reg(Pool,undefined).

+ 2 - 2
src/handlers/n2o_pickle.erl

@@ -1,6 +1,6 @@
 -module(n2o_pickle).
--include_lib("n4u/include/wf.hrl").
--export(?PICKLES_API).
+-include_lib("n4u/include/n4u.hrl").
+-export([pickle/1, depickle/1]).
 
 pickle(Data) -> base64:encode(term_to_binary({Data, os:timestamp()}, [compressed])).
 depickle(PickledData) ->

+ 2 - 2
src/handlers/n2o_query.erl

@@ -1,7 +1,7 @@
 -module(n2o_query).
 -author('Maxim Sokhatsky').
--include_lib("n4u/include/wf.hrl").
--export(?QUERING_API).
+-include_lib("n4u/include/n4u.hrl").
+-export([init/2, finish/2]).
 
 init(_State, Ctx) ->
     {Params,NewReq} = wf:params(Ctx#cx.req),

+ 2 - 2
src/handlers/n2o_secret.erl

@@ -1,8 +1,8 @@
 -module(n2o_secret).
 -author('Oleksandr Nikitin').
--include_lib("n4u/include/wf.hrl").
+-include_lib("n4u/include/n4u.hrl").
 -compile([export_all, nowarn_export_all]).
--export(?PICKLES_API).
+-export([pickle/1, depickle/1]).
 
 pickle(Data) ->
     Message = term_to_binary({Data,os:timestamp()}),

+ 1 - 1
src/handlers/n2o_session.erl

@@ -1,6 +1,6 @@
 -module(n2o_session).
 -author('Dmitry Krapivnoy').
--include_lib("n4u/include/wf.hrl").
+-include_lib("n4u/include/n4u.hrl").
 -include_lib("stdlib/include/ms_transform.hrl").
 -compile([export_all, nowarn_export_all]).
 

+ 2 - 2
src/handlers/n2o_syn.erl

@@ -1,6 +1,6 @@
 -module(n2o_syn).
--include_lib("n4u/include/wf.hrl").
--export(?MESSAGE_API).
+-include_lib("n4u/include/n4u.hrl").
+-export([send/2, reg/1, reg/2, unreg/1]).
 
 send(Pool, Message) -> syn:publish(term_to_binary(Pool),Message).
 reg(Pool) -> reg(Pool,undefined).

+ 1 - 1
src/n2o.erl

@@ -1,5 +1,5 @@
 -module(n2o).
--include_lib("n4u/include/wf.hrl").
+-include_lib("n4u/include/n4u.hrl").
 -export([test/0]).
 
 test() -> ok.

+ 1 - 1
src/n2o_cx.erl

@@ -1,7 +1,7 @@
 -module(n2o_cx).
 -description('N2O Process Context').
 -author('Rusty Klophaus').
--include_lib("n4u/include/wf.hrl").
+-include_lib("n4u/include/n4u.hrl").
 -compile([export_all, nowarn_export_all]).
 
 actions() -> get(actions).

+ 1 - 1
src/n4u_sup.erl

@@ -2,7 +2,7 @@
 
 -behaviour(supervisor).
 
--include_lib("n4u/include/wf.hrl").
+-include_lib("n4u/include/n4u.hrl").
 
 -export([start_link/0, init/1]).
 -export([proc/2]).

+ 1 - 1
src/protocols/n2o_client.erl

@@ -1,6 +1,6 @@
 -module(n2o_client).
 -author('Maxim Sokhatsky').
--include_lib("n4u/include/wf.hrl").
+-include_lib("n4u/include/n4u.hrl").
 -compile([export_all, nowarn_export_all]).
 
 info({client,Message}, Req, State) ->

+ 1 - 1
src/protocols/n2o_file.erl

@@ -1,6 +1,6 @@
 -module(n2o_file).
 -author('Andrii Zadorozhnii').
--include_lib("n4u/include/wf.hrl").
+-include_lib("n4u/include/n4u.hrl").
 -include_lib("kernel/include/file.hrl").
 -compile([export_all, nowarn_export_all]).
 

+ 1 - 1
src/protocols/n2o_heart.erl

@@ -1,6 +1,6 @@
 -module(n2o_heart).
 -author('Maxim Sokhatsky').
--include_lib("n4u/include/wf.hrl").
+-include_lib("n4u/include/n4u.hrl").
 -compile([export_all, nowarn_export_all]).
 
 info({text,<<"PING">> = _Ping}=Message, Req, State) ->

+ 1 - 1
src/protocols/n2o_http.erl

@@ -1,5 +1,5 @@
 -module(n2o_http).
--include_lib("n4u/include/wf.hrl").
+-include_lib("n4u/include/n4u.hrl").
 -compile([export_all, nowarn_export_all]).
 
 %% ws.send(enc(tuple(atom('http'), bin(url), bin(method), bin(body), [])));

+ 1 - 1
src/protocols/n2o_nitrogen.erl

@@ -1,6 +1,6 @@
 -module(n2o_nitrogen).
 -author('Maxim Sokhatsky').
--include_lib("n4u/include/wf.hrl").
+-include_lib("n4u/include/n4u.hrl").
 -compile([export_all, nowarn_export_all]).
 
 % Nitrogen pickle handler

+ 1 - 1
src/protocols/n2o_text.erl

@@ -1,6 +1,6 @@
 -module(n2o_text).
 -author('Alexander Salnikov').
--include_lib("n4u/include/wf.hrl").
+-include_lib("n4u/include/n4u.hrl").
 -compile([export_all, nowarn_export_all]).
 
 info({text,Text}=Message, Req, State) when is_binary(Text) ->

+ 1 - 1
src/wf.erl

@@ -1,7 +1,7 @@
 -module(wf).
 -author('Rusty Klophaus').
 -author('Maxim Sokhatsky').
--include_lib("n4u/include/wf.hrl").
+-include_lib("n4u/include/n4u.hrl").
 -include_lib("n4u/include/api.hrl").
 -compile([export_all, nowarn_export_all]).
 

+ 1 - 1
test/elements.erl

@@ -1,5 +1,5 @@
 -module(elements).
--include_lib("n4u/include/wf.hrl").
+-include_lib("n4u/include/n4u.hrl").
 -include_lib("common_test/include/ct.hrl").
 -compile(export_all).
 

+ 1 - 1
test/n2o_SUITE.erl

@@ -1,7 +1,7 @@
 -module(n2o_SUITE).
 -behaviour(cowboy_http_handler).
 -include_lib("common_test/include/ct.hrl").
--include_lib("n4u/include/wf.hrl").
+-include_lib("n4u/include/n4u.hrl").
 -compile(export_all).
 
 suite() -> [{timetrap,{seconds,30}}].