Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rtomayko/57920 to your computer and use it in GitHub Desktop.
Save rtomayko/57920 to your computer and use it in GitHub Desktop.
require 'sinatra'
require 'compass'
require 'ostruct'
enable :static, :logging
set :views, "#{root}/app/views"
set :haml, :format => :html4, :attr_wrapper => '"'
set :sass, :style => :compact
load "#{root}/app/models/models.rb"
load "#{root}/lib/helpers.rb"
## Import the Site Configs
Settings = OpenStruct.new(YAML.load_file("#{root}/config/settings.yml"))
Page = OpenStruct.new(:title => "Undefined")
configure do
::DataMapper.setup(:default, "sqlite3:db/#{environment}.sqlite3")
::DataMapper.auto_upgrade!
::DataMapper.logger.set_log('log/dm.log', :debug)
end
helpers do
alias_method :h, :escape_html
# ... more helpers ...
end
get '/' do
@title = 'HOME'
@posts = Post.all
erb :index, :layout => :application
end
get '/about/?' do
erb :about
end
get '/sinatra' do
out = "Powered by Sinatra v#{Sinatra::VERSION} running in '#{Sinatra::Base.environment}' mode.\n"
erb( out )
end
get "/stylesheets/*.css" do
content_type 'text/css', :charset => 'utf-8'
# Use views/stylesheets & blueprint's stylesheet dirs in the Sass load path
sass "stylesheets/#{params[:splat]}".to_sym, {
:sass => {
:style => :compact,
:load_paths => (
[ File.join(APP_ROOT, 'app', 'views', 'stylesheets') ] + Compass::Frameworks::ALL.map { |f| f.stylesheets_directory }
)
}
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment