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
end
if project.avatar_url
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
project_identicon(project, options)
end
......
......@@ -12,7 +12,7 @@ module GroupsHelper
group = Group.find_by_full_path(group)
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
def group_title(group, name = nil, url = nil)
......@@ -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
output =
if (group.try(:avatar_url) || show_avatar) && !Rails.env.test?
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
""
end
......
......@@ -9,7 +9,11 @@ module LazyImageTagHelper
unless options.delete(:lazy) == false
options[:data] ||= {}
unless options.delete(:use_original_source) == true
options[:data][:src] = path_to_image(source)
else
options[:data][:src] = source
end
options[:class] ||= ""
options[:class] << " lazy"
......
module Avatarable
extend ActiveSupport::Concern
def avatar_path(only_path: true)
def avatar_path(only_path: true, use_asset_path: true)
return unless self[:avatar].present?
# If only_path is true then use the relative path of avatar.
......@@ -9,10 +9,14 @@ module Avatarable
asset_host = ActionController::Base.asset_host
gitlab_host = only_path ? gitlab_config.relative_url_root : gitlab_config.url
if use_asset_path
# If asset_host is set then it is expected that assets are handled by a standalone 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
else
avatar.url
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