Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Returned the original erlang.mk
  • Loading branch information
mhishami committed Nov 21, 2015
1 parent 431986d commit 8588338
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 14 deletions.
2 changes: 1 addition & 1 deletion example/foo/include/foo.hrl
Expand Up @@ -6,4 +6,4 @@
-define(INFO(Text, Args), lager:log(info, ?MODULE, "~p:~p: " ++ Text, [?MODULE, ?LINE | Args])).
-define(ERROR(Text, Args), lager:log(error, ?MODULE, "~p:~p: " ++ Text, [?MODULE, ?LINE | Args])).

-define (DB_USERS, <<"users">>).
-define(DB_USERS, <<"users">>).
4 changes: 4 additions & 0 deletions example/foo/priv/static/dist/js/jquery.min.js

Large diffs are not rendered by default.

12 changes: 2 additions & 10 deletions example/foo/src/foo.app.src
Expand Up @@ -6,19 +6,11 @@
{applications, [
kernel,
stdlib,
sasl,
crypto,
mnesia,
tuah,
sync,
cowboy,
erlydtl,
jsx,
lager,
cowlib,
ranch,
bson,
pbkdf2,
mongodb
sync
]},
{mod, {foo_app, []}},
{env, [
Expand Down
5 changes: 3 additions & 2 deletions example/foo/src/foo_sup.erl
@@ -1,12 +1,13 @@
-module(foo_sup).
-behaviour(supervisor).

-include ("foo.hrl").

-export([start_link/0]).
-export([init/1]).

start_link() ->
supervisor:start_link({local, ?MODULE}, ?MODULE, []).

init([]) ->
Procs = [],
{ok, {{one_for_one, 1, 5}, Procs}}.
{ok, {{one_for_one, 1, 5}, []}}.
22 changes: 22 additions & 0 deletions example/foo/src/home_ws_controller.erl
@@ -0,0 +1,22 @@
-module (home_ws_controller).
-behaviour (tuah_ws_controller).

-include ("foo.hrl").

-export ([version/0]).
-export ([handle_ws/2]).

version() -> 1.0.

handle_ws(Data, _Req) ->
?DEBUG("Data received: ~p~n", [Data]),
case Data of
{text, Val} ->
Reply = jsx:decode(Val),
?DEBUG("Data received: ~p", [Reply]),
{text, Reply};
_ ->
{text, [{ok, <<"processed">>}]}
end.


4 changes: 4 additions & 0 deletions example/foo/templates/home.dtl
Expand Up @@ -89,5 +89,9 @@

<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="/static/assets/assets/js/ie10-viewport-bug-workaround.js"></script>

{% block js %}
{% endblock %}

</body>
</html>
34 changes: 33 additions & 1 deletion example/foo/templates/public.dtl
Expand Up @@ -12,4 +12,36 @@
{% endif %}
</div>

{% endblock %}
{% endblock %}

{% block js %}
<script src="/static/dist/js/jquery.min.js"></script>
<script type="text/javascript">
var ws;
$(function() {
ws_tuah.init()
}), ws_tuah = {
init: function() {
ws = new WebSocket("ws://localhost:8080/ws");
ws.onopen = function(e) { ws_tuah.onOpen(e) };
ws.onclose = function(e) { ws_tuah.onClose(e) };
ws.onmessage = function(evt) { ws_tuah.onMessage(evt) };
},
onOpen: function(e) {
data = {
url: '/messages',
auth: 'hisham',
session_id: '"4a2703d7-e025-454b-916c-0e871c63b0bc"'
};
ws.send(JSON.stringify(data));
console.log('Data sent...');
},
onClose: function(e) {
console.log('Socket closed');
},
onMessage: function(e) {
console.log(e.data);
}
};
</script>
{% endblock %}

0 comments on commit 8588338

Please sign in to comment.