various changes

This commit is contained in:
Espen Antonsen 2011-04-11 17:17:08 +08:00
parent 72e2c9a50f
commit 1aa3bc284a
6 changed files with 41 additions and 19 deletions

View file

@ -2,7 +2,6 @@ source 'http://rubygems.org'
gem 'rails', '3.0.3'
gem "authlogic"
gem 'mime-types', :require => 'mime/types'
gem "carrierwave", :git => 'git://github.com/jnicklas/carrierwave.git'
# MySQL:

View file

@ -36,8 +36,6 @@ GEM
activesupport (= 3.0.3)
activesupport (3.0.3)
arel (2.0.6)
authlogic (2.1.6)
activesupport
builder (2.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
@ -100,7 +98,6 @@ PLATFORMS
ruby
DEPENDENCIES
authlogic
carrierwave!
fog
mime-types

44
README
View file

@ -2,11 +2,7 @@
Made by Espen Antonsen.
Version 1.2.0rc2 for Rails3
Issues:
- carrierwave not saving to model, only to disk (testet on ubuntu)
- jpg files not being upload, no error written to log (testet on osx)
Version 1.2.0 for Rails3
http://balderapp.com
@ -31,17 +27,34 @@ Free for personal use. Contact me for commercial license.
Rails 3.0
Software
- ImageMagicK (required for Carrierwave resizing). Can also use ImageScience
Optional:
- ExifTool (required for Mini_EfixTool)
- ImageMagicK (required for Carrierwave resizing). Can also use ImageScience and MiniMagick
- ExifTool (required for Mini_EfixTool). Can be disabled.
Ruby Gems
- AuthLogic
- Mime-Types
- Carrierwave
- Mini_Exiftool (to read exif info to database and write exif to original file. See photo.rb model). Can be disabled.
Optional:
- AWS/S3 (if saving to Amazon s3)
- Mini_Exiftool (to read exif info to database. See photo.rb model)
== Configuration
config/balder.rb has the following adjustable settings:
STORAGE_PATH Relative path to where the photos are stored. Default: uploads
Under the specified path two folders are used. "files" for original files and "thumbs" for generated thumbnails.
This can be adjusted in app/uploaders/file_uploader.rb
PRIVATE Require visitors to have a user and authenticate before viewing photos.
TITLE Title of site
HEROKU To be used on heroku.com. This will adjust carrierwave to save to Heroku's tmp area.
S3_KEY For saving files to Amazon S3 (required for Heroku)
S3_SECRET For saving files to Amazon S3 (required for Heroku)
S3_BUCKET For saving files to Amazon S3 (required for Heroku)
As these are environment variables you can easily add them to Heroku:
http://devcenter.heroku.com/articles/config-vars#rack_env_rails_env_merb_env
== Installation
@ -49,7 +62,7 @@ Optional:
GitHub: git clone git://github.com/espen/balder.git
2. Install required software listed above
3. 'bundle install' to install required gems.
4. Adjust the settings in balder.rb
4. Adjust the settings in balder.rb (See configuration above)
5. Copy database file (not needed when hosting on Heroku):
cp config/database.example.yml config/database.yml
6. Create database user and edit database file. (unless on Heroku or using SQLite3)
@ -72,7 +85,16 @@ This format is recommended:
./trip to iran/mosque in yazd.jpg
./trip to iran/powder snow in dizin.jpg
Every time you manually add photos to disk you must scan by visiting /photos/scan
Every time you manually add photos to disk you must scan by visiting /photos/scan or run ScanFiles.Scan(false) from the console.
== Version history
1.2.0
- New storage path: "/uploads/files/" instead of "/uploads/". Make sure you move your photos or adjust the storage path.
== TODO
- Testing...
== Copyright and license info

View file

@ -9,7 +9,7 @@ class Photo < ActiveRecord::Base
validates :title, :presence => true
before_validation :set_title
before_validation :set_title, :set_path
before_create :exif_read
before_update :exif_write
@ -65,6 +65,10 @@ class Photo < ActiveRecord::Base
self.title = self.file.file.basename.titleize unless self.title
end
def set_path
self.path = self.file.file.file.sub(File.expand_path(Rails.root.to_s + '/public/' + ENV['STORAGE_PATH'] + "/files" ) + "/","") unless self.path
end
def ensure_file
#self.destroy if !File.exists?( APP_CONFIG[:photos_path] + self.path )
end

View file

@ -34,11 +34,11 @@ module ScanFiles
def self.ScanFile(path, debug)
return unless [".jpeg", ".jpg", ".gif", ".png"].include?( File.extname(path).downcase )
puts "analyze file " + path
photo = Photo.find_or_initialize_by_file( path )
photo = Photo.find_or_initialize_by_path( path )
puts "new record " + photo.new_record?.to_s
if photo.new_record?
puts "Save file " + path.sub(@photos_path, '')
photo.file = File.open( path )
photo.file = File.open( path ) unless debug
photo.album = Album.find_by_path( File.dirname( path ).sub(@photos_path, '') )
photo.save! unless debug
photo.file.recreate_versions! unless debug

@ -1 +1 @@
Subproject commit a06ec53ca238c1ad211ff8787f126acf94df4c86
Subproject commit e3edaa21e62045e677941562f12e518578192e5a