DEV: Breaks up core digest.text.erb for readability (#33637)

Adds partials for digest.text.erb and some comments for clarity.
This commit is contained in:
benj
2025-07-17 11:41:21 -05:00
committed by GitHub
parent bf08512288
commit b6c1ec0264
10 changed files with 61 additions and 54 deletions
@@ -50,6 +50,7 @@
<%= render partial: "user_notifications/digest/footer" %>
<%= digest_custom_html("below_footer") %>
</td>
<!-- Empty cells pad either side of the email content -->
<td></td>
</tr>
</table>
+5 -54
View File
@@ -1,58 +1,9 @@
<%- site_link = raw(@markdown_linker.create(@site_name, '/')) %>
<%= raw(t 'user_notifications.digest.why', site_link: site_link, since: @since) %>
<%= render partial: "user_notifications/digest/header" %>
<%- @counts.each do |count| -%>
<%= count[:value] -%> <%=t count[:label_key] %>
<%- end -%>
<%= render partial: "user_notifications/digest/popular_topics" %>
--------------------------------------------------------------------------------
<%= render partial: "user_notifications/digest/popular_posts" %>
<%- if @popular_topics.present? %>
### <%=t 'user_notifications.digest.popular_topics' %>
<%= render partial: "user_notifications/digest/other_new_topics" %>
<%- @popular_topics.each_with_index do |t,i| %>
<%= raw(@markdown_linker.create(t.title, t.url)) %>
<%- if t.best_post.present? %>
<%= raw(t.best_post.excerpt(1000, strip_links: true, text_entities: true, markdown_images: true)) %>
--------------------------------------------------------------------------------
<%- end %>
<%= digest_custom_text("below_post_#{i+1}") %>
<%- end %>
<%- end %>
<%= digest_custom_text("above_popular_topics") %>
<%- if @popular_posts.present? %>
### <%=t 'user_notifications.digest.popular_posts' %>
<%- @popular_posts.each_with_index do |post,i| %>
<%= post.user.username -%> - <%= raw(@markdown_linker.create(post.topic.title, post.topic.url)) %>
<%= raw(post.excerpt(1000, strip_links: true, text_entities: true, markdown_images: true)) %>
--------------------------------------------------------------------------------
<%- end %>
<%- end %>
<%- if @other_new_for_you.present? %>
**<%=t 'user_notifications.digest.more_new' %>**
<%- @other_new_for_you.each do |t| %>
* <%= raw(@markdown_linker.create(t.title, t.url)) %> - <%= t.posts_count %> - <%- if t.category %>[<%= t.category.name %>]<%- end %>
<%- end -%>
<%- end %>
<%= digest_custom_text("below_popular_topics") %>
<%= raw(@markdown_linker.references) %>
<%= digest_custom_text("above_footer") %>
<%=raw(t :'user_notifications.digest.unsubscribe',
site_link: site_link,
email_preferences_link: raw(@markdown_linker.create(t('user_notifications.digest.your_email_settings'), '/my/preferences/emails')),
unsubscribe_link: raw(@markdown_linker.create(t('user_notifications.digest.click_here'), "/email/unsubscribe/#{@unsubscribe_key}"))) %>
<%= raw(@markdown_linker.references) %>
<%= digest_custom_text("below_footer") %>
<%= render partial: "user_notifications/digest/footer" %>
@@ -1,5 +1,6 @@
<table width="100%" class="digest-header logo-header" dir="<%= rtl? ? 'rtl' : 'ltr' %>" style="border-spacing:0;padding:0;">
<tr>
<!-- Empty cells pad either side of the email content -->
<td></td>
<td width="650" style="padding:0;">
<%= raw(t 'user_notifications.digest.custom.html.header') %>
@@ -1,5 +1,6 @@
<table width="100%" class='summary-footer with-dir'>
<tr>
<!-- Empty cells pad either side of the email content -->
<td></td>
<td width="650" align="center">
<%=raw(t 'user_notifications.digest.unsubscribe',
@@ -0,0 +1,15 @@
<%- site_link = raw(@markdown_linker.create(@site_name, '/')) %>
<%= digest_custom_text("below_popular_topics") %>
<%= raw(@markdown_linker.references) %>
<%= digest_custom_text("above_footer") %>
<%=raw(t :'user_notifications.digest.unsubscribe',
site_link: site_link,
email_preferences_link: raw(@markdown_linker.create(t('user_notifications.digest.your_email_settings'), '/my/preferences/emails')),
unsubscribe_link: raw(@markdown_linker.create(t('user_notifications.digest.click_here'), "/email/unsubscribe/#{@unsubscribe_key}"))) %>
<%= raw(@markdown_linker.references) %>
<%= digest_custom_text("below_footer") %>
@@ -1,5 +1,6 @@
<table width="100%" class="digest-header text-header with-dir" style="background-color:#<%= @header_bgcolor -%>;">
<tr>
<!-- Empty cells pad either side of the email content -->
<td></td>
<td width="650" align="center" style="text-align: center;padding: 20px 0; font-family:Arial,sans-serif;">
<a href="<%= Discourse.base_url %>" style="color:#<%= @header_color -%>;font-size:22px;text-decoration:none;">
@@ -0,0 +1,6 @@
<%- site_link = raw(@markdown_linker.create(@site_name, '/')) %>
<%= raw(t 'user_notifications.digest.why', site_link: site_link, since: @since) %>
<%- @counts.each do |count| -%>
<%= count[:value] -%> <%=t count[:label_key] %>
<%- end -%>
@@ -0,0 +1,7 @@
<%- if @other_new_for_you.present? %>
**<%=t 'user_notifications.digest.more_new' %>**
<%- @other_new_for_you.each do |t| %>
* <%= raw(@markdown_linker.create(t.title, t.url)) %> - <%= t.posts_count %> - <%- if t.category %>[<%= t.category.name %>]<%- end %>
<%- end -%>
<%- end %>
@@ -0,0 +1,10 @@
<%- if @popular_posts.present? %>
### <%=t 'user_notifications.digest.popular_posts' %>
<%- @popular_posts.each_with_index do |post,i| %>
<%= post.user.username -%> - <%= raw(@markdown_linker.create(post.topic.title, post.topic.url)) %>
<%= raw(post.excerpt(1000, strip_links: true, text_entities: true, markdown_images: true)) %>
<%- end %>
<%- end %>
@@ -0,0 +1,14 @@
<%- if @popular_topics.present? %>
### <%=t 'user_notifications.digest.popular_topics' %>
<%- @popular_topics.each_with_index do |t,i| %>
<%= raw(@markdown_linker.create(t.title, t.url)) %>
<%- if t.best_post.present? %>
<%= raw(t.best_post.excerpt(1000, strip_links: true, text_entities: true, markdown_images: true)) %>
<%- end %>
<%= digest_custom_text("below_post_#{i+1}") %>
<%- end %>
<%- end %>
<%= digest_custom_text("above_popular_topics") %>