diaspora/app/controllers/users_controller.rb
ilya 08b9aa864a Merge branch 'master' of github.com:diaspora/diaspora into fb
Conflicts:
	app/views/layouts/application.html.haml
	app/views/shared/_publisher.haml
	app/views/shared/_sub_header.haml
	app/views/users/edit.html.haml
	config/deploy_config.yml
	config/routes.rb
2010-09-27 15:39:50 -07:00

55 lines
1.5 KiB
Ruby

# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
class UsersController < ApplicationController
before_filter :authenticate_user!, :except => [:new, :create]
respond_to :html
def edit
@user = current_user
@person = @user.person
@profile = @user.person.profile
@photos = Photo.find_all_by_person_id(@person.id).paginate :page => params[:page], :order => 'created_at DESC'
@fb_access_url = MiniFB.oauth_url(FB_APP_ID, APP_CONFIG[:pod_url] + "services/create",
:scope=>MiniFB.scopes.join(","))
end
def update
@user = current_user
data = clean_hash params[:user]
prep_image_url(data)
@user.update_profile data
respond_with(@user, :location => root_url)
end
private
def prep_image_url(params)
url = APP_CONFIG[:pod_url].chop if APP_CONFIG[:pod_url][-1,1] == '/'
if params[:profile][:image_url].empty?
params[:profile].delete(:image_url)
else
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
def clean_hash(params)
return {
:profile =>
{
:first_name => params[:profile][:first_name],
:last_name => params[:profile][:last_name],
:image_url => params[:profile][:image_url]
}
}
end
end