From 73f710e73712a349e4e65f16010012c3ff61c3d7 Mon Sep 17 00:00:00 2001 From: taitus Date: Wed, 4 May 2022 20:38:58 +0200 Subject: [PATCH] Unify format and indentation for sanitize, i18n and links on emails In the mail section we have very different indentations and formatting in texts with sanitize, links and texts with interpolations. In my opinion it helps a lot to have clearer indentations in these cases. This may not be the best way to indent them, but at least I think it is clearer than it was and at least relatively unified. --- .../mailer/budget_investment_created.html.erb | 23 ++++++++++++------- .../budget_investment_unfeasible.html.erb | 10 +++++--- app/views/mailer/comment.html.erb | 17 ++++++++------ .../direct_message_for_receiver.html.erb | 14 +++++++---- .../mailer/direct_message_for_sender.html.erb | 3 +-- app/views/mailer/email_verification.html.erb | 22 +++++++++++------- app/views/mailer/evaluation_comment.html.erb | 11 +++++---- .../mailer/machine_learning_error.html.erb | 3 ++- .../mailer/machine_learning_success.html.erb | 3 ++- app/views/mailer/newsletter.html.erb | 17 ++++++++------ .../proposal_notification_digest.html.erb | 23 +++++++++++++------ app/views/mailer/reply.html.erb | 17 ++++++++------ 12 files changed, 102 insertions(+), 61 deletions(-) diff --git a/app/views/mailer/budget_investment_created.html.erb b/app/views/mailer/budget_investment_created.html.erb index 2b2efbcbf..8c2da30c6 100644 --- a/app/views/mailer/budget_investment_created.html.erb +++ b/app/views/mailer/budget_investment_created.html.erb @@ -5,20 +5,27 @@

- <%= sanitize(t("mailers.budget_investment_created.intro", - author: @investment.author.name)) %> + <%= sanitize( + t("mailers.budget_investment_created.intro", author: @investment.author.name) + ) %>

- <%= sanitize(t("mailers.budget_investment_created.text", - investment: @investment.title, - budget: @investment.budget.name)) %> + <%= sanitize( + t("mailers.budget_investment_created.text", + investment: @investment.title, + budget: @investment.budget.name) + ) %>

- <%= sanitize(t("mailers.budget_investment_created.follow", - link: link_to(t("mailers.budget_investment_created.follow_link"), budgets_url, - style: css_for_mailer_link)), attributes: %w[href style]) %> + <%= sanitize( + t("mailers.budget_investment_created.follow", + link: link_to(t("mailers.budget_investment_created.follow_link"), budgets_url, + style: css_for_mailer_link) + ), + attributes: %w[href style] + ) %>

diff --git a/app/views/mailer/budget_investment_unfeasible.html.erb b/app/views/mailer/budget_investment_unfeasible.html.erb index 3420b4687..0fd60982d 100644 --- a/app/views/mailer/budget_investment_unfeasible.html.erb +++ b/app/views/mailer/budget_investment_unfeasible.html.erb @@ -13,10 +13,14 @@

- <%= sanitize(t("mailers.budget_investment_unfeasible.new", + <%= sanitize( + t("mailers.budget_investment_unfeasible.new", url: link_to(t("mailers.budget_investment_unfeasible.new_href"), - new_budget_investment_url(@investment.budget), style: css_for_mailer_link)), - attributes: %w[href style]) %> + new_budget_investment_url(@investment.budget), + style: css_for_mailer_link) + ), + attributes: %w[href style] + ) %>

diff --git a/app/views/mailer/comment.html.erb b/app/views/mailer/comment.html.erb index 93e5888d8..3c277bbd8 100644 --- a/app/views/mailer/comment.html.erb +++ b/app/views/mailer/comment.html.erb @@ -18,13 +18,16 @@

- <%= sanitize(t("mailers.config.unsubscribe_text", - notifications: link_to( - t("mailers.config.notifications_link"), - edit_subscriptions_url(token: @token), - style: css_for_mailer_link + <%= sanitize( + t("mailers.config.unsubscribe_text", + notifications: link_to( + t("mailers.config.notifications_link"), + edit_subscriptions_url(token: @token), + style: css_for_mailer_link + ), + notification: User.human_attribute_name(:email_on_comment) ), - notification: User.human_attribute_name(:email_on_comment) - ), attributes: %w[href style]) %> + attributes: %w[href style] + ) %>

diff --git a/app/views/mailer/direct_message_for_receiver.html.erb b/app/views/mailer/direct_message_for_receiver.html.erb index e680ec668..efe41e744 100644 --- a/app/views/mailer/direct_message_for_receiver.html.erb +++ b/app/views/mailer/direct_message_for_receiver.html.erb @@ -21,10 +21,14 @@

- <%= sanitize(t("mailers.direct_message_for_receiver.unsubscribe_text", - notifications: link_to(t("mailers.config.notifications_link"), - edit_subscriptions_url(token: @token), - style: css_for_mailer_link)), - attributes: %w[href style]) %> + <%= sanitize( + t("mailers.direct_message_for_receiver.unsubscribe_text", + notifications: link_to( + t("mailers.config.notifications_link"), + edit_subscriptions_url(token: @token), + style: css_for_mailer_link) + ), + attributes: %w[href style] + ) %>

diff --git a/app/views/mailer/direct_message_for_sender.html.erb b/app/views/mailer/direct_message_for_sender.html.erb index c775d936f..f5bdbdaed 100644 --- a/app/views/mailer/direct_message_for_sender.html.erb +++ b/app/views/mailer/direct_message_for_sender.html.erb @@ -5,8 +5,7 @@

- <%= sanitize(t("mailers.direct_message_for_sender.text", - receiver: @direct_message.receiver.name)) %> + <%= sanitize(t("mailers.direct_message_for_sender.text", receiver: @direct_message.receiver.name)) %>

diff --git a/app/views/mailer/email_verification.html.erb b/app/views/mailer/email_verification.html.erb index 27365639f..fe1525a3f 100644 --- a/app/views/mailer/email_verification.html.erb +++ b/app/views/mailer/email_verification.html.erb @@ -9,17 +9,23 @@

- <%= sanitize(t("mailers.email_verification.instructions", - verification_link: link_to( - t("mailers.email_verification.click_here_to_verify"), - email_url(email_verification_token: @token), style: css_for_mailer_link)), - attributes: %w[href style]) %> + <%= sanitize( + t("mailers.email_verification.instructions", + verification_link: link_to( + t("mailers.email_verification.click_here_to_verify"), + email_url(email_verification_token: @token), + style: css_for_mailer_link) + ), + attributes: %w[href style] + ) %>

- <%= sanitize(t("mailers.email_verification.instructions_2", - document_type: humanize_document_type(@document_type), - document_number: @document_number)) %> + <%= sanitize( + t("mailers.email_verification.instructions_2", + document_type: humanize_document_type(@document_type), + document_number: @document_number) + ) %>

diff --git a/app/views/mailer/evaluation_comment.html.erb b/app/views/mailer/evaluation_comment.html.erb index 1a8f44c26..fa95263ed 100644 --- a/app/views/mailer/evaluation_comment.html.erb +++ b/app/views/mailer/evaluation_comment.html.erb @@ -9,11 +9,12 @@

- <%= sanitize(t( - "mailers.evaluation_comment.new_comment_by", - commenter: @email.comment.author.name, - investment: valuation_comments_link(@email.commentable) - )) %> + <%= sanitize( + t("mailers.evaluation_comment.new_comment_by", + commenter: @email.comment.author.name, + investment: valuation_comments_link(@email.commentable) + ) + ) %>

diff --git a/app/views/mailer/machine_learning_error.html.erb b/app/views/mailer/machine_learning_error.html.erb index d28a9fbf1..9a14a2d3c 100644 --- a/app/views/mailer/machine_learning_error.html.erb +++ b/app/views/mailer/machine_learning_error.html.erb @@ -9,7 +9,8 @@

- <%= link_to t("mailers.machine_learning_error.link"), admin_machine_learning_url, + <%= link_to t("mailers.machine_learning_error.link"), + admin_machine_learning_url, style: "color: #2895F1; text-decoration:none;" %>

diff --git a/app/views/mailer/machine_learning_success.html.erb b/app/views/mailer/machine_learning_success.html.erb index 2e55baff0..ec22b0b8c 100644 --- a/app/views/mailer/machine_learning_success.html.erb +++ b/app/views/mailer/machine_learning_success.html.erb @@ -9,7 +9,8 @@

- <%= link_to t("mailers.machine_learning_success.link"), admin_machine_learning_url, + <%= link_to t("mailers.machine_learning_success.link"), + admin_machine_learning_url, style: "color: #2895F1; text-decoration:none;" %>

diff --git a/app/views/mailer/newsletter.html.erb b/app/views/mailer/newsletter.html.erb index 59a9375ad..7b7d5130d 100644 --- a/app/views/mailer/newsletter.html.erb +++ b/app/views/mailer/newsletter.html.erb @@ -5,13 +5,16 @@

- <%= sanitize(t("mailers.config.unsubscribe_text", - notifications: link_to( - t("mailers.config.notifications_link"), - edit_subscriptions_url(token: @token), - style: css_for_mailer_link + <%= sanitize( + t("mailers.config.unsubscribe_text", + notifications: link_to( + t("mailers.config.notifications_link"), + edit_subscriptions_url(token: @token), + style: css_for_mailer_link + ), + notification: User.human_attribute_name(:newsletter) ), - notification: User.human_attribute_name(:newsletter) - ), attributes: %w[href style]) %> + attributes: %w[href style] + ) %>

diff --git a/app/views/mailer/proposal_notification_digest.html.erb b/app/views/mailer/proposal_notification_digest.html.erb index 3c23f5777..fee371793 100644 --- a/app/views/mailer/proposal_notification_digest.html.erb +++ b/app/views/mailer/proposal_notification_digest.html.erb @@ -43,9 +43,14 @@

- <%= sanitize(link_to(t("mailers.proposal_notification_digest.unfollow"), + <%= sanitize( + link_to( + t("mailers.proposal_notification_digest.unfollow"), proposal_url(notification.notifiable.proposal), - style: css_for_mailer_link), attributes: %w[href style]) %> + style: css_for_mailer_link + ), + attributes: %w[href style] + ) %>

@@ -58,10 +63,14 @@ <% end %>

- <%= sanitize(t("mailers.proposal_notification_digest.unsubscribe_text", - notifications: link_to(t("mailers.config.notifications_link"), - edit_subscriptions_url(token: @token), - style: css_for_mailer_link)), - attributes: %w[href style]) %> + <%= sanitize( + t("mailers.proposal_notification_digest.unsubscribe_text", + notifications: link_to( + t("mailers.config.notifications_link"), + edit_subscriptions_url(token: @token), + style: css_for_mailer_link) + ), + attributes: %w[href style] + ) %>

diff --git a/app/views/mailer/reply.html.erb b/app/views/mailer/reply.html.erb index 20d8fcdc5..c25fcb1bc 100644 --- a/app/views/mailer/reply.html.erb +++ b/app/views/mailer/reply.html.erb @@ -18,13 +18,16 @@

- <%= sanitize(t("mailers.config.unsubscribe_text", - notifications: link_to( - t("mailers.config.notifications_link"), - edit_subscriptions_url(token: @token), - style: css_for_mailer_link + <%= sanitize( + t("mailers.config.unsubscribe_text", + notifications: link_to( + t("mailers.config.notifications_link"), + edit_subscriptions_url(token: @token), + style: css_for_mailer_link + ), + notification: User.human_attribute_name(:email_on_comment_reply) ), - notification: User.human_attribute_name(:email_on_comment_reply) - ), attributes: %w[href style]) %> + attributes: %w[href style] + ) %>