Browse Source

new sample app without wf:flush/0

Namdak Tonpa 10 years ago
parent
commit
69522fb0ef

BIN
mad


+ 0 - 20
priv/web/apps/n2o_sample/src/index.erl

@@ -1,20 +0,0 @@
--module(index).
--compile(export_all).
--include_lib("n2o/include/wf.hrl").
-
-peer()    -> io_lib:format("~p",[wf:peer(?REQ)]).
-message() -> wf:js_escape(wf:html_encode(wf:q(message))).
-main()    -> #dtl{file="index",app=n2o_sample,bindings=[{body,body()}]}.
-body() ->
-    {ok,Pid} = wf:comet(fun() -> chat_loop() end), 
-    [ #panel{id=history}, #textbox{id=message},
-      #button{id=send,body="Chat",postback={chat,Pid},source=[message]} ].
-
-event(init) -> wf:reg(room);
-event({chat,Pid}) -> Pid ! {peer(), message()};
-event(Event) -> skip.
-
-chat_loop() ->
-    receive {Peer, Message} -> 
-       wf:insert_bottom(history,#panel{id=history,body=[Peer,": ",Message,#br{}]}),
-       wf:flush(room) end, chat_loop().

+ 1 - 1
priv/web/apps/rebar.config

@@ -1,3 +1,3 @@
-{sub_dirs, [ "n2o_sample" ]}.
+{sub_dirs, [ "sample" ]}.
 {lib_dirs, ["../apps"]}.
 {deps_dir, ["../deps"]}.

+ 0 - 0
priv/web/apps/n2o_sample/priv/static/spa/index.htm → priv/web/apps/sample/priv/static/spa/index.htm


+ 0 - 0
priv/web/apps/n2o_sample/priv/static/synrc.css → priv/web/apps/sample/priv/static/synrc.css


+ 0 - 0
priv/web/apps/n2o_sample/priv/templates/index.html → priv/web/apps/sample/priv/templates/index.html


+ 0 - 0
priv/web/apps/n2o_sample/rebar.config → priv/web/apps/sample/rebar.config


+ 13 - 0
priv/web/apps/sample/src/index.erl

@@ -0,0 +1,13 @@
+-module(index).
+-compile(export_all).
+-include_lib("n2o/include/wf.hrl").
+
+peer()    -> io_lib:format("~p",[wf:peer(?REQ)]).
+message() -> wf:js_escape(wf:html_encode(wf:q(message))).
+main()    -> #dtl{file="index",app=n2o_sample,bindings=[{body,body()}]}.
+body()    -> [ #panel{id=history}, #textbox{id=message},
+               #button{id=send,body="Chat",postback=chat,source=[message]} ].
+
+event(init) -> wf:reg(room);
+event(chat) -> wf:insert_bottom(history,#panel{id=history,body=[peer(),": ",message(),#br{}]});
+event(Event) -> wf:info(?MODULE,"Unknown Event: ~p~n",[Event]).

+ 0 - 0
priv/web/apps/n2o_sample/src/routes.erl → priv/web/apps/sample/src/routes.erl


+ 1 - 1
priv/web/apps/n2o_sample/src/n2o_sample.app.src → priv/web/apps/sample/src/sample.app.src

@@ -1,4 +1,4 @@
-{application, n2o_sample,
+{application, sample,
  [
   {description, "N2O VXZ Sample App"},
   {vsn, "1"},

+ 3 - 1
priv/web/apps/n2o_sample/src/web_app.erl → priv/web/apps/sample/src/web_app.erl

@@ -1,8 +1,10 @@
 -module(web_app).
 -behaviour(application).
--export([start/0, start/2, stop/1, main/1]).
+-export([start/0, start/2, stop/1, main/1, log_modules/0]).
 
 main(A) -> mad_repl:main(A,[]).
 start() -> start(normal, []).
 start(_StartType, _StartArgs) -> web_sup:start_link().
 stop(_State) -> ok.
+
+log_modules() -> [n2o_websocket,n2o_client,n2o_heart,n2o_nitrogen,bullet_handler].

+ 0 - 0
priv/web/apps/n2o_sample/src/web_sup.erl → priv/web/apps/sample/src/web_sup.erl


+ 1 - 1
priv/web/sys.config

@@ -1,4 +1,4 @@
 [
- {n2o, [{port,8000},{route,routes}]},
+ {n2o, [{port,8000},{route,routes},{log_modules,web_app}]},
  {kvs, [{dba,store_mnesia}, {schema, [kvs_user, kvs_acl, kvs_feed, kvs_subscription ]} ]}
 ].