doh. add missing files
This commit is contained in:
parent
419ace7c51
commit
de6f5026ff
27
lib/travis/web/app/assets.rb
Normal file
27
lib/travis/web/app/assets.rb
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
class Travis::Web::App
|
||||||
|
class Assets
|
||||||
|
include Helpers
|
||||||
|
|
||||||
|
attr_reader :app, :config
|
||||||
|
|
||||||
|
def initialize(app, config)
|
||||||
|
@app = app
|
||||||
|
@config = config
|
||||||
|
end
|
||||||
|
|
||||||
|
def call(env)
|
||||||
|
path = env['PATH_INFO']
|
||||||
|
if !asset?(path)
|
||||||
|
app.call(map_env(env, config.version))
|
||||||
|
else
|
||||||
|
app.call(env)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def asset?(path)
|
||||||
|
path !~ Travis::Web::App::ASSET_DIRS
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
29
lib/travis/web/app/filter/assets.rb
Normal file
29
lib/travis/web/app/filter/assets.rb
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
class Travis::Web::App::Filter
|
||||||
|
class Assets
|
||||||
|
attr_reader :config
|
||||||
|
|
||||||
|
def initialize(config)
|
||||||
|
@config = config
|
||||||
|
end
|
||||||
|
|
||||||
|
def apply(string)
|
||||||
|
string = version(string)
|
||||||
|
string = minify(string) # if config.production?
|
||||||
|
string
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def version(string)
|
||||||
|
string.gsub(Travis::Web::App::ASSET_DIRS) do
|
||||||
|
"/#{config.version}/#{$1}/"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def minify(string)
|
||||||
|
string.gsub(%r((/javascripts/.*).js)) do
|
||||||
|
"#{$1}.min.js/"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user