DEV: Apply syntax_tree formatting to lib/*

This commit is contained in:
David Taylor
2023-01-09 12:10:19 +00:00
parent b0fda61a8e
commit 6417173082
507 changed files with 16550 additions and 12627 deletions

View File

@@ -58,21 +58,31 @@ module PrettyText
reverse_map[value] << key
end
Upload.where(sha1: map.values).pluck(:sha1, :url, :extension, :original_filename, :secure).each do |row|
sha1, url, extension, original_filename, secure = row
Upload
.where(sha1: map.values)
.pluck(:sha1, :url, :extension, :original_filename, :secure)
.each do |row|
sha1, url, extension, original_filename, secure = row
if short_urls = reverse_map[sha1]
secure_uploads = SiteSetting.secure_uploads? && secure
if short_urls = reverse_map[sha1]
secure_uploads = SiteSetting.secure_uploads? && secure
short_urls.each do |short_url|
result[short_url] = {
url: secure_uploads ? Upload.secure_uploads_url_from_upload_url(url) : Discourse.store.cdn_url(url),
short_path: Upload.short_path(sha1: sha1, extension: extension),
base62_sha1: Upload.base62_sha1(sha1)
}
short_urls.each do |short_url|
result[short_url] = {
url:
(
if secure_uploads
Upload.secure_uploads_url_from_upload_url(url)
else
Discourse.store.cdn_url(url)
end
),
short_path: Upload.short_path(sha1: sha1, extension: extension),
base62_sha1: Upload.base62_sha1(sha1),
}
end
end
end
end
end
result
@@ -83,15 +93,9 @@ module PrettyText
# TODO this only handles public topics, secured one do not get this
topic = Topic.find_by(id: topic_id)
if topic && Guardian.new.can_see?(topic)
{
title: Rack::Utils.escape_html(topic.title),
href: topic.url
}
{ title: Rack::Utils.escape_html(topic.title), href: topic.url }
elsif topic
{
title: I18n.t("on_another_topic"),
href: Discourse.base_url + topic.slugless_url
}
{ title: I18n.t("on_another_topic"), href: Discourse.base_url + topic.slugless_url }
end
end
@@ -103,7 +107,7 @@ module PrettyText
if !is_tag && category = Category.query_from_hashtag_slug(text)
[category.url, text]
elsif (!is_tag && tag = Tag.find_by(name: text)) ||
(is_tag && tag = Tag.find_by(name: text.gsub!(TAG_HASHTAG_POSTFIX, '')))
(is_tag && tag = Tag.find_by(name: text.gsub!(TAG_HASHTAG_POSTFIX, "")))
[tag.url, text]
else
nil
@@ -124,9 +128,11 @@ module PrettyText
cooking_user = User.find(cooking_user_id)
end
result = HashtagAutocompleteService.new(
Guardian.new(cooking_user)
).lookup([slug], types_in_priority_order)
result =
HashtagAutocompleteService.new(Guardian.new(cooking_user)).lookup(
[slug],
types_in_priority_order,
)
found_hashtag = nil
types_in_priority_order.each do |type|