DEV: Apply syntax_tree formatting to app/*

This commit is contained in:
David Taylor
2023-01-09 12:20:10 +00:00
parent a641ce4b62
commit 5a003715d3
696 changed files with 18447 additions and 15481 deletions

View File

@ -6,9 +6,7 @@ module UserNotificationsHelper
def indent(text, by = 2)
spacer = " " * by
result = +""
text.each_line do |line|
result << spacer << line
end
text.each_line { |line| result << spacer << line }
result
end
@ -32,24 +30,28 @@ module UserNotificationsHelper
end
def first_paragraphs_from(html)
doc = Nokogiri::HTML5(html)
doc = Nokogiri.HTML5(html)
result = +""
length = 0
doc.css('body > p, aside.onebox, body > ul, body > blockquote').each do |node|
if node.text.present?
result << node.to_s
length += node.inner_text.length
return result if length >= SiteSetting.digest_min_excerpt_length
doc
.css("body > p, aside.onebox, body > ul, body > blockquote")
.each do |node|
if node.text.present?
result << node.to_s
length += node.inner_text.length
return result if length >= SiteSetting.digest_min_excerpt_length
end
end
end
return result unless result.blank?
# If there is no first paragraph with text, return the first paragraph with
# something else (an image) or div (a onebox).
doc.css('body > p:not(:empty), body > div:not(:empty), body > p > div.lightbox-wrapper img').first
doc.css(
"body > p:not(:empty), body > div:not(:empty), body > p > div.lightbox-wrapper img",
).first
end
def email_excerpt(html_arg, post = nil)
@ -58,7 +60,7 @@ module UserNotificationsHelper
end
def normalize_name(name)
name.downcase.gsub(/[\s_-]/, '')
name.downcase.gsub(/[\s_-]/, "")
end
def show_username_on_post(post)
@ -70,9 +72,7 @@ module UserNotificationsHelper
end
def show_name_on_post(post)
SiteSetting.enable_names? &&
SiteSetting.display_name_on_posts? &&
post.user.name.present? &&
SiteSetting.enable_names? && SiteSetting.display_name_on_posts? && post.user.name.present? &&
normalize_name(post.user.name) != normalize_name(post.user.username)
end
@ -94,7 +94,7 @@ module UserNotificationsHelper
end
def show_image_with_url(url)
!(url.nil? || url.downcase.end_with?('svg'))
!(url.nil? || url.downcase.end_with?("svg"))
end
def email_image_url(basename)
@ -106,5 +106,4 @@ module UserNotificationsHelper
rescue URI::Error
href
end
end