balder ENV settings. s3 init. remove settings.yml

This commit is contained in:
Espen Antonsen 2010-04-13 23:56:13 -04:00
parent 927918561c
commit 787912e735
10 changed files with 27 additions and 33 deletions

View file

@ -18,7 +18,7 @@ class ApplicationController < ActionController::Base
end
def check_public_access
require_user unless APP_CONFIG[:public]
require_user unless ENV['public'] == 'true'
end
def current_user_session

View file

@ -92,13 +92,13 @@ class Album < ActiveRecord::Base
private
def create_folders
Dir.mkdir( APP_CONFIG[:photos_path] + self.path ) unless File.exists?( APP_CONFIG[:photos_path] + self.path )
Dir.mkdir( APP_CONFIG[:thumbs_path] + self.path ) unless File.exists?( APP_CONFIG[:thumbs_path] + self.path )
#Dir.mkdir( APP_CONFIG[:photos_path] + self.path ) unless File.exists?( APP_CONFIG[:photos_path] + self.path )
#Dir.mkdir( APP_CONFIG[:thumbs_path] + self.path ) unless File.exists?( APP_CONFIG[:thumbs_path] + self.path )
end
def destroy_folders
#puts "DELETE DIRECTORY " + APP_CONFIG[:photos_path] + self.path
Dir.delete( APP_CONFIG[:photos_path] + self.path ) if File.exists?( APP_CONFIG[:photos_path] + self.path )
Dir.delete( APP_CONFIG[:thumbs_path] + self.path ) if File.exists?( APP_CONFIG[:thumbs_path] + self.path )
#Dir.delete( APP_CONFIG[:photos_path] + self.path ) if File.exists?( APP_CONFIG[:photos_path] + self.path )
#Dir.delete( APP_CONFIG[:thumbs_path] + self.path ) if File.exists?( APP_CONFIG[:thumbs_path] + self.path )
end
end

View file

@ -8,8 +8,11 @@ class FileUploader < CarrierWave::Uploader::Base
# Choose what kind of storage to use for this uploader
#storage :file
if ENV['S3_KEY']
storage :s3
else
storage :file
end
# Override the directory where uploaded files will be stored
# This is a sensible default for uploaders that are meant to be mounted:

View file

@ -27,7 +27,4 @@
<%= form.text_field :tags, { :autocomplete => "off", :class => 'tag_list', :value => (@album.tags.map{|tag|tag.title}.join(" ") unless @album.tags.nil?) } %><br />
<br />
<% if @album.path? %>
Location on disk: <i><%= APP_CONFIG[:photos_path] + @album.path %></i><br/>
Contains: <%= @album.photos.count %> photos<br/>
<% end %>

View file

@ -3,7 +3,7 @@
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><%= APP_CONFIG[:site_name] %></title>
<title><%= ENV['site_name'] %></title>
<%= yield :head %>
<%= stylesheet_link_tag 'application' %>
</head>
@ -22,10 +22,10 @@
<% end %>
</div>
<h1>
<% if APP_CONFIG[:site_logo] %>
<%= image_tag APP_CONFIG[:site_logo] %>
<% if ENV['LOGO'] %>
<%= image_tag ENV['LOGO'] %>
<% else %>
<%= APP_CONFIG[:site_name] %>
<%= ENV['TITLE'] %>
<% end %>
</h1>
<form action="/albums" method="get" id="search">

5
config/balder.rb Normal file
View file

@ -0,0 +1,5 @@
ENV['PUBLIC'] = 'true'
ENV['TITLE'] = 'photos'
#ENV['S3_KEY'] = ''
#ENV['S3_SECRET'] = ''
#ENV['S3_BUCKET'] = ''

View file

@ -6,6 +6,10 @@
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
# Load heroku vars from local file
balder_env = File.join(RAILS_ROOT, 'config', 'balder.rb')
load(balder_env) if File.exists?(balder_env)
Rails::Initializer.run do |config|

View file

@ -1,2 +0,0 @@
#APP_CONFIG = YAML.load_file("#{RAILS_ROOT}/config/settings.yml")[RAILS_ENV].symbolize_keys
APP_CONFIG = YAML.load(ERB.new(File.read("#{RAILS_ROOT}/config/settings.yml")).result)[RAILS_ENV].symbolize_keys

View file

@ -1,5 +1,5 @@
CarrierWave.configure do |config|
config.s3_access_key_id = APP_CONFIG[:s3_access_key_id]
config.s3_secret_access_key = APP_CONFIG[:s3_secret_access_key]
config.s3_bucket = APP_CONFIG[:s3_bucket]
config.s3_access_key_id = ENV['S3_KEY']
config.s3_secret_access_key = ENV['S3_SECRET']
config.s3_bucket = ENV['S3_BUCKET']
end

View file

@ -1,13 +0,0 @@
development:
public: true
site_name: 'Photos'
#site_logo: 'logo.png'
#s3_access_key_id: ''
#s3_secret_access_key: ''
#s3_bucket: ''
production:
public: true
site_name: 'Photos'
test:
public: true
site_name: 'Photos'