From dd92e2b5dca8080abfac3ff4abe29b6d29b32fec Mon Sep 17 00:00:00 2001 From: Luke van der Hoeven Date: Fri, 31 Jan 2014 11:34:27 -0500 Subject: [PATCH] fix for use with sinatra-cache seeing an issue where sinatra-cache takes over the rendering path and using `File.dirname` from the view is somewhere deep within the cache gem root. this ensures we have the right path --- lib/sidetiq/views/history.erb | 4 ++-- lib/sidetiq/views/locks.erb | 4 ++-- lib/sidetiq/views/schedule.erb | 4 ++-- lib/sidetiq/views/sidetiq.erb | 4 ++-- lib/sidetiq/web.rb | 8 ++++---- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/sidetiq/views/history.erb b/lib/sidetiq/views/history.erb index 0deb4c5..84a2242 100644 --- a/lib/sidetiq/views/history.erb +++ b/lib/sidetiq/views/history.erb @@ -1,4 +1,4 @@ -<%= File.read(File.join(File.dirname(__FILE__), 'views', 'assets', 'styles.css')) %> +<%= File.read(File.join(view_path, 'assets', 'styles.css')) %>
@@ -8,7 +8,7 @@
- <%= erb File.read(File.join(File.dirname(__FILE__), 'views', '_worker_nav.erb')) %> + <%= erb File.read(File.join(view_path, '_worker_nav.erb')) %>
diff --git a/lib/sidetiq/views/locks.erb b/lib/sidetiq/views/locks.erb index 3fbd518..e19009c 100644 --- a/lib/sidetiq/views/locks.erb +++ b/lib/sidetiq/views/locks.erb @@ -1,4 +1,4 @@ -<%= File.read(File.join(File.dirname(__FILE__), 'views', 'assets', 'styles.css')) %> +<%= File.read(File.join(view_path, 'assets', 'styles.css')) %>
@@ -8,7 +8,7 @@
- <%= erb File.read(File.join(File.dirname(__FILE__), 'views', '_home_nav.erb')) %> + <%= erb File.read(File.join(view_path, '_home_nav.erb')) %>
<% if @locks.length > 0 %> diff --git a/lib/sidetiq/views/schedule.erb b/lib/sidetiq/views/schedule.erb index 9f6b60e..f713afc 100644 --- a/lib/sidetiq/views/schedule.erb +++ b/lib/sidetiq/views/schedule.erb @@ -1,4 +1,4 @@ -<%= File.read(File.join(File.dirname(__FILE__), 'views', 'assets', 'styles.css')) %> +<%= File.read(File.join(view_path, 'assets', 'styles.css')) %>
@@ -8,7 +8,7 @@
- <%= erb File.read(File.join(File.dirname(__FILE__), 'views', '_worker_nav.erb')) %> + <%= erb File.read(File.join(view_path, '_worker_nav.erb')) %>
<% if (recurrences = @schedule.recurrence_rules).length > 0 %> diff --git a/lib/sidetiq/views/sidetiq.erb b/lib/sidetiq/views/sidetiq.erb index 6f37463..a2c9199 100644 --- a/lib/sidetiq/views/sidetiq.erb +++ b/lib/sidetiq/views/sidetiq.erb @@ -1,4 +1,4 @@ -<%= File.read(File.join(File.dirname(__FILE__), 'views', 'assets', 'styles.css')) %> +<%= File.read(File.join(view_path, 'assets', 'styles.css')) %>
@@ -8,7 +8,7 @@
- <%= erb File.read(File.join(File.dirname(__FILE__), 'views', '_home_nav.erb')) %> + <%= erb File.read(File.join(view_path, '_home_nav.erb')) %>
<% if @workers.length > 0 %> diff --git a/lib/sidetiq/web.rb b/lib/sidetiq/web.rb index 80f3ad6..835c0e9 100644 --- a/lib/sidetiq/web.rb +++ b/lib/sidetiq/web.rb @@ -8,13 +8,13 @@ module Sidetiq app.get "/sidetiq" do @workers = Sidetiq.workers @time = Sidetiq.clock.gettime - erb File.read(File.join(VIEWS, 'sidetiq.erb')) + erb File.read(File.join(VIEWS, 'sidetiq.erb')), locals: {view_path: VIEWS} end app.get "/sidetiq/locks" do @locks = Sidetiq::Lock::Redis.all.map(&:meta_data) - erb File.read(File.join(VIEWS, 'locks.erb')) + erb File.read(File.join(VIEWS, 'locks.erb')), locals: {view_path: VIEWS} end app.get "/sidetiq/:name/schedule" do @@ -28,7 +28,7 @@ module Sidetiq @schedule = @worker.schedule - erb File.read(File.join(VIEWS, 'schedule.erb')) + erb File.read(File.join(VIEWS, 'schedule.erb')), locals: {view_path: VIEWS} end app.get "/sidetiq/:name/history" do @@ -44,7 +44,7 @@ module Sidetiq redis.lrange("sidetiq:#{name}:history", 0, -1) end - erb File.read(File.join(VIEWS, 'history.erb')) + erb File.read(File.join(VIEWS, 'history.erb')), locals: {view_path: VIEWS} end app.post "/sidetiq/:name/trigger" do