Skip to content

Commit

Permalink
diaspora#8239 Shorten Report text in reported posts list
Browse files Browse the repository at this point in the history
  • Loading branch information
tclaus committed Aug 22, 2021
1 parent b2eea32 commit 6bb5180
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
22 changes: 20 additions & 2 deletions app/helpers/notifier_helper.rb
Expand Up @@ -10,7 +10,16 @@ def post_message(post, opts={})
if post.respond_to? :message
post.message.try(:plain_text_without_markdown).presence || post_page_title(post)
else
I18n.translate "notifier.a_post_you_shared"
I18n.t "notifier.a_post_you_shared"
end
end

def truncated_post_message(post)
if post.respond_to? :message
plain_text = post.message.try(:plain_text_without_markdown).presence || post_page_title(post)
truncate(plain_text, length: 300)
else
I18n.t "notifier.a_post_you_shared"
end
end

Expand All @@ -20,7 +29,16 @@ def comment_message(comment, opts={})
if comment.post.public?
comment.message.plain_text_without_markdown
else
I18n.translate "notifier.a_limited_post_comment"
I18n.t "notifier.a_limited_post_comment"
end
end

def truncated_comment_message(comment)
if comment.post.public?
plain_text = comment.message.plain_text_without_markdown
truncate(plain_text, length: 180)
else
I18n.t "notifier.a_limited_post_comment"
end
end
end
6 changes: 4 additions & 2 deletions app/helpers/report_helper.rb
Expand Up @@ -5,19 +5,21 @@
# the COPYRIGHT file.

module ReportHelper
# rubocop:disable Rails/OutputSafety
def report_content(report)
case (item = report.item)
when Post
raw t("report.post_label", content: link_to(post_message(item), post_path(item.id)))
raw t("report.post_label", content: link_to(truncated_post_message(item), post_path(item.id)))
when Comment
raw t("report.comment_label", data: link_to(
h(comment_message(item)),
h(truncated_comment_message(item)),
post_path(item.post.id, anchor: item.guid)
))
else
t("report.not_found")
end
end
# rubocop:enable Rails/OutputSafety

def link_to_content(report)
case (item = report.item)
Expand Down

0 comments on commit 6bb5180

Please sign in to comment.