Sha256: 90a497cbb2e1617453e684749a16391a492bbe91ab5f12baad79180bd881d972

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

require 'sinatra'
require 'haml'
require 'fileutils'
require 'faker'
require File.dirname(__FILE__) + '/mercury/helpers'
require File.dirname(__FILE__) + '/mercury/images'

# Core Sinatra application to run mercury apps
class Mercury < Sinatra::Application
  helpers Sinatra::Helpers
  register Sinatra::Images
  
  set :root,  FileUtils.pwd.gsub("\n",'')
  set :public, File.dirname(__FILE__) + '/public'
  set :views, FileUtils.pwd.gsub("\n",'') + '/wwwroot'
  
  get '/*' do
    view_file_request = params["splat"][0]  
    haml view_file_request.empty? ? view_file = get_view('index.haml') : view_file_request.to_sym, :layout => get_view('layout.haml')
  end

  
private  
    
  def get_view(filename)
    full_file = File.join(options.views, filename)
    if File.exists?(full_file)
      view_file = full_file 
    else
      view_directory = File.join(File.dirname(__FILE__),'views')
      view_file = File.join(view_directory,filename)
    end
    open(view_file,'r') { |file| file.read }
  end
  
  
  
  
  
    
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mercury-0.9.4 lib/mercury.rb