Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

why not have a cdn!

  • Loading branch information...
commit d94677b498066ecbb0aeb83db890db0bc94cb7a2 1 parent 562d2e2
@bhuga authored
Showing with 20 additions and 7 deletions.
  1. +6 −5 config.ru
  2. +12 −0 lib/bhuga.rb
  3. +2 −2 views/layout.haml
View
11 config.ru
@@ -5,12 +5,13 @@ require 'bundler'
Bundler.setup
require 'sprockets'
+require 'bhuga'
map '/assets' do
- environment = Sprockets::Environment.new
- environment.append_path 'assets/javascripts'
- environment.append_path 'assets/stylesheets'
- run environment
+ sprockets = Sprockets::Environment.new
+ sprockets.append_path 'assets/javascripts'
+ sprockets.append_path 'assets/stylesheets'
+ Bhuga.set :sprockets, sprockets
+ run sprockets
end
-require 'bhuga'
run Bhuga
View
12 lib/bhuga.rb
@@ -120,6 +120,18 @@ def content_for(key, &block)
def content(key)
@content && @content[key]
end
+
+ def digest_asset_path(pathname)
+ '/assets/' + settings.sprockets.find_asset(pathname).digest_path
+ end
+
+ def asset_host
+ ENV['ASSET_HOST'].nil? ? '' : "http://#{ENV['ASSET_HOST']}"
+ end
+
+ def asset_path(asset)
+ "#{asset_host}#{digest_asset_path(asset)}"
+ end
end
end
View
4 views/layout.haml
@@ -1,8 +1,8 @@
%html
%head
%title BHUGA WOOGA
- %link{:rel => 'stylesheet', :href => '/assets/all.css', :type => 'text/css', :media => 'screen, projection'}
- %script{:type => 'text/javascript', :src => '/assets/all.js'}
+ %link{:rel => 'stylesheet', :href => asset_path('all.css'), :type => 'text/css', :media => 'all'}
+ %script{:type => 'text/javascript', :src => asset_path('all.js')}
:javascript
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-3784741-1']);
Please sign in to comment.
Something went wrong with that request. Please try again.