This commit is contained in:
Espen Antonsen 2011-01-12 16:48:28 +08:00
commit 9e09177769
10 changed files with 30 additions and 27 deletions

5
.gems
View file

@ -1,4 +1,5 @@
rails --version '2.3.9'
authlogic authlogic
carrierwave carrierwave --version '0.4.5'
aws-s3 aws-s3
mini_exiftool rmagick

3
.gitignore vendored
View file

@ -3,6 +3,7 @@ tmp/**/*
.DS_Store .DS_Store
doc/api doc/api
doc/app doc/app
config/balder.rb
config/database.yml config/database.yml
config/settings.yml config/settings.yml
config/deploy.rb config/deploy.rb
@ -10,4 +11,4 @@ config/deploy
Capfile Capfile
photos photos
public/thumbs public/thumbs
public/uploads public/uploads

View file

@ -46,7 +46,7 @@ class ApplicationController < ActionController::Base
end end
def check_public_access def check_public_access
require_user unless ENV['PUBLIC'] == 'true' require_user if ENV['PRIVATE'] == 'true'
end end
def current_user_session def current_user_session

View file

@ -22,7 +22,7 @@ class FileUploader < CarrierWave::Uploader::Base
# This is a sensible default for uploaders that are meant to be mounted: # This is a sensible default for uploaders that are meant to be mounted:
def store_dir def store_dir
#{}"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" #{}"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
"uploads/files/#{model.album.path}" ENV['STORAGE_PATH'] + "files/#{model.album.path}"
end end
# Provide a default URL as a default if there hasn't been a file uploaded # Provide a default URL as a default if there hasn't been a file uploaded
@ -41,25 +41,25 @@ class FileUploader < CarrierWave::Uploader::Base
version :collection do version :collection do
process :resize_to_fill => [200, 200] process :resize_to_fill => [200, 200]
def store_dir def store_dir
"uploads/thumbs/#{model.album.path}" ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
end end
end end
version :album do version :album do
process :resize_to_fill => [100, 100] process :resize_to_fill => [100, 100]
def store_dir def store_dir
"uploads/thumbs/#{model.album.path}" ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
end end
end end
version :preview do version :preview do
process :resize_to_fit => [210, 210] process :resize_to_fit => [210, 210]
def store_dir def store_dir
"uploads/thumbs/#{model.album.path}" ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
end end
end end
version :single do version :single do
process :resize_to_limit => [950, 950] process :resize_to_limit => [950, 950]
def store_dir def store_dir
"uploads/thumbs/#{model.album.path}" ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}"
end end
end end

View file

@ -3,7 +3,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><%= ENV['TITLE'] %></title> <title><%= ENV['TITLE'] || "Photos" %></title>
<%= yield :head %> <%= yield :head %>
<%= stylesheet_link_tag 'application' %> <%= stylesheet_link_tag 'application' %>
</head> </head>

View file

@ -1,6 +1,7 @@
ENV['PUBLIC'] = 'true' ENV['STORAGE_PATH'] = "uploads" if ENV['STORAGE_PATH'].nil?
ENV['TITLE'] = 'photo' #ENV['PRIVATE'] = 'true'
#ENV['TITLE'] = 'photo'
#ENV['HEROKU'] = 'true' #ENV['HEROKU'] = 'true'
#ENV['S3_KEY'] = '' #ENV['S3_KEY'] = ''
#ENV['S3_SECRET'] = '' #ENV['S3_SECRET'] = ''
#ENV['S3_BUCKET'] = '' #ENV['S3_BUCKET'] = ''

View file

@ -16,9 +16,9 @@ Rails::Initializer.run do |config|
config.gem "authlogic" config.gem "authlogic"
config.gem 'mime-types', :lib => 'mime/types' config.gem 'mime-types', :lib => 'mime/types'
config.gem "carrierwave" config.gem "carrierwave"
config.gem "mysql2" config.gem "mysql2" unless ENV['HEROKU']
config.gem "aws-s3", :lib => "aws/s3" if ENV['HEROKU']
#config.gem "mini_exiftool" #config.gem "mini_exiftool"
#config.gem "aws-s3", :lib => "aws/s3"
config.load_paths += %W( #{RAILS_ROOT}/app/middleware ) config.load_paths += %W( #{RAILS_ROOT}/app/middleware )

View file

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

View file

@ -27,8 +27,8 @@ Feature: Manage Albums
Scenario: Create Valid Album Scenario: Create Valid Album
Given the following user records Given the following user records
| email | password | | email | password |
| espen@inspired.no | megmeg | | balder@balderapp.com | balder |
When I am logged in as "espen@inspired.no" with password "megmeg" When I am logged in as "balder@balderapp.com" with password "balder"
And I am on the list of albums And I am on the list of albums
And I have no albums And I have no albums
When I follow "New Album" When I follow "New Album"

View file

@ -1,12 +1,12 @@
Given /i am logged in as a user in the (.*) role/i do |role| Given /i am logged in as a user in the (.*) role/i do |role|
#@user = Factory.create(:user, :name => "Espen Antonsen", #@user = Factory.create(:user, :name => "Espen Antonsen",
# :email => "espen@inspired.no", # :email => "balder@balderapp.com",
# :password => "megmeg") # :password => "balder")
#@role = Factory.create(:role, :rolename => role) #@role = Factory.create(:role, :rolename => role)
#@user.roles << @role #@user.roles << @role
visits "/login" visits "/login"
fills_in("email", :with => "espen@inspired.no") fills_in("email", :with => "balder@balderapp.com")
fills_in("password", :with => "megmeg") fills_in("password", :with => "balder")
clicks_button("Log in") clicks_button("Log in")
end end