From 3eb07394e79ae8ff303345dd6a32b8ca5d41151a Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 19 Jan 2015 11:36:56 +0100 Subject: [PATCH] Use already existing mechanism for assets_host --- config.ru | 1 + lib/travis/web/app.rb | 10 ++++++++-- public/index.html | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/config.ru b/config.ru index bb685ce3..c9b94c7c 100644 --- a/config.ru +++ b/config.ru @@ -64,4 +64,5 @@ run Travis::Web::App.build( pro: ENV['TRAVIS_PRO'], code_climate: ENV['CODE_CLIMATE'], code_climate_url: ENV['CODE_CLIMATE_URL'], + assets_host: ENV['ASSETS_HOST'] ) diff --git a/lib/travis/web/app.rb b/lib/travis/web/app.rb index 2f969c39..037298b1 100644 --- a/lib/travis/web/app.rb +++ b/lib/travis/web/app.rb @@ -94,7 +94,6 @@ class Travis::Web::App else set_config(content, options) if config_needed?(file) set_title(content) if index?(file) - set_assets_host(content) if index?(file) headers = { 'Content-Length' => content.bytesize.to_s, @@ -169,7 +168,14 @@ class Travis::Web::App end string.gsub! %r{(src|href)="(?:\/?)((styles|scripts)\/[^"]*)"} do - %(#{$1}=#{opts[:alt] ? "#{S3_URL}/#{opts[:alt]}/#{$2}":"/#{$2}"}) + src = if options[:assets_host] + "#{options[:assets_host].chomp('/')}/#{$2}" + elsif opts[:alt] + "#{S3_URL}/#{opts[:alt]}/#{$2}" + else + "/#{$2}" + end + %(#{$1}="#{src}") end end end diff --git a/public/index.html b/public/index.html index f15c5cb7..673b0ae0 100644 --- a/public/index.html +++ b/public/index.html @@ -23,8 +23,8 @@ - - + +