Commit 79c80de9 authored by Tim Zallmann's avatar Tim Zallmann

Making private project avatars use local paths + Some Group Icons

parent 4a0f720a
...@@ -41,7 +41,12 @@ module ApplicationHelper ...@@ -41,7 +41,12 @@ module ApplicationHelper
end end
if project.avatar_url if project.avatar_url
image_tag project.avatar_url, options if project.private?
options[:use_original_source] = true
image_tag project.avatar_url(use_asset_path: false), options
else
image_tag project.avatar_url, options
end
else # generated icon else # generated icon
project_identicon(project, options) project_identicon(project, options)
end end
......
...@@ -12,7 +12,7 @@ module GroupsHelper ...@@ -12,7 +12,7 @@ module GroupsHelper
group = Group.find_by_full_path(group) group = Group.find_by_full_path(group)
end end
group.try(:avatar_url) || ActionController::Base.helpers.image_path('no_group_avatar.png') group.try(:avatar_url, use_asset_path: false) || ActionController::Base.helpers.image_path('no_group_avatar.png')
end end
def group_title(group, name = nil, url = nil) def group_title(group, name = nil, url = nil)
...@@ -89,7 +89,12 @@ module GroupsHelper ...@@ -89,7 +89,12 @@ module GroupsHelper
link_to(group_path(group), class: "group-path #{'breadcrumb-item-text' unless for_dropdown} js-breadcrumb-item-text #{'hidable' if hidable}") do link_to(group_path(group), class: "group-path #{'breadcrumb-item-text' unless for_dropdown} js-breadcrumb-item-text #{'hidable' if hidable}") do
output = output =
if (group.try(:avatar_url) || show_avatar) && !Rails.env.test? if (group.try(:avatar_url) || show_avatar) && !Rails.env.test?
image_tag(group_icon(group), class: "avatar-tile", width: 15, height: 15) if group.private?
puts "GROUP IS PRIVATE : " + group_icon(group)
image_tag(group_icon(group), class: "avatar-tile", width: 15, height: 15, use_original_source: true)
else
image_tag(group_icon(group), class: "avatar-tile", width: 15, height: 15)
end
else else
"" ""
end end
......
...@@ -9,7 +9,11 @@ module LazyImageTagHelper ...@@ -9,7 +9,11 @@ module LazyImageTagHelper
unless options.delete(:lazy) == false unless options.delete(:lazy) == false
options[:data] ||= {} options[:data] ||= {}
options[:data][:src] = path_to_image(source) unless options.delete(:use_original_source) == true
options[:data][:src] = path_to_image(source)
else
options[:data][:src] = source
end
options[:class] ||= "" options[:class] ||= ""
options[:class] << " lazy" options[:class] << " lazy"
......
module Avatarable module Avatarable
extend ActiveSupport::Concern extend ActiveSupport::Concern
def avatar_path(only_path: true) def avatar_path(only_path: true, use_asset_path: true)
return unless self[:avatar].present? return unless self[:avatar].present?
# If only_path is true then use the relative path of avatar. # If only_path is true then use the relative path of avatar.
...@@ -9,10 +9,14 @@ module Avatarable ...@@ -9,10 +9,14 @@ module Avatarable
asset_host = ActionController::Base.asset_host asset_host = ActionController::Base.asset_host
gitlab_host = only_path ? gitlab_config.relative_url_root : gitlab_config.url gitlab_host = only_path ? gitlab_config.relative_url_root : gitlab_config.url
# If asset_host is set then it is expected that assets are handled by a standalone host. if use_asset_path
# That means we do not want to get GitLab's relative_url_root option anymore. # If asset_host is set then it is expected that assets are handled by a standalone host.
host = asset_host.present? ? asset_host : gitlab_host # That means we do not want to get GitLab's relative_url_root option anymore.
host = asset_host.present? ? asset_host : gitlab_host
[host, avatar.url].join [host, avatar.url].join
else
avatar.url
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment