diff --git a/javascripts/dashing.coffee b/javascripts/dashing.coffee index fa677e80..03e42865 100644 --- a/javascripts/dashing.coffee +++ b/javascripts/dashing.coffee @@ -92,7 +92,7 @@ Dashing.widgets = widgets = {} Dashing.lastEvents = lastEvents = {} Dashing.debugMode = false -source = new EventSource('events') +source = new EventSource('/events') source.addEventListener 'open', (e) -> console.log("Connection opened", e) diff --git a/lib/dashing/app.rb b/lib/dashing/app.rb index 033849c7..52e47e39 100644 --- a/lib/dashing/app.rb +++ b/lib/dashing/app.rb @@ -74,16 +74,6 @@ def protected! end end -get '/:dashboard' do - protected! - tilt_html_engines.each do |suffix, _| - file = File.join(settings.views, "#{params[:dashboard]}.#{suffix}") - return render(suffix.to_sym, params[:dashboard].to_sym) if File.exist? file - end - - halt 404 -end - post '/dashboards/:id' do request.body.rewind body = JSON.parse(request.body.read) @@ -119,6 +109,17 @@ def protected! end end +get '/*' do + dashboard = File.join(params[:splat]) + protected! + tilt_html_engines.each do |suffix, _| + file = File.join(settings.views, "#{dashboard}.#{suffix}") + return render(suffix.to_sym, dashboard.to_sym) if File.exist? file + end + + halt 404 +end + def send_event(id, body, target=nil) body[:id] = id body[:updatedAt] ||= Time.now.to_i diff --git a/templates/project/dashboards/subdir/sample.erb b/templates/project/dashboards/subdir/sample.erb new file mode 100644 index 00000000..1771b233 --- /dev/null +++ b/templates/project/dashboards/subdir/sample.erb @@ -0,0 +1,56 @@ + + + +<% content_for :title do %>Subdirectory dashboard<% end %> + +