diff --git a/app/models/album.rb b/app/models/album.rb index b30cb5c45d73fc59900806d013ba5306d5dceb51..b6daabb474c99715980b1ae1975931575bb9a6a6 100644 --- a/app/models/album.rb +++ b/app/models/album.rb @@ -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 diff --git a/app/models/photo.rb b/app/models/photo.rb index d93a1189a90c5603d09b662cd416a3ee87800a70..b43ddc376f50e57e4d7bce0f7dbc38a9573c7381 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -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 diff --git a/app/uploaders/image_uploader.rb b/app/uploaders/image_uploader.rb index 2a55e30592e564c46ded16c6ea9b7c83f744cdc6..3fd36c6a602fc93df12fb3d8c8db5604aad7196d 100644 --- a/app/uploaders/image_uploader.rb +++ b/app/uploaders/image_uploader.rb @@ -1,10 +1,10 @@ class ImageUploader < CarrierWave::Uploader::Base include CarrierWave::MiniMagick - storage :grid_fs + storage :file def store_dir - "files" + "uploads/images" end def extension_white_list diff --git a/app/views/albums/_album.html.haml b/app/views/albums/_album.html.haml index 52cb7fe4aea4d276f43a2e4b49f0968ee01b796d..3e4bf3483c97d11ad75ef830c321e0b6a11e976f 100644 --- a/app/views/albums/_album.html.haml +++ b/app/views/albums/_album.html.haml @@ -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) diff --git a/app/views/albums/edit.html.haml b/app/views/albums/edit.html.haml index b505cf76b626a02c3f369c54ac60d81250ec8098..18cb8b6447961bb7ca34bd275563c5a33b712fdf 100644 --- a/app/views/albums/edit.html.haml +++ b/app/views/albums/edit.html.haml @@ -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 diff --git a/app/views/albums/show.html.haml b/app/views/albums/show.html.haml index b63dea9de9afff13345f3b65eaf58ec7b78f6fc6..04b1176456f9c1a802e26e80c2f3789ed5966ecf 100644 --- a/app/views/albums/show.html.haml +++ b/app/views/albums/show.html.haml @@ -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 diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index 05443591f847f29762c16bdb90d1ec204aa5e513..8636998b3e515b73ea02939efa2728a26c532046 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -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 diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index fa1136fec5668497a7dc7d669dd9546adeca42ba..24aa8e7f01c5b224723acd628ed1ec5f55831e84 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -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 diff --git a/config/initializers/carrierwave.rb b/config/initializers/carrierwave.rb index ed6e8bb4ecc19a9d6e91e975f2d7558d3a9038b2..0fe280e02335bf4a17ef51a045058ca287edd7f2 100644 --- a/config/initializers/carrierwave.rb +++ b/config/initializers/carrierwave.rb @@ -1,7 +1,3 @@ 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 diff --git a/config/routes.rb b/config/routes.rb index e1991d0330e4b2d232396e979e09bec2af1bd014..e8d5616f0a7f8cb9fb95717eb8a346475e236d50 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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" diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index 3d4d83008272834b3ee26bcbc96e4116e87ea322..c91fd3c1a711aa581c61849d1b18078bd66f84f1 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -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