Namdak Tonpa 6 years ago
parent
commit
3e28aef622
4 changed files with 17 additions and 8 deletions
  1. 3 0
      .gitignore
  2. 1 1
      include/mad.hrl
  3. BIN
      mad
  4. 13 7
      src/mad_static.erl

+ 3 - 0
.gitignore

@@ -6,3 +6,6 @@ logs
 deps
 .DS_Store
 .applist
+erlang.log.1
+run_erl.log
+rebar3

+ 1 - 1
include/mad.hrl

@@ -1 +1 @@
--define(VERSION,"500247").
+-define(VERSION,"0a124f").

BIN
mad


+ 13 - 7
src/mad_static.erl

@@ -54,18 +54,24 @@ compile_static(Files) ->
         {_,0,_} -> {ok,static};
         {_,_,_} -> mad:info("error while compiling assets~n"), {error,"Static compile."} end.
 
-app([]) -> app(["sample"]);
-app(Params) ->
-    [Name] = Params,
+app([]) -> app(["web","sample"]);
+app([Name]) -> app(["web",Name]);
+app([Skeleton,Name|_]) ->
+    io:format("Scaffolding ~p Name ~p~n",[Skeleton,Name]),
     mad_repl:load(),
     Apps = ets:tab2list(filesystem),
     try
-    [ case string:str(File,"priv/web") of
-       1 -> Relative = unicode:characters_to_list(Name ++
-                       string:replace(string:substr(File, 9), "sample", Name, all), utf8),
+    [ begin %io:format("File: ~p~n",[{File,Name,string:replace(File, "sample", Name, all)}]),
+       case string:str(File,"priv/"++Skeleton) of
+       1 -> Relative = unicode:characters_to_list(Name++
+                       string:replace(
+                       string:replace(File, "sample", Name, all),
+                                     "priv/"++Skeleton, "", all), utf8),
             mad:info("Created: ~p~n",[Relative]),
             filelib:ensure_dir(Relative),
             BinNew = string:replace(Bin, "sample", Name, all),
             file:write_file(Relative, BinNew);
        _ -> skip
-       end || {File,Bin} <- Apps, is_list(File) ], {ok,Name} catch _:_ -> {error,"Skeleton failed."} end.
+       end end || {File,Bin} <- Apps, is_list(File)],
+       {ok,Name}
+    catch _:_ -> {error,"Skeleton failed."} end.