-
Notifications
You must be signed in to change notification settings - Fork 57
Move MJML content to separate template file #955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
5bc39a1
ac8559a
a5e61a7
eb7c76d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| <mjml> | ||
| <mj-body> | ||
| <!-- header --> | ||
| <mj-section padding="0" full-width="" background-color="#c4cdd3"> | ||
| <mj-column padding="0"> | ||
| <mj-image src="https://orcasite.s3.us-west-2.amazonaws.com/email_assets/orcasound_email_header.jpg" alt="Orcasound" align="center" container-background-color="#c4cdd3"></mj-image> | ||
| </mj-column> | ||
| </mj-section> | ||
|
|
||
| <mj-section> | ||
| <mj-column background-color="#404040" padding="18px"> | ||
| <mj-text font-size="18px" color="#F2F2F2" font-family="Helvetica" line-height="150%"> | ||
| {{ meta["message"] }} | ||
| </mj-text> | ||
| </mj-column> | ||
| </mj-section> | ||
|
|
||
| <mj-section> | ||
| <mj-column> | ||
| <mj-image src="https://orcasite.s3.us-west-2.amazonaws.com/email_assets/orcasound_dont_miss.jpg"></mj-image> | ||
|
|
||
| <mj-button href="http://live.orcasound.net/listen/{{ node }}?utm_source=email&utm_medium=email&utm_campaign=notifications" background-color="#0F0F0F" border-radius="31px" font-size="18px" padding="18px" font-weight="bold">LISTEN NOW!</mj-button> | ||
dthaler marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </mj-column> | ||
| </mj-section> | ||
|
|
||
| <mj-section> | ||
| <mj-column background-color="#404040"> | ||
| <mj-text color="#F2F2F2" font-size="16px" align="center" line-height="150%" font-family="Helvetica"> | ||
| If you miss the concert, <br /> watch the <a href="https://orcasound.net/blog?ecm&utm_source=email&utm_medium=email&utm_campaign=notifications" style="color: #007C89;">Orcasound blog</a> for recordings & bioacoustic analysis! | ||
| </mj-text> | ||
| </mj-column> | ||
| </mj-section> | ||
|
|
||
| <!-- footer --> | ||
| <mj-section background-color="#5d5b72" full-width=""> | ||
| <mj-column> | ||
| <mj-text font-weight="bold" font-family="Helvetica" color="#ffffff" align="center" line-height="150%"> | ||
| If you encounter whales at sea, <a href="https://www.bewhalewise.org/" style="font-weight: normal; color: #ffffff">Be Whale Wise</a>.<br /> | ||
| Know the laws and best practices in both the U.S. and Canada. | ||
| </mj-text> | ||
|
|
||
| <mj-divider border-color="#404040" border-width="1px"></mj-divider> | ||
|
|
||
| <mj-text color="#ffffff" font-size="12px" font-style="italic" align="center" line-height="150%"> | ||
| Copyright © 2023 Orcasound, All rights reserved. <br /> | ||
| You are receiving this email because you opted in via our website. | ||
| </mj-text> | ||
| <mj-text color="#ffffff" font-size="12px" align="center" line-height="150%"> | ||
| <strong>Our mailing address is:</strong><br /> | ||
| Orcasound<br /> | ||
| 7044 17th Ave NE<br /> | ||
| Seattle, WA 98115-5739 | ||
| </mj-text> | ||
| {{#if unsubscribe_token }} | ||
| <mj-text color="#ffffff" font-size="12px" align="center" line-height="150%"> | ||
| If you no longer wish to receive these emails,<br /> | ||
| you can <a href="{{ unsubscribe_url }}" style="color: #ffffff;">unsubscribe</a>. | ||
| </mj-text> | ||
| {{/if}} | ||
| </mj-column> | ||
| </mj-section> | ||
|
|
||
| </mj-body> | ||
| </mjml> | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,68 @@ | ||||||||||||||
| <mjml> | ||||||||||||||
| <mj-body> | ||||||||||||||
| <mj-section> | ||||||||||||||
| <mj-column> | ||||||||||||||
|
|
||||||||||||||
| <mj-text font-size="20px" font-family="helvetica"> | ||||||||||||||
| A new detection has been submitted at {{ node_name }} ({{ node }})! | ||||||||||||||
| </mj-text> | ||||||||||||||
|
|
||||||||||||||
| <mj-text font-size="20px" font-family="helvetica"> | ||||||||||||||
| Description: {{#if meta["description"]}}{{ meta["description"] }}{{else}}(no description){{/if}} | ||||||||||||||
| </mj-text> | ||||||||||||||
| {{#if meta["listener_count"] }} | ||||||||||||||
| <mj-text font-size="20px" font-family="helvetica"> | ||||||||||||||
| Listeners: {{ meta["listener_count"] }} | ||||||||||||||
| </mj-text> | ||||||||||||||
| {{/if}} | ||||||||||||||
| {{#if meta["candidate_id"] }} | ||||||||||||||
| <mj-text font-size="20px" font-family="helvetica"> | ||||||||||||||
| Review here: <a href="https://live.orcasound.net/reports/{{meta["candidate_id"]}}?utm_source=email&utm_medium=email&utm_campaign=notifications">{{ meta["candidate_id"] }}</a> | ||||||||||||||
| </mj-text> | ||||||||||||||
| {{/if}} | ||||||||||||||
| {{#if node && meta["start_time"] && meta["category"] }} | ||||||||||||||
| <mj-text font-size="20px" font-family="helvetica"> | ||||||||||||||
| <a href="https://live.orcasound.net/bouts/new/{{ node }}?time={{ meta["start_time"] }}&category={{ meta["category"] }}&utm_source=email&utm_medium=email&utm_campaign=notifications">Start a new bout</a> | ||||||||||||||
| </mj-text> | ||||||||||||||
| {{/if}} | ||||||||||||||
|
|
||||||||||||||
| {{#if notifications_since_count > 0}} | ||||||||||||||
| <mj-text font-size="20px" font-family="helvetica"> | ||||||||||||||
| There have been {{ notifications_since_count }} other detections since the last notification. | ||||||||||||||
| </mj-text> | ||||||||||||||
| <mj-table> | ||||||||||||||
| <tr style="border-bottom:1px solid #ecedee;text-align:left;padding:15px 0;"> | ||||||||||||||
| <th style="padding: 0 5px 0 0;">Feed</th> | ||||||||||||||
| <th style="padding: 0 15px; text-align: right;">#</th> | ||||||||||||||
| <th style="padding: 0 0 0 15px;">Description</th> | ||||||||||||||
| <th style="padding: 0 0 0 15px;">Action</th> | ||||||||||||||
| </tr> | ||||||||||||||
| {{#each notifications_since as |notif_meta|}} | ||||||||||||||
| <tr> | ||||||||||||||
| <td style="padding: 0 5px 0 0;white-space:nowrap;">{{ notif_meta["node"] }}</td> | ||||||||||||||
| <td style="padding: 0 15px;text-align:right;">{{ notif_meta["listener_count"] }}</td> | ||||||||||||||
| <td style="padding: 0 0 0 15px;">{{ notif_meta["description"] }}</td> | ||||||||||||||
| <td style="padding: 0 0 0 15px;"> | ||||||||||||||
| {{#if notif_meta["candidate_id"] }} | ||||||||||||||
| <a href="https://live.orcasound.net/reports/{{meta["candidate_id"]}}?utm_source=email&utm_medium=email&utm_campaign=notifications">Review</a> | ||||||||||||||
|
||||||||||||||
| <a href="https://live.orcasound.net/reports/{{meta["candidate_id"]}}?utm_source=email&utm_medium=email&utm_campaign=notifications">Review</a> | |
| <a href="https://live.orcasound.net/reports/{{notif_meta["candidate_id"]}}?utm_source=email&utm_medium=email&utm_campaign=notifications">Review</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong variable in Review link inside the loop.
Links will point to the outer meta id, not the per‑row notif_meta id.
- <a href="https://live.orcasound.net/reports/{{meta["candidate_id"]}}?utm_source=email&utm_medium=email&utm_campaign=notifications">Review</a>
+ <a href="https://live.orcasound.net/reports/{{notif_meta["candidate_id"]}}?utm_source=email&utm_medium=email&utm_campaign=notifications">Review</a>📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| {{#if notif_meta["candidate_id"] }} | |
| <a href="https://live.orcasound.net/reports/{{meta["candidate_id"]}}?utm_source=email&utm_medium=email&utm_campaign=notifications">Review</a> | |
| {{/if}} | |
| {{#if notif_meta["candidate_id"] }} | |
| <a href="https://live.orcasound.net/reports/{{notif_meta["candidate_id"]}}?utm_source=email&utm_medium=email&utm_campaign=notifications">Review</a> | |
| {{/if}} |
🤖 Prompt for AI Agents
In server/lib/orcasite/notifications/templates/new_detection.mjml.eex around
lines 46 to 48, the Review link uses the outer meta["candidate_id"] instead of
the per-row notif_meta["candidate_id"]; change the URL interpolation to use
notif_meta["candidate_id"] (so the href becomes
.../reports/{{notif_meta["candidate_id"]}}?...), ensuring it matches the
existing {{#if notif_meta["candidate_id"] }} guard and preserves the utm query
params and quoting style.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| defmodule Orcasite.Notifications.EmailTemplateTest do | ||
| use ExUnit.Case | ||
|
|
||
| describe "email templates" do | ||
| test "new_detection template exists and is readable" do | ||
| template_path = Path.expand("lib/orcasite/notifications/templates/new_detection.mjml.eex") | ||
| assert File.exists?(template_path), "new_detection template file should exist" | ||
|
|
||
| {:ok, content} = File.read(template_path) | ||
| assert String.length(content) > 0, "template should not be empty" | ||
| assert String.contains?(content, "<mjml>"), "template should contain MJML structure" | ||
| assert String.contains?(content, "A new detection has been submitted"), "template should contain expected content" | ||
| end | ||
|
|
||
| test "confirmed_candidate template exists and is readable" do | ||
| template_path = Path.expand("lib/orcasite/notifications/templates/confirmed_candidate.mjml.eex") | ||
| assert File.exists?(template_path), "confirmed_candidate template file should exist" | ||
|
|
||
| {:ok, content} = File.read(template_path) | ||
| assert String.length(content) > 0, "template should not be empty" | ||
| assert String.contains?(content, "<mjml>"), "template should contain MJML structure" | ||
| assert String.contains?(content, "LISTEN NOW!"), "template should contain expected content" | ||
| end | ||
|
|
||
| test "templates contain required variables" do | ||
| # Test new_detection template variables | ||
| {:ok, new_detection_content} = File.read(Path.expand("lib/orcasite/notifications/templates/new_detection.mjml.eex")) | ||
| assert String.contains?(new_detection_content, "{{ node_name }}"), "should contain node_name variable" | ||
| assert String.contains?(new_detection_content, "{{ node }}"), "should contain node variable" | ||
| assert String.contains?(new_detection_content, "meta[\"description\"]"), "should contain description variable" | ||
| assert String.contains?(new_detection_content, "{{unsubscribe_url}}"), "should contain unsubscribe_url variable" | ||
|
|
||
| # Test confirmed_candidate template variables | ||
| {:ok, confirmed_candidate_content} = File.read(Path.expand("lib/orcasite/notifications/templates/confirmed_candidate.mjml.eex")) | ||
| assert String.contains?(confirmed_candidate_content, "{{ node }}"), "should contain node variable" | ||
| assert String.contains?(confirmed_candidate_content, "meta[\"message\"]"), "should contain message variable" | ||
| assert String.contains?(confirmed_candidate_content, "{{ unsubscribe_url }}"), "should contain unsubscribe_url variable" | ||
| end | ||
| end | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make template path robust to CWD/release layout.
Hardcoding "lib/..." depends on process CWD. Resolve relative to this module instead.
📝 Committable suggestion
🤖 Prompt for AI Agents