Skip to content

Instantly share code, notes, and snippets.

@kleinmatic
Created April 16, 2013 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kleinmatic/5398423 to your computer and use it in GitHub Desktop.
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.
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