Moving to file store
This commit is contained in:
parent
39c96bfd04
commit
7ed31ab96a
11 changed files with 26 additions and 25 deletions
|
|
@ -27,7 +27,6 @@ class Album
|
||||||
|
|
||||||
def self.mine_or_friends(friend_param, current_user)
|
def self.mine_or_friends(friend_param, current_user)
|
||||||
if friend_param
|
if friend_param
|
||||||
puts "i am working"
|
|
||||||
Album.find_all_by_person_id(current_user.friend_ids)
|
Album.find_all_by_person_id(current_user.friend_ids)
|
||||||
else
|
else
|
||||||
current_user.person.albums
|
current_user.person.albums
|
||||||
|
|
|
||||||
|
|
@ -37,13 +37,22 @@ class Photo < Post
|
||||||
end
|
end
|
||||||
|
|
||||||
def remote_photo
|
def remote_photo
|
||||||
@remote_photo ||= self.person.url.chop + image.url
|
url
|
||||||
end
|
end
|
||||||
|
|
||||||
def remote_photo= remote_path
|
def remote_photo= remote_path
|
||||||
@remote_photo = remote_path
|
name_start = remote_path.rindex '/'
|
||||||
image.download! remote_path
|
@remote_photo_path = remote_path.slice(0, name_start )
|
||||||
image.store!
|
@remote_photo_name = remote_path.slice(name_start, remote_path.length)
|
||||||
|
puts url
|
||||||
|
end
|
||||||
|
|
||||||
|
def url name = nil
|
||||||
|
if @remote_photo_path
|
||||||
|
@remote_photo_path + name.to_s + @remote_photo_name
|
||||||
|
else
|
||||||
|
image.url name
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def ensure_user_picture
|
def ensure_user_picture
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
class ImageUploader < CarrierWave::Uploader::Base
|
class ImageUploader < CarrierWave::Uploader::Base
|
||||||
include CarrierWave::MiniMagick
|
include CarrierWave::MiniMagick
|
||||||
|
|
||||||
storage :grid_fs
|
storage :file
|
||||||
|
|
||||||
def store_dir
|
def store_dir
|
||||||
"files"
|
"uploads/images"
|
||||||
end
|
end
|
||||||
|
|
||||||
def extension_white_list
|
def extension_white_list
|
||||||
|
|
|
||||||
|
|
@ -11,5 +11,5 @@
|
||||||
|
|
||||||
%div.image_cycle
|
%div.image_cycle
|
||||||
- for photo in post.photos[0..3]
|
- for photo in post.photos[0..3]
|
||||||
= link_to (image_tag photo.image.url(:thumb_large)), album_path(post)
|
= link_to (image_tag photo.url(:thumb_large)), album_path(post)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
%ul
|
%ul
|
||||||
- for photo in @album.photos
|
- for photo in @album.photos
|
||||||
%li.photo_edit_block= image_tag photo.image.url(:thumb_large)
|
%li.photo_edit_block= image_tag photo.url(:thumb_large)
|
||||||
|
|
||||||
#submit_block
|
#submit_block
|
||||||
= link_to "Cancel", root_path
|
= link_to "Cancel", root_path
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
#thumbnails
|
#thumbnails
|
||||||
- for photo in @album_photos
|
- for photo in @album_photos
|
||||||
.image_thumb
|
.image_thumb
|
||||||
= link_to (image_tag photo.image.url(:thumb_medium)), object_path(photo)
|
= link_to (image_tag photo.url(:thumb_medium)), object_path(photo)
|
||||||
|
|
||||||
#content_bottom
|
#content_bottom
|
||||||
.back
|
.back
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
.sub_header
|
.sub_header
|
||||||
= link_to_prev @photo, @album
|
= link_to_prev @photo, @album
|
||||||
|
|
|
|
||||||
= link_to "full size", @photo.image.url
|
= link_to "full size", @photo.url
|
||||||
|
|
|
|
||||||
= link_to_next @photo, @album
|
= link_to_next @photo, @album
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,14 +15,14 @@
|
||||||
%div#image_picker
|
%div#image_picker
|
||||||
= p.hidden_field :image_url, :value => @profile.image_url, :id => 'image_url_field'
|
= p.hidden_field :image_url, :value => @profile.image_url, :id => 'image_url_field'
|
||||||
- for photo in @photos
|
- for photo in @photos
|
||||||
- if photo.image.url(:thumb_medium) == @profile.image_url
|
- if photo.url(:thumb_medium) == @profile.image_url
|
||||||
%div.small_photo{:id => photo.image.thumb_medium.url, :class=>'selected'}
|
%div.small_photo{:id => photo.image.thumb_medium.url, :class=>'selected'}
|
||||||
= check_box_tag 'checked_photo', true, true
|
= check_box_tag 'checked_photo', true, true
|
||||||
= link_to image_tag(photo.image.url(:thumb_medium)), "#"
|
= link_to image_tag(photo.url(:thumb_medium)), "#"
|
||||||
- else
|
- else
|
||||||
%div.small_photo{:id => photo.image.thumb_medium.url}
|
%div.small_photo{:id => photo.image.thumb_medium.url}
|
||||||
= check_box_tag 'checked_photo'
|
= check_box_tag 'checked_photo'
|
||||||
= link_to image_tag(photo.image.url(:thumb_medium)), "#"
|
= link_to image_tag(photo.url(:thumb_medium)), "#"
|
||||||
=will_paginate @photos
|
=will_paginate @photos
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,3 @@
|
||||||
CarrierWave.configure do |config|
|
CarrierWave.configure do |config|
|
||||||
config.grid_fs_database = MongoMapper::database.name
|
config.storage = :file
|
||||||
config.grid_fs_host = MongoMapper::connection.host
|
|
||||||
config.grid_fs_access_url = "/images"
|
|
||||||
config.storage = :grid_fs
|
|
||||||
#config.storage = :file
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,6 @@ Diaspora::Application.routes.draw do |map|
|
||||||
resources :albums
|
resources :albums
|
||||||
resources :groups
|
resources :groups
|
||||||
|
|
||||||
match "/images/files/*path" => "gridfs#serve"
|
|
||||||
|
|
||||||
match 'warzombie', :to => "dev_utilities#warzombie"
|
match 'warzombie', :to => "dev_utilities#warzombie"
|
||||||
match 'zombiefriends', :to => "dev_utilities#zombiefriends"
|
match 'zombiefriends', :to => "dev_utilities#zombiefriends"
|
||||||
match 'zombiefriendaccept', :to => "dev_utilities#zombiefriendaccept"
|
match 'zombiefriendaccept', :to => "dev_utilities#zombiefriendaccept"
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ describe Photo do
|
||||||
photo.image.read.nil?.should be false
|
photo.image.read.nil?.should be false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should save a photo to GridFS' do
|
it 'should save a photo' do
|
||||||
@photo.image.store! File.open(@fixture_name)
|
@photo.image.store! File.open(@fixture_name)
|
||||||
@photo.save.should == true
|
@photo.save.should == true
|
||||||
binary = @photo.image.read
|
binary = @photo.image.read
|
||||||
|
|
@ -58,7 +58,6 @@ describe Photo do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not use the imported filename as the url' do
|
it 'should not use the imported filename as the url' do
|
||||||
pending "Until this passes, duplicate photos will cause errors"
|
|
||||||
@photo.image.store! File.open(@fixture_name)
|
@photo.image.store! File.open(@fixture_name)
|
||||||
@photo.image.url.include?(@fixture_filename).should be false
|
@photo.image.url.include?(@fixture_filename).should be false
|
||||||
@photo.image.url(:thumb_medium).include?("/" + @fixture_filename).should be false
|
@photo.image.url(:thumb_medium).include?("/" + @fixture_filename).should be false
|
||||||
|
|
@ -85,7 +84,7 @@ describe Photo do
|
||||||
stub_signature_verification
|
stub_signature_verification
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should save a signed photo to GridFS' do
|
it 'should save a signed photo' do
|
||||||
photo = @user.post(:photo, :album => @album, :user_file => [File.open(@fixture_name)])
|
photo = @user.post(:photo, :album => @album, :user_file => [File.open(@fixture_name)])
|
||||||
photo.save.should == true
|
photo.save.should == true
|
||||||
photo.signature_valid?.should be true
|
photo.signature_valid?.should be true
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue