photo uploader on edit profile page.
This commit is contained in:
parent
ce805c8167
commit
79ec02c6ad
7 changed files with 45 additions and 50 deletions
|
|
@ -37,7 +37,6 @@ class PeopleController < ApplicationController
|
||||||
@aspect = :person_edit
|
@aspect = :person_edit
|
||||||
@person = current_user.person
|
@person = current_user.person
|
||||||
@profile = @person.profile
|
@profile = @person.profile
|
||||||
@photos = current_user.visible_posts(:person_id => @person.id, :_type => 'Photo').paginate :page => params[:page], :order => 'created_at DESC'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
|
@ -64,15 +63,17 @@ class PeopleController < ApplicationController
|
||||||
|
|
||||||
private
|
private
|
||||||
def prep_image_url(params)
|
def prep_image_url(params)
|
||||||
url = APP_CONFIG[:pod_url].dup
|
if params[:profile] && params[:profile][:image_url]
|
||||||
url.chop! if APP_CONFIG[:pod_url][-1,1] == '/'
|
url = APP_CONFIG[:pod_url].dup
|
||||||
if params[:profile][:image_url].empty?
|
url.chop! if APP_CONFIG[:pod_url][-1,1] == '/'
|
||||||
params[:profile].delete(:image_url)
|
if params[:profile][:image_url].empty?
|
||||||
else
|
params[:profile].delete(:image_url)
|
||||||
if /^http:\/\// =~ params[:profile][:image_url]
|
|
||||||
params[:profile][:image_url] = params[:profile][:image_url]
|
|
||||||
else
|
else
|
||||||
params[:profile][:image_url] = url + params[:profile][:image_url]
|
if /^http:\/\// =~ params[:profile][:image_url]
|
||||||
|
params[:profile][:image_url] = params[:profile][:image_url]
|
||||||
|
else
|
||||||
|
params[:profile][:image_url] = url + params[:profile][:image_url]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,11 @@ class PhotosController < ApplicationController
|
||||||
|
|
||||||
@photo = current_user.post(:photo, params[:photo])
|
@photo = current_user.post(:photo, params[:photo])
|
||||||
|
|
||||||
|
# set image as profile photo
|
||||||
|
if params[:set_profile_image] && !params[:set_profile_image].empty?
|
||||||
|
current_user.update_profile(:image_url=>@photo.url(:thumb_medium))
|
||||||
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json{render(:layout => false , :json => {"success" => true, "data" => @photo}.to_json )}
|
format.json{render(:layout => false , :json => {"success" => true, "data" => @photo}.to_json )}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
13
app/views/people/_profile_photo_upload.html.haml
Normal file
13
app/views/people/_profile_photo_upload.html.haml
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
-# Copyright (c) 2010, Diaspora Inc. This file is
|
||||||
|
-# licensed under the Affero General Public License version 3 or later. See
|
||||||
|
-# the COPYRIGHT file.
|
||||||
|
|
||||||
|
|
||||||
|
#profile_photo_upload
|
||||||
|
= owner_image_tag
|
||||||
|
= render 'photos/new_photo', :album_id => nil, :aspect_id => 'all', :set_profile_image => true
|
||||||
|
|
||||||
|
%p
|
||||||
|
\...or select one from your already existing
|
||||||
|
= link_to 'photos', person_photos_path(@person)
|
||||||
|
\.
|
||||||
|
|
@ -42,26 +42,7 @@
|
||||||
|
|
||||||
%h4
|
%h4
|
||||||
Your photo
|
Your photo
|
||||||
%div#image_picker
|
= render 'people/profile_photo_upload'
|
||||||
= profile.hidden_field :image_url, :value => (@profile.image_url if @profile.image_url), :id => 'image_url_field'
|
|
||||||
|
|
||||||
- unless @photos.nil? || @photos.empty?
|
|
||||||
- for photo in @photos
|
|
||||||
- if @profile.image_url && @profile.image_url.include?(photo.url(:thumb_medium))
|
|
||||||
%div.small_photo{:id => photo.url(:thumb_medium), :class=>'selected'}
|
|
||||||
= check_box_tag 'checked_photo', true, true
|
|
||||||
= link_to image_tag(photo.url(:thumb_medium)), "#"
|
|
||||||
- else
|
|
||||||
%div.small_photo{:id => photo.url(:thumb_medium)}
|
|
||||||
= check_box_tag 'checked_photo'
|
|
||||||
= link_to image_tag(photo.url(:thumb_medium)), "#"
|
|
||||||
|
|
||||||
- else
|
|
||||||
=t('.you_dont_have_any_photos')
|
|
||||||
= link_to t('.albums'), albums_path(:aspect => 'all')
|
|
||||||
=t('.page_to_upload_some')
|
|
||||||
|
|
||||||
=will_paginate @photos
|
|
||||||
|
|
||||||
.submit_block
|
.submit_block
|
||||||
= link_to t('.cancel'), edit_user_path(current_user)
|
= link_to t('.cancel'), edit_user_path(current_user)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
function createUploader(){
|
function createUploader(){
|
||||||
var uploader = new qq.FileUploader({
|
var uploader = new qq.FileUploader({
|
||||||
element: document.getElementById('file-upload'),
|
element: document.getElementById('file-upload'),
|
||||||
params: {'photo' : { 'album_id' : "#{album_id}", 'to' : "#{aspect_id}"}},
|
params: {'photo' : { 'album_id' : "#{album_id}", 'to' : "#{aspect_id}"}, 'set_profile_image' : "#{set_profile_image if defined?(set_profile_image)}"},
|
||||||
allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'],
|
allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'],
|
||||||
action: "#{photos_path}"
|
action: "#{photos_path}"
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -33,26 +33,7 @@
|
||||||
|
|
||||||
%h4
|
%h4
|
||||||
Your photo
|
Your photo
|
||||||
%div#image_picker
|
= render 'people/profile_photo_upload'
|
||||||
= profile.hidden_field :image_url, :value => (@profile.image_url if @profile.image_url), :id => 'image_url_field'
|
|
||||||
|
|
||||||
- unless @photos.nil? || @photos.empty?
|
|
||||||
- for photo in @photos
|
|
||||||
- if @profile.image_url && @profile.image_url.include?(photo.url(:thumb_medium))
|
|
||||||
%div.small_photo{:id => photo.url(:thumb_medium), :class=>'selected'}
|
|
||||||
= check_box_tag 'checked_photo', true, true
|
|
||||||
= link_to image_tag(photo.url(:thumb_medium)), "#"
|
|
||||||
- else
|
|
||||||
%div.small_photo{:id => photo.url(:thumb_medium)}
|
|
||||||
= check_box_tag 'checked_photo'
|
|
||||||
= link_to image_tag(photo.url(:thumb_medium)), "#"
|
|
||||||
|
|
||||||
- else
|
|
||||||
=t('.you_dont_have_any_photos')
|
|
||||||
= link_to t('.albums'), albums_path(:aspect => 'all')
|
|
||||||
=t('.page_to_upload_some')
|
|
||||||
|
|
||||||
=will_paginate @photos
|
|
||||||
|
|
||||||
= hidden_field_tag :getting_started, @step
|
= hidden_field_tag :getting_started, @step
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1377,3 +1377,17 @@ ul.aspects
|
||||||
:display inline
|
:display inline
|
||||||
:left 600px
|
:left 600px
|
||||||
:top 0
|
:top 0
|
||||||
|
|
||||||
|
#profile_photo_upload
|
||||||
|
:margin
|
||||||
|
:top 5px
|
||||||
|
img
|
||||||
|
:position absolute
|
||||||
|
:left 0
|
||||||
|
:height 100px
|
||||||
|
:width 100px
|
||||||
|
:border-radius 5px
|
||||||
|
:-webkit-box-shadow 0 1px 2px #666
|
||||||
|
|
||||||
|
:padding
|
||||||
|
:left 120px
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue