photo uploader on edit profile page.

This commit is contained in:
danielvincent 2010-10-29 12:20:25 -07:00
parent ce805c8167
commit 79ec02c6ad
7 changed files with 45 additions and 50 deletions

View file

@ -37,7 +37,6 @@ class PeopleController < ApplicationController
@aspect = :person_edit
@person = current_user.person
@profile = @person.profile
@photos = current_user.visible_posts(:person_id => @person.id, :_type => 'Photo').paginate :page => params[:page], :order => 'created_at DESC'
end
def update
@ -64,6 +63,7 @@ class PeopleController < ApplicationController
private
def prep_image_url(params)
if params[:profile] && params[:profile][:image_url]
url = APP_CONFIG[:pod_url].dup
url.chop! if APP_CONFIG[:pod_url][-1,1] == '/'
if params[:profile][:image_url].empty?
@ -76,5 +76,6 @@ class PeopleController < ApplicationController
end
end
end
end
end

View file

@ -51,6 +51,11 @@ class PhotosController < ApplicationController
@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|
format.json{render(:layout => false , :json => {"success" => true, "data" => @photo}.to_json )}
end

View 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)
\.

View file

@ -42,26 +42,7 @@
%h4
Your photo
%div#image_picker
= 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
= render 'people/profile_photo_upload'
.submit_block
= link_to t('.cancel'), edit_user_path(current_user)

View file

@ -6,7 +6,7 @@
function createUploader(){
var uploader = new qq.FileUploader({
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'],
action: "#{photos_path}"
});

View file

@ -33,26 +33,7 @@
%h4
Your photo
%div#image_picker
= 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
= render 'people/profile_photo_upload'
= hidden_field_tag :getting_started, @step

View file

@ -1377,3 +1377,17 @@ ul.aspects
:display inline
:left 600px
: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