Sha256: d6e718ec2fe692658f236e09231d47fdd332579d68dc0abbccc245bd6872a8e1
Contents?: true
Size: 1.88 KB
Versions: 2
Compression:
Stored size: 1.88 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 def self.enable_sessions! enable :sessions end 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/*" do params[:app_name] = params[:splat].first halt 404 unless params[:app_name] @application = Application.new(params[:app_name]) @revisions = @application.revisions erb :application end post "/applications/*/activate/*" do params[:app_name], params[:revision_name] = params[:splat] 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ember_cli_deploy_redis-1.0.2 | lib/ember_cli_deploy_redis/web.rb |
ember_cli_deploy_redis-1.0.1 | lib/ember_cli_deploy_redis/web.rb |