bigger profile pictures
refs #9889, refs #8592 This commit removes support for twitter and linkedin profile pictures, as they are too small. Test plan: * rake db:migrate * go view some profile pages * the profile pics should not be ghetto-scaled Change-Id: Ibea84420351cabbb496b1a8e5860d6e5834bb8ac Reviewed-on: https://gerrit.instructure.com/13030 Reviewed-by: Brian Palmer <brianp@instructure.com> Tested-by: Jenkins <jenkins@instructure.com>
This commit is contained in:
parent
0e5a5283fc
commit
63a275bd09
|
@ -135,7 +135,7 @@ class ProfileController < ApplicationController
|
|||
|
||||
# @API List avatar options
|
||||
# Retrieve the possible user avatar options that can be set with the user update endpoint. The response will be an array of avatar records. If the 'type' field is 'attachment', the record will include all the normal attachment json fields; otherwise it will include only the 'url' and 'display_name' fields. Additionally, all records will include a 'type' field and a 'token' field. The following explains each field in more detail
|
||||
# type:: ["gravatar"|"twitter"|"linked_in"|"attachment"|"no_pic"] The type of avatar record, for categorization purposes.
|
||||
# type:: ["gravatar"|"attachment"|"no_pic"] The type of avatar record, for categorization purposes.
|
||||
# url:: The url of the avatar
|
||||
# token:: A unique representation of the avatar record which can be used to set the avatar with the user update endpoint. Note: this is an internal representation and is subject to change without notice. It should be consumed with this api endpoint and used in the user update endpoint, and should not be constructed by the client.
|
||||
# display_name:: A textual description of the avatar record
|
||||
|
|
|
@ -760,7 +760,7 @@ class UsersController < ApplicationController
|
|||
# @argument user[time_zone] [Optional] The time zone for the user. Allowed time zones are listed in {http://rubydoc.info/docs/rails/2.3.8/ActiveSupport/TimeZone The Ruby on Rails documentation}.
|
||||
# @argument user[locale] [Optional] The user's preferred language as a two-letter ISO 639-1 code. Current supported languages are English ("en") and Spanish ("es").
|
||||
# @argument user[avatar][token] [Optional] A unique representation of the avatar record to assign as the user's current avatar. This token can be obtained from the user avatars endpoint. This supersedes the user[avatar][url] argument, and if both are included the url will be ignored. Note: this is an internal representation and is subject to change without notice. It should be consumed with this api endpoint and used in the user update endpoint, and should not be constructed by the client.
|
||||
# @argument user[avatar][url] [Optional] To set the user's avatar to point to an external url, do not include a token and instead pass the url here. Warning: For maximum compatibility, please use 50 px square images.
|
||||
# @argument user[avatar][url] [Optional] To set the user's avatar to point to an external url, do not include a token and instead pass the url here. Warning: For maximum compatibility, please use 128 px square images.
|
||||
#
|
||||
# @example_request
|
||||
#
|
||||
|
|
|
@ -672,7 +672,7 @@ class Attachment < ActiveRecord::Base
|
|||
if local_storage?
|
||||
has_attachment(
|
||||
:path_prefix => file_store_config['path_prefix'],
|
||||
:thumbnails => { :thumb => '200x50' },
|
||||
:thumbnails => { :thumb => '128x128' },
|
||||
:thumbnail_class => 'Thumbnail'
|
||||
)
|
||||
def authenticated_s3_url(*args)
|
||||
|
@ -696,7 +696,7 @@ class Attachment < ActiveRecord::Base
|
|||
has_attachment(
|
||||
:storage => :s3,
|
||||
:s3_access => :private,
|
||||
:thumbnails => { :thumb => '200x50' },
|
||||
:thumbnails => { :thumb => '128x128' },
|
||||
:thumbnail_class => 'Thumbnail'
|
||||
)
|
||||
def bucket_name
|
||||
|
|
|
@ -1189,7 +1189,7 @@ class User < ActiveRecord::Base
|
|||
#
|
||||
# val - A hash of options used to configure the avatar.
|
||||
# :type - The type of avatar. Should be 'facebook,' 'gravatar,'
|
||||
# 'twitter,' 'linked_in,' 'external,' or 'attachment.'
|
||||
# 'external,' or 'attachment.'
|
||||
# :url - The URL of the gravatar. Used for types 'external' and
|
||||
# 'attachment.'
|
||||
#
|
||||
|
@ -1214,28 +1214,6 @@ class User < ActiveRecord::Base
|
|||
self.avatar_image_source = 'gravatar'
|
||||
self.avatar_image_url = nil
|
||||
self.avatar_state = 'submitted'
|
||||
elsif val['type'] == 'twitter'
|
||||
twitter = self.user_services.for_service('twitter').first rescue nil
|
||||
if twitter
|
||||
url = URI.parse("http://twitter.com/users/show.json?user_id=#{twitter.service_user_id}")
|
||||
data = JSON.parse(Net::HTTP.get(url)) rescue nil
|
||||
if data
|
||||
self.avatar_image_source = 'twitter'
|
||||
self.avatar_image_url = data['profile_image_url_https'] || self.avatar_image_url
|
||||
self.avatar_state = 'submitted'
|
||||
end
|
||||
end
|
||||
elsif val['type'] == 'linked_in'
|
||||
@linked_in_service = self.user_services.for_service('linked_in').first rescue nil
|
||||
if @linked_in_service
|
||||
self.extend LinkedIn
|
||||
profile = linked_in_profile
|
||||
if profile
|
||||
self.avatar_image_source = 'linked_in'
|
||||
self.avatar_image_url = profile['picture_url']
|
||||
self.avatar_state = 'submitted'
|
||||
end
|
||||
end
|
||||
elsif val['type'] == 'external'
|
||||
self.avatar_image_source = 'external'
|
||||
self.avatar_image_url = val['url']
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<% form_tag update_profile_profile_path, { :method => :put, :id => :edit_profile_form, :class => "bootstrap-form form-vertical" } do %>
|
||||
<div class="image-block">
|
||||
<div class="image-block-image profile-avatar-wrapper">
|
||||
<%= avatar_image @user_data[:id], 50 %>
|
||||
<%= avatar_image @user_data[:id], 128 %>
|
||||
</div>
|
||||
<div class="image-block-content row-fluid">
|
||||
<h1>
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
class FixProfilePictures < ActiveRecord::Migration
|
||||
tag :postdeploy
|
||||
|
||||
class User < ActiveRecord::Base
|
||||
attr_accessible :id
|
||||
end
|
||||
|
||||
def self.up
|
||||
# we don't support twitter or linked in profile pictures anymore, because
|
||||
# they are too small
|
||||
ids = User.where(:avatar_image_source => %w(twitter linkedin)).map(&:id)
|
||||
now = Time.now
|
||||
User.update_all(
|
||||
{
|
||||
:avatar_image_source => 'no_pic',
|
||||
:avatar_image_url => nil,
|
||||
:avatar_image_updated_at => now
|
||||
},
|
||||
:id => ids)
|
||||
|
||||
DataFixup::RegenerateUserThumbnails.send_later_if_production(:run)
|
||||
end
|
||||
|
||||
def self.down
|
||||
end
|
||||
end
|
|
@ -25,26 +25,6 @@ module Api::V1::Avatar
|
|||
if feature_enabled?(:facebook) && facebook = user.facebook
|
||||
# TODO: add facebook picture if enabled
|
||||
end
|
||||
if feature_enabled?(:twitter) && twitter = user.user_services.for_service('twitter').first
|
||||
url = URI.parse("http://twitter.com/users/show.json?user_id=#{twitter.service_user_id}")
|
||||
data = JSON.parse(Net::HTTP.get(url)) rescue nil
|
||||
if data
|
||||
avatars << avatar_json(user, data['profile_image_url_https'], {
|
||||
:type => 'twitter',
|
||||
:alt => 'twitter pic'
|
||||
})
|
||||
end
|
||||
end
|
||||
if feature_enabled?(:linked_in) && linked_in = user.user_services.for_service('linked_in').first
|
||||
self.extend LinkedIn
|
||||
profile = linked_in_profile
|
||||
if profile && profile['picture_url']
|
||||
avatars << avatar_json(user, profile['picture_url'], {
|
||||
:type => 'linked_in',
|
||||
:alt => 'linked_in pic'
|
||||
})
|
||||
end
|
||||
end
|
||||
avatars << avatar_json(user, user.gravatar_url(50, "/images/dotted_pic.png", request), {
|
||||
:type => 'gravatar',
|
||||
:alt => 'gravatar pic'
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
module DataFixup::RegenerateUserThumbnails
|
||||
def self.run
|
||||
User.find_in_batches(:include => :active_images) do |users|
|
||||
attachments = users.map(&:active_images).flatten
|
||||
attachments.each do |a|
|
||||
a.thumbnails.destroy_all
|
||||
tmp_file = a.create_temp_file
|
||||
a.create_or_update_thumbnail(tmp_file, :thumb, '128x128')
|
||||
a.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue