This reverts commit ab81f36a38.
This commit is contained in:
parent
23cee97d0a
commit
5657067e55
62 changed files with 99 additions and 99 deletions
|
|
@ -56,7 +56,7 @@ class AsyncInfoController < ApplicationController
|
|||
id: @user.id,
|
||||
name: @user.name,
|
||||
username: @user.username,
|
||||
profile_image_90: Images::Profile.call(@user.profile_image_url, length: 90),
|
||||
profile_image_90: ProfileImage.new(@user).get(width: 90),
|
||||
followed_tags: @user.cached_followed_tags.to_json(only: %i[id name bg_color_hex text_color_hex hotness_score],
|
||||
methods: [:points]),
|
||||
followed_podcast_ids: @user.cached_following_podcasts_ids,
|
||||
|
|
|
|||
|
|
@ -378,7 +378,7 @@ class StoriesController < ApplicationController
|
|||
},
|
||||
"url": URL.user(@user),
|
||||
"sameAs": user_same_as,
|
||||
"image": Images::Profile.call(@user.profile_image_url, length: 320),
|
||||
"image": ProfileImage.new(@user).get(width: 320),
|
||||
"name": @user.name,
|
||||
"email": @user.email_public ? @user.email : nil,
|
||||
"jobTitle": @user.employment_title.presence,
|
||||
|
|
@ -444,7 +444,7 @@ class StoriesController < ApplicationController
|
|||
"@id": URL.organization(@organization)
|
||||
},
|
||||
"url": URL.organization(@organization),
|
||||
"image": Images::Profile.call(@organization.profile_image_url, length: 320),
|
||||
"image": ProfileImage.new(@organization).get(width: 320),
|
||||
"name": @organization.name,
|
||||
"description": @organization.summary.presence || "404 bio not found"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ module ChatChannelMembershipHelper
|
|||
membership_id: membership.id,
|
||||
role: membership.role,
|
||||
status: membership.status,
|
||||
image: Images::Profile.call(membership.user.profile_image_url, length: 90)
|
||||
image: ProfileImage.new(membership.user).get(width: 90)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
@ -21,7 +21,7 @@ module ChatChannelMembershipHelper
|
|||
membership_id: membership.id,
|
||||
role: membership.role,
|
||||
status: membership.status,
|
||||
image: Images::Profile.call(membership.user.profile_image_url, length: 90)
|
||||
image: ProfileImage.new(membership.user).get(width: 90)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ module ChatChannelMembershipsHelper
|
|||
membership_id: membership.id,
|
||||
role: membership.role,
|
||||
status: membership.status,
|
||||
image: Images::Profile.call(membership.user.profile_image_url, length: 90),
|
||||
image: ProfileImage.new(membership.user).get(width: 90),
|
||||
chat_channel_name: membership.chat_channel.channel_name,
|
||||
chat_channel_id: membership.chat_channel.id,
|
||||
slug: membership.chat_channel.slug
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ module MessagesHelper
|
|||
chat_channel_adjusted_slug: new_message.chat_channel.adjusted_slug(current_user, "sender"),
|
||||
channel_type: new_message.chat_channel.channel_type,
|
||||
username: new_message.user.username,
|
||||
profile_image_url: Images::Profile.call(new_message.user.profile_image_url, length: 90),
|
||||
profile_image_url: ProfileImage.new(new_message.user).get(width: 90),
|
||||
message: new_message.message_html,
|
||||
markdown: new_message.message_markdown,
|
||||
edited_at: new_message.edited_at,
|
||||
|
|
|
|||
13
app/labor/profile_image.rb
Normal file
13
app/labor/profile_image.rb
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
class ProfileImage
|
||||
BACKUP_LINK = "https://thepracticaldev.s3.amazonaws.com/i/99mvlsfu5tfj9m7ku25d.png".freeze
|
||||
|
||||
attr_accessor :image_link
|
||||
|
||||
def initialize(resource)
|
||||
@image_link = resource.profile_image_url
|
||||
end
|
||||
|
||||
def get(width: 120)
|
||||
Images::Optimizer.call(image_link || BACKUP_LINK, width: width, height: width, crop: "fill")
|
||||
end
|
||||
end
|
||||
|
|
@ -169,7 +169,7 @@ class ChatChannel < ApplicationRecord
|
|||
|
||||
def user_obj(membership)
|
||||
{
|
||||
profile_image: Images::Profile.call(membership.user.profile_image_url, length: 90),
|
||||
profile_image: ProfileImage.new(membership.user).get(width: 90),
|
||||
darker_color: membership.user.decorate.darker_color,
|
||||
name: membership.user.name,
|
||||
last_opened_at: membership.last_opened_at,
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class ChatChannelMembership < ApplicationRecord
|
|||
|
||||
def channel_image
|
||||
if chat_channel.channel_type == "direct"
|
||||
Images::Profile.call(other_user.profile_image_url, length: 90)
|
||||
ProfileImage.new(other_user).get(width: 90)
|
||||
else
|
||||
ActionController::Base.helpers.asset_path("organization.svg")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ class Message < ApplicationRecord
|
|||
target='_blank' rel='noopener' data-content='sidecar-article'>
|
||||
#{"<div class='chatchannels__richlinkmainimage' style='background-image:url(#{cl_path(article.main_image)})' data-content='sidecar-article' ></div>" if article.main_image.present?}
|
||||
<h1 data-content='sidecar-article'>#{article.title}</h1>
|
||||
<h4 data-content='sidecar-article'><img src='#{Images::Profile.call(article.cached_user.profile_image_url, length: 90)}' /> #{article.cached_user.name}・#{article.readable_publish_date || 'Draft Post'}</h4>
|
||||
<h4 data-content='sidecar-article'><img src='#{ProfileImage.new(article.cached_user).get(width: 90)}' /> #{article.cached_user.name}・#{article.readable_publish_date || 'Draft Post'}</h4>
|
||||
</a>".html_safe
|
||||
elsif (tag = rich_link_tag(anchor))
|
||||
html += "<a href='/t/#{tag.name}'
|
||||
|
|
@ -125,7 +125,7 @@ class Message < ApplicationRecord
|
|||
class='chatchannels__richlink'
|
||||
target='_blank' rel='noopener' data-content='sidecar-user'>
|
||||
<h1 data-content='sidecar-user'>
|
||||
<img src='#{Images::Profile.call(user.profile_image_url, length: 90)}' data-content='sidecar-user' class='chatchannels__richlinkprofilepic' />
|
||||
<img src='#{ProfileImage.new(user).get(width: 90)}' data-content='sidecar-user' class='chatchannels__richlinkprofilepic' />
|
||||
#{user.name}
|
||||
</h1>
|
||||
</a>".html_safe
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ class Organization < ApplicationRecord
|
|||
end
|
||||
|
||||
def profile_image_90
|
||||
Images::Profile.call(profile_image_url, length: 90)
|
||||
ProfileImage.new(self).get(width: 90)
|
||||
end
|
||||
|
||||
def enough_credits?(num_credits_needed)
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class Podcast < ApplicationRecord
|
|||
end
|
||||
|
||||
def image_90
|
||||
Images::Profile.call(profile_image_url, length: 90)
|
||||
ProfileImage.new(self).get(width: 90)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
|
|
@ -490,7 +490,7 @@ class User < ApplicationRecord
|
|||
end
|
||||
|
||||
def profile_image_90
|
||||
Images::Profile.call(profile_image_url, length: 90)
|
||||
ProfileImage.new(self).get(width: 90)
|
||||
end
|
||||
|
||||
def unsubscribe_from_newsletters
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ module Search
|
|||
:website_url
|
||||
|
||||
attribute :main_image do |pde|
|
||||
Images::Profile.call(pde.podcast.profile_image_url, length: 90)
|
||||
ProfileImage.new(pde.podcast).get(width: 90)
|
||||
end
|
||||
attribute :slug, &:podcast_slug
|
||||
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ module Webhook
|
|||
attributes :name, :username, :twitter_username, :github_username
|
||||
attribute :website_url, &:processed_website_url
|
||||
attribute :profile_image do |user|
|
||||
Images::Profile.call(user.profile_image_url, length: 640)
|
||||
ProfileImage.new(user).get(width: 640)
|
||||
end
|
||||
attribute :profile_image_90 do |user|
|
||||
Images::Profile.call(user.profile_image_url, length: 90)
|
||||
ProfileImage.new(user).get(width: 90)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
module Images
|
||||
module Profile
|
||||
BACKUP_LINK = "https://thepracticaldev.s3.amazonaws.com/i/99mvlsfu5tfj9m7ku25d.png".freeze
|
||||
|
||||
def self.call(image_url, length: 120)
|
||||
Optimizer.call(
|
||||
image_url || BACKUP_LINK,
|
||||
width: length,
|
||||
height: length,
|
||||
crop: "fill",
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
<h5 class="card-title text-center">
|
||||
<% if comment.user %>
|
||||
<a href="<%= comment.user.path %>" target="_blank" rel="noopener">
|
||||
<img class="rounded" height="30" src="<%= Images::Profile.call(comment.user.profile_image_url, length: 50) %>" alt="<%= comment.user.username %> profile" /> <%= comment.user.username %>
|
||||
<img class="rounded" height="30" src="<%= ProfileImage.new(comment.user).get(width: 50) %>" alt="<%= comment.user.username %> profile" /> <%= comment.user.username %>
|
||||
</a>
|
||||
<% end %>
|
||||
<% if comment.user && comment.user.twitter_username.present? %>
|
||||
|
|
|
|||
|
|
@ -13,6 +13,6 @@ json.array! @articles do |article|
|
|||
|
||||
json.user do
|
||||
json.name article.user.name
|
||||
json.profile_image_url Images::Profile.call(article.user.profile_image_url, length: 90)
|
||||
json.profile_image_url ProfileImage.new(article.user).get(width: 90)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
json.name user.name
|
||||
json.path "/#{user.path.delete_prefix('/')}"
|
||||
json.username user.try(:username) || user.name
|
||||
json.profile_image Images::Profile.call(user.profile_image_url, length: 60)
|
||||
json.profile_image ProfileImage.new(user).get(width: 60)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
organization_profile_image = ProfileImage.new(organization)
|
||||
|
||||
json.organization do
|
||||
json.extract!(organization, :name, :username, :slug)
|
||||
|
||||
json.profile_image Images::Profile.call(organization.profile_image_url, length: 640)
|
||||
json.profile_image_90 Images::Profile.call(organization.profile_image_url, length: 90)
|
||||
json.profile_image organization_profile_image.get(width: 640)
|
||||
json.profile_image_90 organization_profile_image.get(width: 90)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
user_profile_image = ProfileImage.new(user)
|
||||
|
||||
json.user do
|
||||
json.extract!(user, :name, :username, :twitter_username, :github_username)
|
||||
|
||||
json.website_url user.processed_website_url
|
||||
json.profile_image Images::Profile.call(user.profile_image_url, length: 640)
|
||||
json.profile_image_90 Images::Profile.call(user.profile_image_url, length: 90)
|
||||
json.profile_image user_profile_image.get(width: 640)
|
||||
json.profile_image_90 user_profile_image.get(width: 90)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,4 +13,4 @@ json.extract!(
|
|||
)
|
||||
|
||||
json.joined_at @user.created_at.strftime("%b %e, %Y")
|
||||
json.profile_image Images::Profile.call(@user.profile_image_url, length: 320)
|
||||
json.profile_image ProfileImage.new(@user).get(width: 320)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
<div class="flex">
|
||||
<a href="<%= URL.user(@user) %>" class="crayons-avatar crayons-avatar--2xl shrink-0 mr-4">
|
||||
<img class="crayons-avatar__image" src="<%= Images::Profile.call(@user.profile_image_url, length: 180) %>" alt="<%= @user.username %> profile" />
|
||||
<img class="crayons-avatar__image" src="<%= ProfileImage.new(@user).get(width: 180) %>" alt="<%= @user.username %> profile" />
|
||||
</a>
|
||||
<div>
|
||||
<h3 class="fs-l s:fs-xl m:fs-2xl l:fs-3xl fw-medium"><a href="<%= URL.user(@user) %>" class="crayons-link"><%= @user.name %></a></h3>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
<% end %>
|
||||
<a href='<%= article.user.path %>' class='ltag__link__link'>
|
||||
<div class='ltag__link__pic'>
|
||||
<img src='<%= Images::Profile.call(article.user.profile_image_url, length: 150) %>' alt='<%= "#{article.user.username} image" %>'>
|
||||
<img src='<%= ProfileImage.new(article.user).get(width: 150) %>' alt='<%= article.user.username + " " + "image" %>'>
|
||||
</div>
|
||||
</a>
|
||||
<a href='<%= article.path %>' class='ltag__link__link'>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<div class="flex <% if author == true %>mt-6<% end %>">
|
||||
<a href="/<%= organization.slug %>" class="crayons-logo crayons-logo--2xl shrink-0 mr-4">
|
||||
<% cache("article-organization-image-#{organization.id}-#{organization.updated_at.rfc3339}", expires_in: 100.hours) do %>
|
||||
<img src="<%= Images::Profile.call(organization.profile_image_url) %>" alt="<%= organization.name %>" class="crayons-logo__image" />
|
||||
<img src="<%= ProfileImage.new(organization).get %>" alt="<%= organization.name %>" class="crayons-logo__image" />
|
||||
<% end %>
|
||||
</a>
|
||||
<div>
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
<% end %>
|
||||
|
||||
<a href="/<%= story.cached_user.username %>" class="crayons-avatar <% if story.cached_organization && !@organization_article_index %> crayons-avatar--s absolute -right-2 -bottom-2 border-solid border-2 border-base-inverted <% else %> crayons-avatar--l <% end %> ">
|
||||
<img src="<%= Images::Profile.call(story.cached_user.profile_image_url, length: 90) %>" alt="<%= story.cached_user.username %> profile" class="crayons-avatar__image" />
|
||||
<img src="<%= ProfileImage.new(story.cached_user).get(width: 90) %>" alt="<%= story.cached_user.username %> profile" class="crayons-avatar__image" />
|
||||
</a>
|
||||
</div>
|
||||
<div>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<div class="-mt-4">
|
||||
<a href="<%= @actor.path %>" class="flex">
|
||||
<span class="<% if @actor.class.name == "User" %>crayons-avatar crayons-avatar--xl<% elsif @actor.class.name == "Organization" %>crayons-logo crayons-logo--xl<% end %> mr-2 shrink-0">
|
||||
<img src="<%= Images::Profile.call(@actor.profile_image_url, length: 90) %>" class="<% if @actor.class.name == "User" %>crayons-avatar__image<% elsif @actor.class.name == "Organization" %>crayons-logo__image<% end %>" alt="<%= @actor.name %> profile image">
|
||||
<img src="<%= ProfileImage.new(@actor).get(width: 90) %>" class="<% if @actor.class.name == "User" %>crayons-avatar__image<% elsif @actor.class.name == "Organization" %>crayons-logo__image<% end %>" alt="<%= @actor.name %> profile image">
|
||||
</span>
|
||||
<span class="crayons-link fs-l fw-bold mt-5"><%= @actor.name %></span>
|
||||
</a>
|
||||
|
|
@ -72,7 +72,7 @@
|
|||
<% @sticky_articles.each_with_index do |article, index| %>
|
||||
<a class="crayons-link crayons-link--contentful flex" href="<%= article.path %>">
|
||||
<span class="crayons-avatar mr-2 shrink-0">
|
||||
<img src="<%= Images::Profile.call(article.user.profile_image_url, length: 90) %>" class="crayons-avatar__image" loading="lazy" alt="<%= article.user.name %> profile image">
|
||||
<img src="<%= ProfileImage.new(article.user).get(width: 90) %>" class="crayons-avatar__image" loading="lazy" alt="<%= article.user.name %> profile image">
|
||||
</span>
|
||||
<div>
|
||||
<%= article.title %>
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@
|
|||
<% if @organization %>
|
||||
<a href="<%= @organization.path %>" class="flex items-center mb-4 fs-l fw-medium crayons-link">
|
||||
<span class="crayons-logo crayons-logo--l mr-3">
|
||||
<img src="<%= Images::Profile.call(@organization.profile_image_url, length: 50) %>" class="crayons-logo__image" alt="<%= @organization.name %> profile image">
|
||||
<img src="<%= ProfileImage.new(@organization).get(width: 50) %>" class="crayons-logo__image" alt="<%= @organization.name %> profile image">
|
||||
</span>
|
||||
<%= @organization.name %>
|
||||
</a>
|
||||
|
|
@ -147,7 +147,7 @@
|
|||
|
||||
<div class="crayons-article__subheader">
|
||||
<a href="/<%= @user.username %>" class="flex items-center mr-4 mb-4 s:mb-0 fw-medium crayons-link">
|
||||
<span class="crayons-avatar crayons-avatar--l mr-2"><img class="crayons-avatar__image" src="<%= Images::Profile.call(@user.profile_image_url, length: 50) %>" alt="<%= @user.username %> profile image" /></span>
|
||||
<span class="crayons-avatar crayons-avatar--l mr-2"><img class="crayons-avatar__image" src="<%= ProfileImage.new(@user).get(width: 50) %>" alt="<%= @user.username %> profile image" /></span>
|
||||
<%= @user.name %>
|
||||
</a>
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@
|
|||
<% @moderators.each do |user| %>
|
||||
<div class="widget-user-pic">
|
||||
<a href="/<%= user.username %>" title="<%= user.username %>">
|
||||
<img src="<%= Images::Profile.call(user.profile_image_url, length: 90) %>" alt="<%= user.username %> profile image">
|
||||
<img src="<%= ProfileImage.new(user).get(width: 90) %>" alt="<%= user.username %> profile image">
|
||||
</a>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ json.messages @chat_messages.reverse do |message|
|
|||
json.extract!(message, :id, :user_id, :edited_at)
|
||||
|
||||
json.username message.user.username
|
||||
json.profile_image_url Images::Profile.call(message.user.profile_image_url, length: 90)
|
||||
json.profile_image_url ProfileImage.new(message.user).get(width: 90)
|
||||
json.message message.message_html
|
||||
json.markdown message.message_markdown
|
||||
json.timestamp message.created_at
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ json.user do
|
|||
json.id current_user.id
|
||||
json.username current_user.username
|
||||
json.name current_user.name
|
||||
json.profile_pic Images::Profile.call(current_user.profile_image_url, length: 50)
|
||||
json.profile_pic ProfileImage.new(current_user).get(width: 50)
|
||||
json.twitter_username current_user.twitter_username
|
||||
json.github_username current_user.github_username
|
||||
end
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
<div class="details <%= "low-quality-comment" if decorated_comment.low_quality %>">
|
||||
<a href="/<%= comment.user.username %>">
|
||||
<img class="profile-pic" src="<%= Images::Profile.call(comment.user.profile_image_url, length: 50) %>" alt="<%= comment.user.username %> profile image" />
|
||||
<img class="profile-pic" src="<%= ProfileImage.new(comment.user).get(width: 50) %>" alt="<%= comment.user.username %> profile image" />
|
||||
<span class="comment-username">
|
||||
<span class="comment-username-inner">
|
||||
<%= comment.user.name %>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<div class="liquid-comment">
|
||||
<div class="details">
|
||||
<a href="/<%= comment.user.username %>">
|
||||
<img class="profile-pic" src="<%= Images::Profile.call(comment.user.profile_image_url, length: 50) %>" alt="<%= comment.user.username %> profile image" />
|
||||
<img class="profile-pic" src="<%= ProfileImage.new(comment.user).get(width: 50) %>" alt="<%= comment.user.username %> profile image" />
|
||||
</a>
|
||||
<a href="/<%= comment.user.username %>">
|
||||
<span class="comment-username"><%= comment.user.name %></span>
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
<div class="details <%= "low-quality-comment" if decorated_comment.low_quality %>">
|
||||
<a href="/<%= @user.username %>">
|
||||
<img class="profile-pic" src="<%= Images::Profile.call(@user.profile_image_url, length: 50) %>" alt="<%= @user.username %> profile image" />
|
||||
<img class="profile-pic" src="<%= ProfileImage.new(@user).get(width: 50) %>" alt="<%= @user.username %> profile image" />
|
||||
<span class="comment-username">
|
||||
<span class="comment-username-inner">
|
||||
<%= @user.name %>
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
<% if user %>
|
||||
<div class="crayons-card p-4 m:p-6 flex s:grid single-article break-word content-center" id="follows-<%= follow.id %>">
|
||||
<a href="<%= user.path %>" class="crayons-avatar crayons-avatar--2xl s:mb-2 s:mx-auto">
|
||||
<img alt="<%= user.username %> profile image" class="crayons-avatar__image" src="<%= Images::Profile.call(user.profile_image_url, length: 60) %>" />
|
||||
<img alt="<%= user.username %> profile image" class="crayons-avatar__image" src="<%= ProfileImage.new(user).get(width: 60) %>" />
|
||||
</a>
|
||||
|
||||
<div class="pl-4 s:pl-0 self-center">
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
<% organization = follow.followable %>
|
||||
<div class="crayons-card p-4 m:p-6 flex s:grid single-article break-word content-center" id="follows-<%= follow.id %>">
|
||||
<a href="<%= organization.path %>" class="crayons-logo crayons-logo--2xl s:mb-2 s:mx-auto">
|
||||
<img alt="<%= organization.name %> logo" class="crayons-logo__image" src="<%= Images::Profile.call(organization.profile_image_url, length: 60) %>" />
|
||||
<img alt="<%= organization.name %> logo" class="crayons-logo__image" src="<%= ProfileImage.new(organization).get(width: 60) %>" />
|
||||
</a>
|
||||
|
||||
<div class="pl-4 s:pl-0 self-center">
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
<% if user %>
|
||||
<div class="crayons-card p-4 m:p-6 flex s:grid single-article break-word content-center" id="follows-<%= follow.id %>">
|
||||
<a href="<%= user.path %>" class="crayons-avatar crayons-avatar--2xl s:mb-2 s:mx-auto">
|
||||
<img alt="<%= user.username %> profile image" class="crayons-avatar__image" src="<%= Images::Profile.call(user.profile_image_url, length: 60) %>" />
|
||||
<img alt="<%= user.username %> profile image" class="crayons-avatar__image" src="<%= ProfileImage.new(user).get(width: 60) %>" />
|
||||
</a>
|
||||
|
||||
<div class="pl-4 s:pl-0 self-center">
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<% cache "broadcast-html-#{notification.json_data['broadcast']['title']}" do %>
|
||||
<a href="<%= json_data["user"]["path"] %>" class="small-pic-link-wrapper">
|
||||
<div class="small-pic">
|
||||
<img src="<%= Images::Profile.call(user.profile_image_url) %>" alt="link to <%= json_data["user"]["username"] %>'s profile">
|
||||
<img src="<%= ProfileImage.new(user).get %>" alt="link to <%= json_data["user"]["username"] %>'s profile">
|
||||
</div>
|
||||
</a>
|
||||
<div class="content notification-content broadcast-content" id="<%= sanitized_broadcast_id(json_data["broadcast"]["title"]) %>">
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
</style>
|
||||
<a href="<%= organization.path %>" class="ltag__user__link profile-image-link">
|
||||
<div class="ltag__user__pic">
|
||||
<img src="<%= Images::Profile.call(organization.profile_image_url, length: 150) %>" alt="<%= "#{organization.slug} image" %>" />
|
||||
<img src="<%= ProfileImage.new(organization).get(width: 150) %>" alt="<%= organization.slug + " image" %>" />
|
||||
</div>
|
||||
</a>
|
||||
<div class="ltag__user__content">
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
<% @organization.users.find_each do |user| %>
|
||||
<div class="widget-user-pic">
|
||||
<a href="/<%= user.username %>">
|
||||
<img src="<%= Images::Profile.call(user.profile_image_url, length: 90) %>" alt="<%= user.username %> profile image">
|
||||
<img src="<%= ProfileImage.new(user).get(width: 90) %>" alt="<%= user.username %> profile image">
|
||||
</a>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<div class="partner-credits-explainer">
|
||||
<h3><img src="<%= Images::Profile.call(org.profile_image_url, length: 90) %>" />@<%= org.slug %></h3>
|
||||
<h3><img src="<%= ProfileImage.new(org).get(width: 90) %>" />@<%= org.slug %></h3>
|
||||
<div style="font-size: 0.88em;"><em>This organization account has <%= org.credits.unspent.size %> credits available</em></div>
|
||||
<% sponsorships = org.sponsorships.unexpired.where(level: Sponsorship::METAL_LEVELS) %>
|
||||
<% level_sponsorship = sponsorships.where(level: level).take %>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<h4>What next?</h4>
|
||||
<h3><img src="<%= Images::Profile.call(org.profile_image_url, length: 90) %>" /> Purchase Credits for @<%= org.slug %></h3>
|
||||
<h3><img src="<%= ProfileImage.new(org).get(width: 90) %>" /> Purchase Credits for @<%= org.slug %></h3>
|
||||
<% if org.credits.unspent.size > 0 %>
|
||||
<div style="font-size: 0.88em;">
|
||||
<em>This organization account has <%= org.credits.unspent.size %> credits available</em>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<div class="partner-credits-explainer">
|
||||
<% sponsored_tags = org.sponsorships.unexpired.where(level: :tag).includes(:sponsorable).map { |sp| sp.sponsorable.name } %>
|
||||
<h3><img src="<%= Images::Profile.call(org.profile_image_url, length: 90) %>" />@<%= org.slug %></h3>
|
||||
<h3><img src="<%= ProfileImage.new(org).get(width: 90) %>" />@<%= org.slug %></h3>
|
||||
<% if org.enough_credits?(Sponsorship::CREDITS[level]) %>
|
||||
<div style="font-size: 0.88em;"><em>This organization account has <%= org.credits.unspent.size %> credits available</em></div>
|
||||
<br />
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@
|
|||
<h1 style="font-size:<%= font_size %>vw;"><%= @article.title %></h1>
|
||||
</div>
|
||||
<div class="preview-user">
|
||||
<img src="<%= Images::Profile.call(@article.user.profile_image_url, length: 90) %>" />
|
||||
<img src="<%= ProfileImage.new(@article.user).get(width: 90) %>" />
|
||||
<%= truncate @article.user.name, length: 28 %>・<%= @article.readable_publish_date %>
|
||||
</div>
|
||||
<div class="badge-images">
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@
|
|||
<h1 style="font-size:<%= font_size %>vw;"><%= @article.title %></h1>
|
||||
</div>
|
||||
<div class="preview-user">
|
||||
<img src="<%= Images::Profile.call(@article.user.profile_image_url, length: 90) %>" />
|
||||
<img src="<%= ProfileImage.new(@article.user).get(width: 90) %>" />
|
||||
<%= truncate @article.user.name, length: 28 %>・<%= @article.readable_publish_date %>
|
||||
</div>
|
||||
<div class="badge-images">
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@
|
|||
<h1 style="font-size:<%= font_size %>vw;"><%= @comment.title %></h1>
|
||||
</div>
|
||||
<div class="preview-user">
|
||||
<img src="<%= Images::Profile.call(@comment.user.profile_image_url, length: 90) %>" />
|
||||
<img src="<%= ProfileImage.new(@comment.user).get(width: 90) %>" />
|
||||
<%= truncate @comment.user.name, length: 28 %>・<%= @comment.readable_publish_date %>
|
||||
</div>
|
||||
<div class="badge-images">
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@
|
|||
<% font_size = 4.6 %>
|
||||
<% end %>
|
||||
<h1 style="font-size:<%= font_size %>vw;">
|
||||
<img src="<%= Images::Profile.call(@user.profile_image_url, length: 640) %>" alt="<%= @user.name %> profile image">
|
||||
<img src="<%= ProfileImage.new(@user).get(width: 640) %>" alt="<%= @user.name %> profile image">
|
||||
<%= truncate @user.name, length: 32 %>
|
||||
<br />
|
||||
<span style="font-size: 0.4em;display: inline-block; margin-left: 5.4em; margin-top: -1.7em">@<%= @user.username %></span>
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@
|
|||
<% if user_path.present? %>
|
||||
<a href="<%= user_path %>" class="ltag__user__link profile-image-link">
|
||||
<div class="ltag__user__pic">
|
||||
<img src="<%= Images::Profile.call(user.profile_image_url, length: 150) %>" alt="<%= "#{user.username} image" %>" />
|
||||
<img src="<%= ProfileImage.new(user).get(width: 150) %>" alt="<%= "#{user.username} image" %>" />
|
||||
</div>
|
||||
</a>
|
||||
<% else %>
|
||||
<div class="ltag__user__pic">
|
||||
<img src="<%= Images::Profile.call(user.profile_image_url, length: 150) %>" alt="<%= "#{user.username} image" %>" />
|
||||
<img src="<%= ProfileImage.new(user).get(width: 150) %>" alt="<%= "#{user.username} image" %>" />
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="ltag__user__content">
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
<% @user.organizations.each do |organization| %>
|
||||
<div class="widget-user-pic">
|
||||
<a href="/<%= organization.slug %>">
|
||||
<img src="<%= Images::Profile.call(organization.profile_image_url, length: 90) %>" alt="<%= organization.name %> profile image">
|
||||
<img src="<%= ProfileImage.new(organization).get(width: 90) %>" alt="<%= organization.name %> profile image">
|
||||
</a>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
<div class="flex items-center">
|
||||
<% if @user.profile_image_url.present? %>
|
||||
<span class="crayons-avatar crayons-avatar--xl mr-2"><img alt="<%= @user.username %> profile image" src="<%= Images::Profile.call(@user.profile_image_url, length: 50) %>" class="crayons-avatar__image" /></span>
|
||||
<span class="crayons-avatar crayons-avatar--xl mr-2"><img alt="<%= @user.username %> profile image" src="<%= ProfileImage.new(@user).get(width: 50) %>" class="crayons-avatar__image" /></span>
|
||||
<%= f.file_field :profile_image, accept: "image/*", class: "crayons-card crayons-card--secondary p-3 flex items-center flex-1 w-100" %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
<a href="<%= user_url(@user) %>"></a>
|
||||
<div class="user-profile-header-container">
|
||||
<div class="profile-pic-wrapper">
|
||||
<img class="profile-pic" src="<%= Images::Profile.call(@user.profile_image_url, length: 320) %>" alt="<%= @user.username %> profile" style="border-color:<%= user_colors(@user)[:bg] %>;background:<%= user_colors(@user)[:bg] %>" />
|
||||
<img class="profile-pic" src="<%= ProfileImage.new(@user).get(width: 320) %>" alt="<%= @user.username %> profile" style="border-color:<%= user_colors(@user)[:bg] %>;background:<%= user_colors(@user)[:bg] %>" />
|
||||
</div>
|
||||
<div class="profile-details">
|
||||
<h1 style="color:<%= HexComparer.new([user_colors(@user)[:bg], user_colors(@user)[:text]]).brightness(0.78) %>">
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@ json.array! @users.each do |user|
|
|||
json.extract!(user, :id, :name, :username)
|
||||
|
||||
json.summary truncate(user.summary.presence || "Active #{community_name} author", length: 100)
|
||||
json.profile_image_url Images::Profile.call(user.profile_image_url, length: 90)
|
||||
json.profile_image_url ProfileImage.new(user).get(width: 90)
|
||||
json.following false
|
||||
end
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
<div class="user-profile-header" style="<%= user_colors_style(@user) %>">
|
||||
<div class="user-profile-header-container">
|
||||
<div class="profile-pic-wrapper">
|
||||
<img class="profile-pic" src="<%= Images::Profile.call(@user.profile_image_url, length: 320) %>" alt="<%= @user.username %> profile" style="border-color:<%= user_colors(@user)[:bg] %>;background:<%= user_colors(@user)[:bg] %>" />
|
||||
<img class="profile-pic" src="<%= ProfileImage.new(@user).get(width: 320) %>" alt="<%= @user.username %> profile" style="border-color:<%= user_colors(@user)[:bg] %>;background:<%= user_colors(@user)[:bg] %>" />
|
||||
</div>
|
||||
<div class="profile-details">
|
||||
<h1>
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe Images::Profile, type: :services do
|
||||
RSpec.describe ProfileImage, type: :labor do
|
||||
describe "#get" do
|
||||
it "returns user profile_image_url" do
|
||||
user = build_stubbed(:user)
|
||||
expect(described_class.call(user.profile_image_url)).to eq(user.profile_image_url)
|
||||
expect(described_class.new(user).get).to eq(user.profile_image_url)
|
||||
end
|
||||
|
||||
context "when user has no profile_image" do
|
||||
it "returns backup image prefixed with Cloudinary" do
|
||||
user = build_stubbed(:user, profile_image: nil)
|
||||
correct_prefix = "/c_fill,f_auto,fl_progressive,h_120,q_auto,w_120/"
|
||||
expect(described_class.call(user.profile_image_url)).to include(correct_prefix + described_class::BACKUP_LINK)
|
||||
expect(described_class.new(user).get).to include(correct_prefix + described_class::BACKUP_LINK)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -35,7 +35,7 @@ RSpec.describe LinkTag, type: :liquid_tag do
|
|||
<div class='ltag__link'>
|
||||
<a href='#{article.user.path}' class='ltag__link__link'>
|
||||
<div class='ltag__link__pic'>
|
||||
<img src='#{Images::Profile.call(article.user.profile_image_url, length: 150)}' alt='#{article.user.username} image'>
|
||||
<img src='#{ProfileImage.new(article.user).get(width: 150)}' alt='#{article.user.username} image'>
|
||||
</div>
|
||||
</a>
|
||||
<a href='#{article.path}' class='ltag__link__link'>
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ RSpec.describe "Api::V0::FollowersController", type: :request do
|
|||
expect(response_follower["name"]).to eq(follower.name)
|
||||
expect(response_follower["path"]).to eq(follower.path)
|
||||
expect(response_follower["username"]).to eq(follower.username)
|
||||
expect(response_follower["profile_image"]).to eq(Images::Profile.call(follower.profile_image_url, length: 60))
|
||||
expect(response_follower["profile_image"]).to eq(ProfileImage.new(follower).get(width: 60))
|
||||
end
|
||||
|
||||
it "supports pagination" do
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ RSpec.describe "Api::V0::Users", type: :request do
|
|||
end
|
||||
|
||||
expect(response_user["joined_at"]).to eq(user.created_at.strftime("%b %e, %Y"))
|
||||
expect(response_user["profile_image"]).to eq(Images::Profile.call(user.profile_image_url, length: 320))
|
||||
expect(response_user["profile_image"]).to eq(ProfileImage.new(user).get(width: 320))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ RSpec.describe "Api::V0::Users", type: :request do
|
|||
end
|
||||
|
||||
expect(response_user["joined_at"]).to eq(user.created_at.strftime("%b %e, %Y"))
|
||||
expect(response_user["profile_image"]).to eq(Images::Profile.call(user.profile_image_url, length: 320))
|
||||
expect(response_user["profile_image"]).to eq(ProfileImage.new(user).get(width: 320))
|
||||
end
|
||||
|
||||
it "returns 200 if no authentication and site config is set to private but user is authenticated" do
|
||||
|
|
@ -92,7 +92,7 @@ RSpec.describe "Api::V0::Users", type: :request do
|
|||
end
|
||||
|
||||
expect(response_user["joined_at"]).to eq(user.created_at.strftime("%b %e, %Y"))
|
||||
expect(response_user["profile_image"]).to eq(Images::Profile.call(user.profile_image_url, length: 320))
|
||||
expect(response_user["profile_image"]).to eq(ProfileImage.new(user).get(width: 320))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -121,18 +121,15 @@ RSpec.describe "Api::V0::Webhooks", type: :request do
|
|||
get api_webhook_path(webhook.id)
|
||||
|
||||
response_webhook_user = response.parsed_body["user"]
|
||||
user_profile_image = ProfileImage.new(webhook.user)
|
||||
|
||||
expect(response_webhook_user).to eq({
|
||||
"name" => webhook.user.name,
|
||||
"username" => webhook.user.username,
|
||||
"twitter_username" => webhook.user.twitter_username,
|
||||
"github_username" => webhook.user.github_username,
|
||||
"website_url" => webhook.user.processed_website_url,
|
||||
"profile_image" => Images::Profile.call(webhook.user.profile_image_url,
|
||||
length: 640),
|
||||
"profile_image_90" => Images::Profile.call(webhook.user.profile_image_url,
|
||||
length: 90)
|
||||
})
|
||||
expect(response_webhook_user["name"]).to eq(webhook.user.name)
|
||||
expect(response_webhook_user["username"]).to eq(webhook.user.username)
|
||||
expect(response_webhook_user["twitter_username"]).to eq(webhook.user.twitter_username)
|
||||
expect(response_webhook_user["github_username"]).to eq(webhook.user.github_username)
|
||||
expect(response_webhook_user["website_url"]).to eq(webhook.user.processed_website_url)
|
||||
expect(response_webhook_user["profile_image"]).to eq(user_profile_image.get(width: 640))
|
||||
expect(response_webhook_user["profile_image_90"]).to eq(user_profile_image.get(width: 90))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ RSpec.describe "ArticlesShow", type: :request do
|
|||
"@id" => URL.organization(organization)
|
||||
},
|
||||
"url" => URL.organization(organization),
|
||||
"image" => Images::Profile.call(organization.profile_image_url, length: 320),
|
||||
"image" => ProfileImage.new(organization).get(width: 320),
|
||||
"name" => organization.name,
|
||||
"description" => organization.summary
|
||||
},
|
||||
|
|
|
|||
|
|
@ -406,7 +406,7 @@ RSpec.describe "ChatChannels", type: :request do
|
|||
expected_last_opened_at = Time.zone.parse(response_channel_users[user.username]["last_opened_at"]).to_i
|
||||
response_user = response_channel_users[user.username]
|
||||
|
||||
expect(response_user["profile_image"]).to eq(Images::Profile.call(user.profile_image_url, length: 90))
|
||||
expect(response_user["profile_image"]).to eq(ProfileImage.new(user).get(width: 90))
|
||||
expect(response_user["darker_color"]).to eq(user.decorate.darker_color)
|
||||
expect(response_user["name"]).to eq(user.name)
|
||||
expect(expected_last_opened_at).to eq(user.chat_channel_memberships.last.last_opened_at.to_i)
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ RSpec.describe "FollowingsController", type: :request do
|
|||
expect(response_following["name"]).to eq(followed.name)
|
||||
expect(response_following["path"]).to eq(followed.path)
|
||||
expect(response_following["username"]).to eq(followed.username)
|
||||
expect(response_following["profile_image"]).to eq(Images::Profile.call(followed.profile_image_url, length: 60))
|
||||
expect(response_following["profile_image"]).to eq(ProfileImage.new(followed).get(width: 60))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -111,7 +111,7 @@ RSpec.describe "FollowingsController", type: :request do
|
|||
expect(response_following["name"]).to eq(followed.name)
|
||||
expect(response_following["path"]).to eq(followed.path)
|
||||
expect(response_following["username"]).to eq(followed.username)
|
||||
expect(response_following["profile_image"]).to eq(Images::Profile.call(followed.profile_image_url, length: 60))
|
||||
expect(response_following["profile_image"]).to eq(ProfileImage.new(followed).get(width: 60))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -148,7 +148,7 @@ RSpec.describe "FollowingsController", type: :request do
|
|||
expect(response_following["name"]).to eq(followed.name)
|
||||
expect(response_following["path"]).to eq("/#{followed.path}")
|
||||
expect(response_following["username"]).to eq(followed.name)
|
||||
expect(response_following["profile_image"]).to eq(Images::Profile.call(followed.profile_image_url, length: 60))
|
||||
expect(response_following["profile_image"]).to eq(ProfileImage.new(followed).get(width: 60))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ RSpec.describe "UserShow", type: :request do
|
|||
user.twitch_username,
|
||||
user.website_url,
|
||||
],
|
||||
"image" => Images::Profile.call(user.profile_image_url, length: 320),
|
||||
"image" => ProfileImage.new(user).get(width: 320),
|
||||
"name" => user.name,
|
||||
"email" => user.email,
|
||||
"jobTitle" => user.employment_title,
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ RSpec.describe "Users", type: :request do
|
|||
"name" => suggested_user.name,
|
||||
"username" => suggested_user.username,
|
||||
"summary" => suggested_user.summary,
|
||||
"profile_image_url" => Images::Profile.call(suggested_user.profile_image_url, length: 90),
|
||||
"profile_image_url" => ProfileImage.new(suggested_user).get(width: 90),
|
||||
"following" => false,
|
||||
)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue