mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
Make rubocop happy again.
This commit is contained in:
@ -563,49 +563,49 @@ module DiscourseNarrativeBot
|
||||
|
||||
private
|
||||
|
||||
def name
|
||||
@user.username.titleize
|
||||
end
|
||||
def name
|
||||
@user.username.titleize
|
||||
end
|
||||
|
||||
def logo_group(size, width, height)
|
||||
return unless SiteSetting.logo_small_url.present?
|
||||
def logo_group(size, width, height)
|
||||
return unless SiteSetting.logo_small_url.present?
|
||||
|
||||
begin
|
||||
uri = URI(SiteSetting.logo_small_url)
|
||||
begin
|
||||
uri = URI(SiteSetting.logo_small_url)
|
||||
|
||||
logo_uri =
|
||||
if uri.host.blank? || uri.scheme.blank?
|
||||
URI("#{Discourse.base_url}/#{uri.path}")
|
||||
else
|
||||
uri
|
||||
end
|
||||
logo_uri =
|
||||
if uri.host.blank? || uri.scheme.blank?
|
||||
URI("#{Discourse.base_url}/#{uri.path}")
|
||||
else
|
||||
uri
|
||||
end
|
||||
|
||||
<<~URL
|
||||
<<~URL
|
||||
<g transform="translate(#{width / 2 - (size / 2)} #{height})">
|
||||
<image height="#{size}px" width="#{size}px" #{base64_image_link(logo_uri)}/>
|
||||
</g>
|
||||
URL
|
||||
rescue URI::InvalidURIError
|
||||
''
|
||||
end
|
||||
rescue URI::InvalidURIError
|
||||
''
|
||||
end
|
||||
end
|
||||
|
||||
def base64_image_link(url)
|
||||
if image = fetch_image(url)
|
||||
"xlink:href=\"data:image/png;base64,#{Base64.strict_encode64(image)}\""
|
||||
else
|
||||
""
|
||||
end
|
||||
def base64_image_link(url)
|
||||
if image = fetch_image(url)
|
||||
"xlink:href=\"data:image/png;base64,#{Base64.strict_encode64(image)}\""
|
||||
else
|
||||
""
|
||||
end
|
||||
end
|
||||
|
||||
def fetch_image(url)
|
||||
URI(url).open('rb', redirect: true, allow_redirections: :all).read
|
||||
rescue OpenURI::HTTPError
|
||||
# Ignore if fetching image returns a non 200 response
|
||||
end
|
||||
def fetch_image(url)
|
||||
URI(url).open('rb', redirect: true, allow_redirections: :all).read
|
||||
rescue OpenURI::HTTPError
|
||||
# Ignore if fetching image returns a non 200 response
|
||||
end
|
||||
|
||||
def avatar_url
|
||||
UrlHelper.absolute(Discourse.base_uri + @user.avatar_template.gsub('{size}', '250'))
|
||||
end
|
||||
def avatar_url
|
||||
UrlHelper.absolute(Discourse.base_uri + @user.avatar_template.gsub('{size}', '250'))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user