use the built in asset_sync initializer. add a rake task to bootstrap

heroku and asset sync, which puts the S3 config vars in from your app
config.
This commit is contained in:
Maxwell Salzberg 2012-04-03 13:10:53 -07:00
parent a8843c1036
commit bb5aa2821d
4 changed files with 17 additions and 29 deletions

View file

@ -12,8 +12,8 @@
%meta{:name => "description", :content => "Diaspora*"}
%meta{:name => "author", :content => "Diaspora, Inc."}
%link{:rel => 'shortcut icon', :href => '/favicon.png'}
%link{:rel => 'apple-touch-icon', :href => '/apple-touch-icon.png'}
%link{:rel => 'shortcut icon', :href => "#{image_tag('favicon.png')}" }
%link{:rel => 'apple-touch-icon', :href => "#{image_tag('apple-touch-icon.png')}"}
%title
= page_title yield(:page_title)

View file

@ -1,25 +0,0 @@
if defined?(AssetSync)
require File.join(File.dirname(__FILE__), '..', '..', 'app', 'models', 'app_config')
AssetSync.configure do |config|
config.fog_provider = 'AWS'
config.fog_directory = AppConfig[:s3_bucket]
config.aws_access_key_id = AppConfig[:s3_key]
config.aws_secret_access_key = AppConfig[:s3_secret]
# Don't delete files from the store
# config.existing_remote_files = "keep"
#
# Increase upload performance by configuring your region
# config.fog_region = 'eu-west-1'
#
# Automatically replace files with their equivalent gzip compressed version
# config.gzip_compression = true
#
# Use the Rails generated 'manifest.yml' file to produce the list of files to
# upload instead of searching the assets directory.
# config.manifest = true
#
# Fail silently. Useful for environments such as Heroku
# config.fail_silently = true
end
end

View file

@ -20,4 +20,17 @@ namespace :heroku do
system 'heroku addons:add logging:expanded'
system 'heroku addons:add redistogo:nano'
end
end
task :set_up_s3_sync => [:environment] do
fog_provider = "FOG_PROVIDER=AWS"
aws_access_key_id = "AWS_ACCESS_KEY_ID=#{AppConfig[:s3_key]}"
aws_secret_access_key = "AWS_SECRET_ACCESS_KEY=#{AppConfig[:s3_secret]}"
fog = "FOG_DIRECTORY=#{AppConfig[:s3_bucket]}"
asset_host = "ASSET_HOST=https://#{AppConfig[:s3_bucket]}.s3.amazonaws.com"
each_heroku_app do |stage|
system("heroku labs:enable user_env_compile -a #{stage.app}")
stage.run('config:add', "#{fog} #{fog_provider} #{fog} #{aws_secret_access_key} #{aws_access_key_id} ASSET_HOST=#{asset_host}")
end
end
end

View file

@ -34,7 +34,7 @@
<body>
<!-- This file lives in public/500.html -->
<header>
<img id="diaspora_logo" src="/assets/logo_large.png"/>
<img id="diaspora_logo" src="/assets/branding/logo_large.png"/>
</header>
<h1>