Skip to content
Extraits de code Groupes Projets
Valider 7ed31ab9 rédigé par Raphael's avatar Raphael
Parcourir les fichiers

Moving to file store

parent 39c96bfd
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -27,7 +27,6 @@ class Album
def self.mine_or_friends(friend_param, current_user)
if friend_param
puts "i am working"
Album.find_all_by_person_id(current_user.friend_ids)
else
current_user.person.albums
......
......@@ -35,15 +35,24 @@ class Photo < Post
def validate_album_person
album.person_id == person_id
end
def remote_photo
@remote_photo ||= self.person.url.chop + image.url
url
end
def remote_photo= remote_path
@remote_photo = remote_path
image.download! remote_path
image.store!
name_start = remote_path.rindex '/'
@remote_photo_path = remote_path.slice(0, name_start )
@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
def ensure_user_picture
......
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :grid_fs
storage :file
def store_dir
"files"
"uploads/images"
end
def extension_white_list
......
......@@ -11,5 +11,5 @@
%div.image_cycle
- 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
- 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
= link_to "Cancel", root_path
......
......@@ -22,7 +22,7 @@
#thumbnails
- for photo in @album_photos
.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
.back
......
......@@ -8,7 +8,7 @@
.sub_header
= link_to_prev @photo, @album
|
= link_to "full size", @photo.image.url
= link_to "full size", @photo.url
|
= link_to_next @photo, @album
......
......@@ -15,14 +15,14 @@
%div#image_picker
= p.hidden_field :image_url, :value => @profile.image_url, :id => 'image_url_field'
- 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'}
= 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
%div.small_photo{:id => photo.image.thumb_medium.url}
= 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
......
CarrierWave.configure do |config|
config.grid_fs_database = MongoMapper::database.name
config.grid_fs_host = MongoMapper::connection.host
config.grid_fs_access_url = "/images"
config.storage = :grid_fs
#config.storage = :file
config.storage = :file
end
......@@ -8,8 +8,6 @@ Diaspora::Application.routes.draw do |map|
resources :albums
resources :groups
match "/images/files/*path" => "gridfs#serve"
match 'warzombie', :to => "dev_utilities#warzombie"
match 'zombiefriends', :to => "dev_utilities#zombiefriends"
match 'zombiefriendaccept', :to => "dev_utilities#zombiefriendaccept"
......
......@@ -19,7 +19,7 @@ describe Photo do
photo.image.read.nil?.should be false
end
it 'should save a photo to GridFS' do
it 'should save a photo' do
@photo.image.store! File.open(@fixture_name)
@photo.save.should == true
binary = @photo.image.read
......@@ -58,7 +58,6 @@ describe Photo do
end
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.url.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
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.save.should == true
photo.signature_valid?.should be true
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter