Allow to set assets host with ASSETS_HOST

This can be used to set a specific host for a CDN.
This commit is contained in:
Piotr Sarnacki 2015-01-19 10:40:46 +01:00
parent 8c54341815
commit d53987c6e8
3 changed files with 8 additions and 3 deletions

View File

@ -63,5 +63,5 @@ run Travis::Web::App.build(
customer_io_site_id: ENV['CUSTOMER_IO_SITE_ID'], customer_io_site_id: ENV['CUSTOMER_IO_SITE_ID'],
pro: ENV['TRAVIS_PRO'], pro: ENV['TRAVIS_PRO'],
code_climate: ENV['CODE_CLIMATE'], code_climate: ENV['CODE_CLIMATE'],
code_climate_url: ENV['CODE_CLIMATE_URL'] code_climate_url: ENV['CODE_CLIMATE_URL'],
) )

View File

@ -94,6 +94,7 @@ class Travis::Web::App
else else
set_config(content, options) if config_needed?(file) set_config(content, options) if config_needed?(file)
set_title(content) if index?(file) set_title(content) if index?(file)
set_assets_host(content) if index?(file)
headers = { headers = {
'Content-Length' => content.bytesize.to_s, 'Content-Length' => content.bytesize.to_s,
@ -158,6 +159,10 @@ class Travis::Web::App
content.gsub!(/\{\{title\}\}/, ENV['SITE_TITLE'] || default_title) content.gsub!(/\{\{title\}\}/, ENV['SITE_TITLE'] || default_title)
end end
def set_assets_host(content)
content.gsub!(/\{\{assets_host\}\}/, ENV['ASSETS_HOST'] || '')
end
def set_config(string, opts = {}) def set_config(string, opts = {})
string.gsub! %r(<meta (rel|name)="travis\.([^"]*)" (href|value)="([^"]*)"[^>]*>) do string.gsub! %r(<meta (rel|name)="travis\.([^"]*)" (href|value)="([^"]*)"[^>]*>) do
%(<meta #{$1}="travis.#{$2}" #{$3}="#{options[$2.to_sym] || $4}">) %(<meta #{$1}="travis.#{$2}" #{$3}="#{options[$2.to_sym] || $4}">)

View File

@ -23,8 +23,8 @@
<link rel="dns-prefetch" href="//api.github.com"> <link rel="dns-prefetch" href="//api.github.com">
<link rel="dns-prefetch" href="//www.gravatar.com"> <link rel="dns-prefetch" href="//www.gravatar.com">
<link rel="icon" type="image/png" href="/favicon.ico"> <link rel="icon" type="image/png" href="/favicon.ico">
<link rel="stylesheet" href="/styles/app.css"> <link rel="stylesheet" href="{{assets_host}}/styles/app.css">
<script src="/scripts/app.js"></script> <script src="{{assets_host}}/scripts/app.js"></script>
<script> <script>
minispade.require('travis') minispade.require('travis')
Travis.run() Travis.run()