From 6dcda5d7cd26514cac1b18438af7913105e68f00 Mon Sep 17 00:00:00 2001 From: Daniel Beauchamp Date: Wed, 13 Feb 2013 21:32:34 -0500 Subject: Added the public directory for serving static assets. This allows for stuff like favicons and custom 404/500 pages. --- lib/dashing.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/dashing.rb b/lib/dashing.rb index 04e4cee..bae4c29 100644 --- a/lib/dashing.rb +++ b/lib/dashing.rb @@ -49,7 +49,11 @@ end get '/:dashboard' do protected! - erb params[:dashboard].to_sym + if File.exist? File.join(settings.views, "#{params[:dashboard]}.erb") + erb params[:dashboard].to_sym + else + halt 404 + end end get '/views/:widget?.html' do @@ -71,6 +75,10 @@ post '/widgets/:id' do end end +not_found do + send_file File.join(settings.public_folder, '404.html') +end + def development? ENV['RACK_ENV'] == 'development' end -- cgit v1.2.3