refactor development server
This commit is contained in:
parent
590361ae66
commit
0596390d10
|
@ -3,7 +3,7 @@ require 'ext/ember/namespace'
|
||||||
|
|
||||||
@Travis = Em.Namespace.create
|
@Travis = Em.Namespace.create
|
||||||
config:
|
config:
|
||||||
api_endpoint: $('meta[rel="travis.api_endpoint"]').attr('content')
|
api_endpoint: $('meta[rel="travis.api_endpoint"]').attr('href')
|
||||||
|
|
||||||
CONFIG_KEYS: ['rvm', 'gemfile', 'env', 'jdk', 'otp_release', 'php', 'node_js', 'perl', 'python', 'scala']
|
CONFIG_KEYS: ['rvm', 'gemfile', 'env', 'jdk', 'otp_release', 'php', 'node_js', 'perl', 'python', 'scala']
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ require 'ext/ember/namespace'
|
||||||
INTERVALS: { sponsors: -1, times: -1, updateTimes: 1000 }
|
INTERVALS: { sponsors: -1, times: -1, updateTimes: 1000 }
|
||||||
|
|
||||||
run: (attrs) ->
|
run: (attrs) ->
|
||||||
|
console.log "Connecting to #{Travis.config.api_endpoint}"
|
||||||
@app = Travis.App.create(attrs || {})
|
@app = Travis.App.create(attrs || {})
|
||||||
|
|
||||||
|
|
||||||
|
|
38
config.ru
38
config.ru
|
@ -1,19 +1,25 @@
|
||||||
$: << 'lib'
|
require 'sinatra/base'
|
||||||
|
|
||||||
require 'sinatra'
|
app = Sinatra.new do
|
||||||
require 'travis/api/app'
|
configure do
|
||||||
|
disable :protection
|
||||||
|
set :root, File.dirname(__FILE__)
|
||||||
|
set :public_folder, lambda { "#{root}/public" }
|
||||||
|
set :static_cache_control, :public
|
||||||
|
end
|
||||||
|
|
||||||
class App < Sinatra::Base
|
configure :test, :development do
|
||||||
disable :protection
|
set :endpoint, '/api'
|
||||||
|
end
|
||||||
|
|
||||||
set :root, File.dirname(__FILE__)
|
configure :production do
|
||||||
set :public_folder, lambda { "#{root}/public" }
|
require 'travis'
|
||||||
set :static_cache_control, :public
|
set :endpoint, "https://api.#{Travis.config.host}"
|
||||||
|
end
|
||||||
|
|
||||||
provides :html
|
get '*', provides: :html do
|
||||||
|
cache_control settings.static_cache_control
|
||||||
get '*' do
|
File.read('public/index.html').gsub('https://api.travis-ci.org', settings.endpoint)
|
||||||
File.new('public/index.html').readlines
|
|
||||||
end
|
end
|
||||||
|
|
||||||
not_found do
|
not_found do
|
||||||
|
@ -22,5 +28,11 @@ class App < Sinatra::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
use Rack::Deflater
|
use Rack::Deflater
|
||||||
run Rack::Cascade.new([Travis::Api::App.new(disable_root_endpoint: true), App])
|
|
||||||
|
|
||||||
|
if app.development?
|
||||||
|
require 'travis/api/app'
|
||||||
|
map(app.endpoint) { run Travis::Api::App.new }
|
||||||
|
map('/') { run app.new }
|
||||||
|
else
|
||||||
|
run app.new
|
||||||
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta rel="travis.api_endpoint" content="">
|
<meta rel="travis.api_endpoint" href="https://api.travis-ci.org">
|
||||||
<title>Travis CI - Distributed Continuous Integration Platform for the Open Source Community</title>
|
<title>Travis CI - Distributed Continuous Integration Platform for the Open Source Community</title>
|
||||||
<link rel="stylesheet" href="/stylesheets/application.css">
|
<link rel="stylesheet" href="/stylesheets/application.css">
|
||||||
<script src="/javascripts/vendor.js"></script>
|
<script src="/javascripts/vendor.js"></script>
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user