#!/usr/bin/env ruby require 'rbbt/util/simpleopt' require 'rbbt/workflow' require 'zurb-foundation' require 'modular-scale' require 'rbbt/rest/main' require 'rbbt/rest/entity' require 'rbbt/rest/workflow' require 'rbbt/rest/file_server' require 'rbbt/rest/helpers' options = SOPT.get "-e--environment*:-p--port*" workflow = ARGV.first YAML::ENGINE.yamler = 'syck' if defined? YAML::ENGINE and YAML::ENGINE.respond_to? :yamler Workflow.require_workflow workflow class WorkflowRest < Sinatra::Base get '/' do redirect to(File.join('/', Workflow.workflows.last.to_s)) end end ENV["RACK_ENV"] = options[:environment] if options.include?(:environment) class WorkflowRest < Sinatra::Base #{{{ MODULES AND HELPERS register Sinatra::RbbtRESTMain register Sinatra::RbbtRESTWorkflow register Sinatra::RbbtRESTEntity helpers Sinatra::RbbtMiscHelpers #{{{ DIRECTORIES local_var = Rbbt.var.find(:user) set :cache_dir , local_var.sinatra.cache.find set :file_dir , local_var.sinatra.files.find set :favourites_dir , local_var.sinatra.favourites.find set :favourite_lists_dir , local_var.sinatra.favourite_lists #{{{ SESSIONS use Rack::Session::Cookie, :key => 'rack.session', :path => '/', :expire_after => 2592000, :secret => "Workflow #{Workflow.workflows.inspect} secret!!" #{{{ FOUNDATION RESOURCES add_sass_load_path "#{Gem.loaded_specs['compass'].full_gem_path}/frameworks/compass/stylesheets" add_sass_load_path "#{Gem.loaded_specs['zurb-foundation'].full_gem_path}/scss/" add_sass_load_path "#{Gem.loaded_specs['modular-scale'].full_gem_path}/stylesheets/" RbbtRESTHelpers.javascript_resources << Path.setup("#{Gem.loaded_specs['zurb-foundation'].full_gem_path}/js/foundation") RbbtRESTHelpers.javascript_resources << Path.setup("#{Gem.loaded_specs['zurb-foundation'].full_gem_path}/js/vendor") $title = "Workflow Scout" use Rack::Deflater end WorkflowRest.add_workflow Workflow.workflows.last, true WorkflowRest.port = options[:port] || 4567 WorkflowRest.bind = options[:bind] || "0.0.0.0" WorkflowRest.run!