Created
April 16, 2013 18:40
-
-
Save kleinmatic/5398423 to your computer and use it in GitHub Desktop.
How we serve static graphics that can't fit in our CMS using sinatra. We have a layout file that pulls in the header and footer from the main site (and uses content_for to populate the page title and stuff like that.) You are never more than 15 minutes away from implementing this.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
require 'sinatra/content_for' | |
set :static, true | |
Dir.glob("#{:views}/*").each do |file| | |
next if file =~ /layout.*/ | |
url = File.basename(file, ".erb") | |
get "/#{url}" do | |
erb url.to_sym | |
end | |
end | |
not_found do | |
erb :'404', :layout => :layout_basic | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment