You can now use rake assets:precompile to upload all of your static assets to s3. This uses your prexisiting settings in AppConfig for s3. then, start your server with ASSET_HOST={cdn_hostname} remember to include https and no trailing slash
This commit is contained in:
parent
e1658f8d8b
commit
939383ef32
7 changed files with 35 additions and 12 deletions
|
|
@ -38,7 +38,7 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def jquery_include_tag
|
def jquery_include_tag
|
||||||
javascript_include_tag('//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js') +
|
"<script src='//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js' type='text/javascript'></script>".html_safe +
|
||||||
content_tag(:script) do
|
content_tag(:script) do
|
||||||
"!window.jQuery && document.write(unescape(\"#{escape_javascript(include_javascripts(:jquery))}\")); jQuery.ajaxSetup({'cache': false});".html_safe
|
"!window.jQuery && document.write(unescape(\"#{escape_javascript(include_javascripts(:jquery))}\")); jQuery.ajaxSetup({'cache': false});".html_safe
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -54,12 +54,11 @@
|
||||||
|
|
||||||
/ bootstrap/blueprint switch
|
/ bootstrap/blueprint switch
|
||||||
- if @aspect == :getting_started || @page == :logged_out
|
- if @aspect == :getting_started || @page == :logged_out
|
||||||
= stylesheet_link_tag "bootstrap.min.css"
|
= include_stylesheets :bootstrap
|
||||||
- else
|
- else
|
||||||
= stylesheet_link_tag "blueprint/screen", :media => 'screen'
|
= include_stylesheets :blueprint, :media => 'screen'
|
||||||
= stylesheet_link_tag "blueprint/print", :media => 'print'
|
|
||||||
|
|
||||||
= stylesheet_link_tag "login", :media => 'screen'
|
= include_stylesheets :login, :media => 'screen'
|
||||||
|
|
||||||
= include_stylesheets :default, :media => 'all'
|
= include_stylesheets :default, :media => 'all'
|
||||||
- if rtl?
|
- if rtl?
|
||||||
|
|
@ -78,7 +77,7 @@
|
||||||
|
|
||||||
= csrf_meta_tag
|
= csrf_meta_tag
|
||||||
<!--[if IE]>
|
<!--[if IE]>
|
||||||
= javascript_include_tag "/javascripts/ie.js"
|
= include_javascripts :ie
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
|
||||||
= jquery_include_tag
|
= jquery_include_tag
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
<!-- Begin MailChimp Signup Form -->
|
<!-- Begin MailChimp Signup Form -->
|
||||||
<%= javascript_include_tag 'vendor/mailchimp/jquery126.min.js', 'vendor/mailchimp/jquery.validate.js', 'vendor/mailchimp/jquery.form.js' %>
|
<%= include_javascripts :mailchimp %>
|
||||||
<div id="mc_embed_signup">
|
<div id="mc_embed_signup">
|
||||||
<form action="http://joindiaspora.us1.list-manage.com/subscribe/post?u=d759919b94f9cdcf39d204f3f&id=7b5ceb2f8b" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank">
|
<form action="http://joindiaspora.us1.list-manage.com/subscribe/post?u=d759919b94f9cdcf39d204f3f&id=7b5ceb2f8b" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank">
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ gzip_assets: off
|
||||||
javascripts:
|
javascripts:
|
||||||
jquery:
|
jquery:
|
||||||
- public/javascripts/vendor/jquery-1.7.1.min.js
|
- public/javascripts/vendor/jquery-1.7.1.min.js
|
||||||
|
|
||||||
main:
|
main:
|
||||||
- public/javascripts/vendor/underscore.js
|
- public/javascripts/vendor/underscore.js
|
||||||
- public/javascripts/vendor/backbone.js
|
- public/javascripts/vendor/backbone.js
|
||||||
|
|
@ -86,8 +85,15 @@ javascripts:
|
||||||
- public/javascripts/inbox.js
|
- public/javascripts/inbox.js
|
||||||
profile:
|
profile:
|
||||||
- public/javascripts/vendor/jquery.autoSuggest.custom.js
|
- public/javascripts/vendor/jquery.autoSuggest.custom.js
|
||||||
|
ie:
|
||||||
|
- public/javascripts/ie.js
|
||||||
stylesheets:
|
stylesheets:
|
||||||
|
bootstrap:
|
||||||
|
- public/stylesheets/bootstrap.min.css
|
||||||
|
blueprint:
|
||||||
|
- public/stylesheets/blueprint/screen.css
|
||||||
|
login:
|
||||||
|
- public/stylesheets/login.css
|
||||||
default:
|
default:
|
||||||
- public/stylesheets/application.css
|
- public/stylesheets/application.css
|
||||||
- public/stylesheets/ui.css
|
- public/stylesheets/ui.css
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,9 @@ Diaspora::Application.configure do
|
||||||
|
|
||||||
|
|
||||||
# Enable serving of images, stylesheets, and javascripts from an asset server
|
# Enable serving of images, stylesheets, and javascripts from an asset server
|
||||||
# config.action_controller.asset_host = "http://assets.example.com"
|
if ENV['ASSET_HOST']
|
||||||
|
config.action_controller.asset_host = ENV['ASSET_HOST']
|
||||||
|
end
|
||||||
|
|
||||||
# Disable delivery errors, bad email addresses will be ignored
|
# Disable delivery errors, bad email addresses will be ignored
|
||||||
# config.action_mailer.raise_delivery_errors = false
|
# config.action_mailer.raise_delivery_errors = false
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@
|
||||||
if AppConfig[:airbrake_api_key].present?
|
if AppConfig[:airbrake_api_key].present?
|
||||||
require 'airbrake'
|
require 'airbrake'
|
||||||
Airbrake.configure do |config|
|
Airbrake.configure do |config|
|
||||||
puts AppConfig[:airbrake_api_key]
|
|
||||||
config.api_key = AppConfig[:airbrake_api_key]
|
config.api_key = AppConfig[:airbrake_api_key]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -1,6 +1,23 @@
|
||||||
namespace :assets do
|
namespace :assets do
|
||||||
task :precompile do
|
task :precompile do
|
||||||
|
puts "compiling sass..."
|
||||||
system 'sass --update public/stylesheets/sass:public/stylesheets'
|
system 'sass --update public/stylesheets/sass:public/stylesheets'
|
||||||
system 'bundle exec jammit'
|
|
||||||
|
puts "packaging assets....."
|
||||||
|
Jammit.package!
|
||||||
|
|
||||||
|
Rake::Task['assets:upload_to_s3'].invoke
|
||||||
|
end
|
||||||
|
|
||||||
|
task :upload_to_s3 => [:environment] do
|
||||||
|
s3_configuration = {
|
||||||
|
:bucket_name => AppConfig[:s3_bucket],
|
||||||
|
:access_key_id => AppConfig[:s3_key],
|
||||||
|
:secret_access_key => AppConfig[:s3_secret]
|
||||||
|
}
|
||||||
|
Jammit.upload_to_s3!(s3_configuration)
|
||||||
|
asset_host = "https://#{s3_configuration[:bucket_name]}.s3.amazonaws.com"
|
||||||
|
puts "NOTE: ENV['ASSET_HOST'] is now: #{asset_host}, but you may know your cdn url better than I"
|
||||||
|
puts "Please set this in your ENV hash in a production enviroment"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Loading…
Reference in a new issue