Current section

54 Versions

Jump to

Compare versions

19 files changed
+163 additions
-121 deletions
  @@ -6,7 +6,8 @@
6 6
7 7 [http://www.novaframework.org](http://www.novaframework.org)
8 8
9 - [![Build Status](https://travis-ci.org/novaframework/nova.svg?branch=master)](https://travis-ci.org/novaframework/nova)
9 + ![Build status](https://github.com/novaframework/nova/actions/workflows/erlang.yml/badge.svg)
10 +
10 11
11 12 ## Getting started
  @@ -8,14 +8,13 @@
8 8 <<"src/nova.erl">>,<<"src/nova.hrl">>,<<"src/nova_app.erl">>,
9 9 <<"src/nova_basic_handler.erl">>,<<"src/nova_erlydtl_inventory.erl">>,
10 10 <<"src/nova_handler.erl">>,<<"src/nova_handlers.erl">>,
11 - <<"src/nova_internal_error.dtl">>,<<"src/nova_plugin.erl">>,
12 - <<"src/nova_plugin_handler.erl">>,<<"src/nova_pubsub.erl">>,
13 - <<"src/nova_router.erl">>,<<"src/nova_router.hrl">>,
14 - <<"src/nova_security_handler.erl">>,<<"src/nova_session.erl">>,
15 - <<"src/nova_session_ets.erl">>,<<"src/nova_stream_h.erl">>,
16 - <<"src/nova_sup.erl">>,<<"src/nova_watcher.erl">>,
17 - <<"src/nova_websocket.erl">>,<<"src/nova_ws_handler.erl">>,
18 - <<"src/plugins/nova_correlation_plugin.erl">>,
11 + <<"src/nova_plugin.erl">>,<<"src/nova_plugin_handler.erl">>,
12 + <<"src/nova_pubsub.erl">>,<<"src/nova_router.erl">>,
13 + <<"src/nova_router.hrl">>,<<"src/nova_security_handler.erl">>,
14 + <<"src/nova_session.erl">>,<<"src/nova_session_ets.erl">>,
15 + <<"src/nova_stream_h.erl">>,<<"src/nova_sup.erl">>,
16 + <<"src/nova_watcher.erl">>,<<"src/nova_websocket.erl">>,
17 + <<"src/nova_ws_handler.erl">>,<<"src/plugins/nova_correlation_plugin.erl">>,
19 18 <<"src/plugins/nova_cors_plugin.erl">>,
20 19 <<"src/plugins/nova_plugin_utilities.erl">>,
21 20 <<"src/plugins/nova_request_plugin.erl">>,<<"src/views/nova_error.dtl">>]}.
  @@ -26,7 +25,7 @@
26 25 [{<<"cowboy">>,
27 26 [{<<"app">>,<<"cowboy">>},
28 27 {<<"optional">>,false},
29 - {<<"requirement">>,<<"2.9.0">>}]},
28 + {<<"requirement">>,<<"2.10.0">>}]},
30 29 {<<"erlydtl">>,
31 30 [{<<"app">>,<<"erlydtl">>},
32 31 {<<"optional">>,false},
  @@ -51,4 +50,4 @@
51 50 [{<<"app">>,<<"uuid">>},
52 51 {<<"optional">>,false},
53 52 {<<"requirement">>,<<"~>2.0.5">>}]}]}.
54 - {<<"version">>,<<"0.9.5">>}.
53 + {<<"version">>,<<"0.9.11">>}.
  @@ -1,10 +1,17 @@
1 1 %% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
2 2
3 3 {erl_opts, [debug_info]}.
4 - {erlydtl_opts, [{doc_root, "src"}, {recursive, true}]}.
4 + {src_dirs, ["src", "src/controllers"]}.
5 + {erlydtl_opts, [{doc_root, "src/views"},
6 + {recursive, true},
7 + {libraries, [
8 + {nova_erlydtl_inventory, nova_erlydtl_inventory}
9 + ]},
10 + {default_libraries, [nova_erlydtl_inventory]}
11 + ]}.
5 12
6 13 {deps, [
7 - {cowboy, "2.9.0"},
14 + {cowboy, "2.10.0"},
8 15 {uuid, "2.0.5", {pkg, uuid_erl}},
9 16 {erlydtl, "0.14.0"},
10 17 {jhn_stdlib, "3.6.2"},
  @@ -105,6 +112,7 @@
105 112
106 113 {ex_doc, [{proglang, erlang},
107 114 {main, <<"nova">>},
115 + {assets, <<"guides/images">>},
108 116 {extras, [<<"guides/quick-start.md">>,
109 117 <<"guides/routing.md">>,
110 118 <<"guides/controllers.md">>,
  @@ -113,7 +121,8 @@
113 121 <<"guides/building-releases.md">>,
114 122 <<"guides/books-and-links.md">>,
115 123 <<"guides/plugins.md">>,
116 - <<"guides/rebar3_nova.md">>]},
124 + <<"guides/rebar3_nova.md">>,
125 + <<"guides/nova-pubsub.md">>]},
117 126 {source_url, <<"https://github.com/novaframework/nova">>}
118 127 ]
119 128 }.
  @@ -1,6 +1,6 @@
1 1 {"1.2.0",
2 - [{<<"cowboy">>,{pkg,<<"cowboy">>,<<"2.9.0">>},0},
3 - {<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.11.0">>},1},
2 + [{<<"cowboy">>,{pkg,<<"cowboy">>,<<"2.10.0">>},0},
3 + {<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.12.1">>},1},
4 4 {<<"erlydtl">>,{pkg,<<"erlydtl">>,<<"0.14.0">>},0},
5 5 {<<"jhn_stdlib">>,{pkg,<<"jhn_stdlib">>,<<"3.6.2">>},0},
6 6 {<<"pmod_transform">>,{pkg,<<"pmod_transform">>,<<"1.1.0">>},0},
  @@ -11,8 +11,8 @@
11 11 {<<"uuid">>,{pkg,<<"uuid_erl">>,<<"2.0.5">>},0}]}.
12 12 [
13 13 {pkg_hash,[
14 - {<<"cowboy">>, <<"865DD8B6607E14CF03282E10E934023A1BD8BE6F6BACF921A7E2A96D800CD452">>},
15 - {<<"cowlib">>, <<"0B9FF9C346629256C42EBE1EEB769A83C6CB771A6EE5960BD110AB0B9B872063">>},
14 + {<<"cowboy">>, <<"FF9FFEFF91DAE4AE270DD975642997AFE2A1179D94B1887863E43F681A203E26">>},
15 + {<<"cowlib">>, <<"A9FA9A625F1D2025FE6B462CB865881329B5CAFF8F1854D1CBC9F9533F00E1E1">>},
16 16 {<<"erlydtl">>, <<"964B2DC84F8C17ACFAA69C59BA129EF26AC45D2BA898C3C6AD9B5BDC8BA13CED">>},
17 17 {<<"jhn_stdlib">>, <<"DBF19025FB1CCD7BEDCD19DC655A29618AA5943505DFE707C562E25F69C56BAA">>},
18 18 {<<"pmod_transform">>, <<"A3A4FA607B947C90410BC459DCA27F6B60D25D1588D568280F7276AC8767E106">>},
  @@ -22,8 +22,8 @@
22 22 {<<"thoas">>, <<"86A72CCDC5EC388A13F9F843BCD6C1076640233B95440E47FFB8E3C0DBDB5A17">>},
23 23 {<<"uuid">>, <<"60FAEEB7EDFD40847ED13CB0DD1044BAABE4E79A00C0CA9C4D13A073914B1016">>}]},
24 24 {pkg_hash_ext,[
25 - {<<"cowboy">>, <<"2C729F934B4E1AA149AFF882F57C6372C15399A20D54F65C8D67BEF583021BDE">>},
26 - {<<"cowlib">>, <<"2B3E9DA0B21C4565751A6D4901C20D1B4CC25CBB7FD50D91D2AB6DD287BC86A9">>},
25 + {<<"cowboy">>, <<"3AFDCCB7183CC6F143CB14D3CF51FA00E53DB9EC80CDCD525482F5E99BC41D6B">>},
26 + {<<"cowlib">>, <<"163B73F6367A7341B33C794C4E88E7DBFE6498AC42DCD69EF44C5BC5507C8DB0">>},
27 27 {<<"erlydtl">>, <<"D80EC044CD8F58809C19D29AC5605BE09E955040911B644505E31E9DD8143431">>},
28 28 {<<"jhn_stdlib">>, <<"C6F6AE9BC636B0011ABA7B4DACAFF549C0B5CFB58229EBD09959B77391F6ED47">>},
29 29 {<<"pmod_transform">>, <<"68C7FF7354C0D837681990D093D367FCC617C32570A1009B8E7ACFF6445499AA">>},
  @@ -12,13 +12,15 @@ not_found(Req) ->
12 12 JsonLib = nova:get_env(json_lib, thoas),
13 13 Json = erlang:apply(JsonLib, encode, [#{message => "Resource not found"}]),
14 14 {status, 404, #{<<"content-type">> => <<"application/json">>}, Json};
15 - _ ->
15 + <<"text/html">> ->
16 16 %% Just assume HTML
17 17 Variables = #{status => "Could not find the page you were looking for",
18 18 title => "404 Not found",
19 19 message => "We could not find the page you were looking for"},
20 20 {ok, Body} = nova_error_dtl:render(Variables),
21 - {status, 404, #{<<"content-type">> => <<"text/html">>}, Body}
21 + {status, 404, #{<<"content-type">> => <<"text/html">>}, Body};
22 + _ ->
23 + {status, 404, #{<<"content-type">> => <<"text/html">>}, <<>>}
22 24 end.
23 25
24 26 server_error(#{crash_info := #{status_code := StatusCode} = CrashInfo} = Req) ->
  @@ -34,9 +36,11 @@ server_error(#{crash_info := #{status_code := StatusCode} = CrashInfo} = Req) ->
34 36 JsonLib = nova:get_env(json_lib, thoas),
35 37 Json = erlang:apply(JsonLib, encode, [Variables]),
36 38 {status, StatusCode, #{<<"content-type">> => <<"application/json">>}, Json};
37 - _ ->
39 + <<"text/html">> ->
38 40 {ok, Body} = nova_error_dtl:render(Variables),
39 - {status, StatusCode, #{<<"content-type">> => <<"text/html">>}, Body}
41 + {status, StatusCode, #{<<"content-type">> => <<"text/html">>}, Body};
42 + _ ->
43 + {status, StatusCode, #{<<"content-type">> => <<"text/html">>}, <<>>}
40 44 end;
41 45 _ ->
42 46 {status, StatusCode}
  @@ -56,9 +60,11 @@ server_error(#{crash_info := #{stacktrace := Stacktrace, class := Class, reason
56 60 JsonLib = nova:get_env(json_lib, thoas),
57 61 Json = erlang:apply(JsonLib, encode, [Variables]),
58 62 {status, 500, #{<<"content-type">> => <<"application/json">>}, Json};
59 - _ ->
63 + <<"text/html">> ->
60 64 {ok, Body} = nova_error_dtl:render(Variables),
61 - {status, 500, #{<<"content-type">> => <<"text/html">>}, Body}
65 + {status, 500, #{<<"content-type">> => <<"text/html">>}, Body};
66 + _ ->
67 + {status, 500, #{<<"content-type">> => <<"text/html">>}, <<>>}
62 68 end;
63 69 _ ->
64 70 {status, 500}
  @@ -67,11 +73,29 @@ server_error(#{crash_info := #{stacktrace := Stacktrace, class := Class, reason
67 73
68 74 format_stacktrace([]) -> [];
69 75 format_stacktrace([{Mod, Func, Arity, [{file, File}, {line, Line}]}|Tl]) ->
70 - [#{module => erlang:atom_to_binary(Mod, utf8),
71 - function => erlang:atom_to_binary(Func, utf8),
72 - arity => Arity,
73 - file => erlang:list_to_binary(File),
74 - line => Line}|format_stacktrace(Tl)];
76 + Formated = #{module => erlang:atom_to_binary(Mod, utf8),
77 + function => erlang:atom_to_binary(Func, utf8),
78 + arity => format_arity(Arity, []),
79 + file => erlang:list_to_binary(File),
80 + line => Line},
81 + [Formated|format_stacktrace(Tl)];
75 82 format_stacktrace([Hd|Tl]) ->
76 83 logger:warning("Could not format stacktrace line: ~p", [Hd]),
77 84 format_stacktrace(Tl).
85 +
86 +
87 +
88 + format_arity(Arity) when is_pid(Arity) -> list_to_binary(pid_to_list(Arity));
89 + format_arity(Arity) when is_function(Arity) -> <<"fun">>;
90 + format_arity(Arity) -> Arity.
91 +
92 + format_arity([], Acc) ->
93 + logger:warning("Acc: ~p~n", [Acc]),
94 + Acc;
95 + format_arity([Head, Tail], Acc) ->
96 + Formated = format_arity(Head),
97 + format_arity(Tail, [Formated | Acc]);
98 + format_arity(Arity, _) when is_function(Arity)->
99 + <<"fun">>;
100 + format_arity(Arity, _) ->
101 + Arity.
\ No newline at end of file
Loading more files…