Anonymous avatar Anonymous committed 0b61d6b

in wmtrace_resource, find webmachine install with code:lib_dir/1 instead of depending on it being in deps/webmachine

Comments (0)

Files changed (1)

src/wmtrace_resource.erl

 -record(ctx, {trace_dir, trace}).
 
 -define(MAP_EXTERNAL, "static/map.png").
--define(MAP_INTERNAL, "deps/webmachine/docs/http-headers-status-v3.png").
+-define(MAP_INTERNAL, "docs/http-headers-status-v3.png").
 -define(SCRIPT_EXTERNAL, "static/wmtrace.js").
--define(SCRIPT_INTERNAL, "deps/webmachine/trace/wmtrace.js").
+-define(SCRIPT_INTERNAL, "trace/wmtrace.js").
 -define(STYLE_EXTERNAL, "static/wmtrace.css").
--define(STYLE_INTERNAL, "deps/webmachine/trace/wmtrace.css").
+-define(STYLE_INTERNAL, "trace/wmtrace.css").
 
 %%
 %% Dispatch Modifiers
                      Ctx}
             end;
         ?MAP_EXTERNAL ->
-            {filelib:is_file(?MAP_INTERNAL), RD, Ctx};
+            {filelib:is_file(wm_path(?MAP_INTERNAL)), RD, Ctx};
         ?SCRIPT_EXTERNAL ->
-            {filelib:is_file(?SCRIPT_INTERNAL), RD, Ctx};
+            {filelib:is_file(wm_path(?SCRIPT_INTERNAL)), RD, Ctx};
         ?STYLE_EXTERNAL ->
-            {filelib:is_file(?STYLE_INTERNAL), RD, Ctx};
+            {filelib:is_file(wm_path(?STYLE_INTERNAL)), RD, Ctx};
         TraceName ->
             TracePath = filename:join([Ctx#ctx.trace_dir, TraceName]),
             {filelib:is_file(TracePath), RD, Ctx#ctx{trace=TracePath}}
     end.
 
+wm_path(File) ->
+    filename:join(code:lib_dir(webmachine), File).
+
 content_types_provided(RD, Ctx) ->
     case wrq:disp_path(RD) of
         ?MAP_EXTERNAL ->
          ]).
 
 produce_javascript(RD, Ctx) ->
-    {ok, Script} = file:read_file(?SCRIPT_INTERNAL),
+    {ok, Script} = file:read_file(wm_path(?SCRIPT_INTERNAL)),
     {Script, RD, Ctx}.
 
 produce_map(RD, Ctx) ->
-    {ok, Map} = file:read_file(?MAP_INTERNAL),
+    {ok, Map} = file:read_file(wm_path(?MAP_INTERNAL)),
     {Map, RD, Ctx}.
 
 produce_css(RD, Ctx) ->
-    {ok, Script} = file:read_file(?STYLE_INTERNAL),
+    {ok, Script} = file:read_file(wm_path(?STYLE_INTERNAL)),
     {Script, RD, Ctx}.
 
 %%
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.