johnhamelink
4/3/2013 - 10:15 PM

app.rb

require 'sinatra/base'
require './xerotime.rb'


# Configure the defaults.
class FarmGeek < Sinatra::Base

    enable :sessions
    use Rack::Session::Pool, :expire_after => 7200

    configure do
        # Connect the hostname to sinatra
        # so that when we visit the hostname,
        # it (and all links) resolve correctly.
        set :bind, ENV['host']
    end

    get '/' do
        # Set the navigation item for the
        # view helper
        Navigation::set "home"
        erb :index
    end

    before do
        # Set the user session if it exists.
        @user = session[:user] if session[:user]
    end

    after do
        # Reset the navigation
        Navigation::reset
        Title::reset
    end
end

# go through all the controllers and require them
# so that they are available on request.
Dir.glob("controllers/*.rb").each { |r| require_relative r }

# Go through all the helpers and require them
# so that they are available on request.
Dir.glob("helpers/*.rb").each { |r| require_relative r }