Sha256: b97569642a995405390029615c2d254635708346e47c7f4b13d149c4ab9a7365
Contents?: true
Size: 1.76 KB
Versions: 1
Compression:
Stored size: 1.76 KB
Contents
require 'erb' require 'yaml' require 'sinatra/base' require 'ember_cli_deploy_redis' require 'ember_cli_deploy_redis/web_helpers' module EmberCliDeployRedis class Web < Sinatra::Base enable :sessions use Rack::Protection, :use => :authenticity_token unless ENV['RACK_ENV'] == 'test' set :root, File.expand_path(File.dirname(__FILE__) + "/../../web") set :public_folder, proc { "#{root}/assets" } set :views, proc { "#{root}/views" } set :locales, ["#{root}/locales"] helpers WebHelpers get '/' do @applications = EmberCliDeployRedis.configuration.web_application_names.map { |name| Application.new(name) } erb :dashboard end get "/applications/:app_name" do halt 404 unless params[:app_name] @application = Application.new(params[:app_name]) @revisions = @application.revisions erb :application end post "/applications/:app_name/activate/:revision_name" do halt 404 unless params[:app_name] halt 404 unless params[:revision_name] application = Application.new(params[:app_name]) revision = application.revision_by_name(params[:revision_name]) if EmberCliDeployRedis.configuration.on_revision_activated_block EmberCliDeployRedis.configuration.on_revision_activated_block.call(revision) end revision.activate! redirect_with_query("#{root_path}applications/#{application.name}") end end end if defined?(::ActionDispatch::Request::Session) && !::ActionDispatch::Request::Session.respond_to?(:each) # mperham/sidekiq#2460 # Rack apps can't reuse the Rails session store without # this monkeypatch class ActionDispatch::Request::Session def each(&block) hash = self.to_hash hash.each(&block) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ember_cli_deploy_redis-1.0.0 | lib/ember_cli_deploy_redis/web.rb |