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 +++++++++- templates/project/assets/images/favicon.ico | Bin 5430 -> 0 bytes templates/project/public/404.html | 26 ++++++++++++++++++++++++++ templates/project/public/favicon.ico | Bin 0 -> 5430 bytes 4 files changed, 35 insertions(+), 1 deletion(-) delete mode 100644 templates/project/assets/images/favicon.ico create mode 100644 templates/project/public/404.html create mode 100644 templates/project/public/favicon.ico 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 diff --git a/templates/project/assets/images/favicon.ico b/templates/project/assets/images/favicon.ico deleted file mode 100644 index 29a408f..0000000 Binary files a/templates/project/assets/images/favicon.ico and /dev/null differ diff --git a/templates/project/public/404.html b/templates/project/public/404.html new file mode 100644 index 0000000..1a8f334 --- /dev/null +++ b/templates/project/public/404.html @@ -0,0 +1,26 @@ + + + + This Dashboard doesn't exist. + + + + + +
+

Drats! That Dashboard doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+ + \ No newline at end of file diff --git a/templates/project/public/favicon.ico b/templates/project/public/favicon.ico new file mode 100644 index 0000000..29a408f Binary files /dev/null and b/templates/project/public/favicon.ico differ -- cgit v1.2.3