Browse Source

use config settings

221V 1 year ago
parent
commit
c31e3423b4
2 changed files with 34 additions and 2 deletions
  1. 15 1
      README.md
  2. 19 1
      src/active.erl

+ 15 - 1
README.md

@@ -32,8 +32,22 @@ Usage
 -----
 
 On Mac/Linux/Windows just include into your rebar.config:
+```
+  {active, ".*", {git, "https://git.4dev.win/n4u/active.git", {tag, "6.2-erl19"}}}
+```
+add next code into your sys.config  
+for fs listen your apps/deps dirs  
+and active compiling erlydtl templates in apps/yor_app/priv/templates/  
 
-    {active, ".*", {git, "git://github.com/synrc/active", {tag,"0.5"}}}
+```
+{fs,
+ [{backwards_compatible, false}]
+},
+{active,
+ [{compile_on_templates, true},
+  {listen_paths, ["apps", "deps"]}
+ ]}
+```
 
 NOTE: on Linux please install inotify-tools.
 

+ 19 - 1
src/active.erl

@@ -21,7 +21,23 @@ start_link() ->
 
 
 init([]) ->
-  fs:subscribe(),
+  case {application:get_env(fs, backwards_compatible, false),
+        application:get_env(active, listen_paths, [])} of
+    %{true, []} -> fs:subscribe();
+    {true, _} ->
+      fs:subscribe();
+    {false, []} ->
+      fs:start_link(default_fs),
+      fs:subscribe();
+    {false, Paths} ->
+      lists:foldl(fun(Path, ok)->
+        Name = erlang:list_to_atom(Path),
+        fs:start_link(Name, Path),
+        fs:subscribe(Name),
+        ok
+      end, ok, Paths)
+  end,
+  
   erlang:process_flag(priority, low),
   gen_server:cast(self(), recompile_all),
   {ok, #state{last=fresh, root=fs:path()}}.
@@ -114,6 +130,8 @@ app(_App, ["priv", "windows" ++ _], _) -> skip;
 app(_App, ["priv", "linux" ++ _], _) -> skip;
 app(App, ["priv", "static"|_Rest], Path) ->
   compile_skip(compile_on_static, App, _Rest, Path);
+app(App, ["priv", "templates"|Rest], Path) ->
+  compile_skip(compile_on_templates, App, Rest, Path);
 app(App, ["priv"|Rest], Path) ->
   compile_skip(compile_on_priv, App, Rest, Path);
 app(App, ["include"|Rest], Path) ->