Skip to content

Commit

Permalink
Add a human-friendly HTML template for mentions
Browse files Browse the repository at this point in the history
  • Loading branch information
acelaya committed Feb 18, 2025
1 parent 5ba13e3 commit 372f9f8
Show file tree
Hide file tree
Showing 7 changed files with 763 additions and 57 deletions.
6 changes: 4 additions & 2 deletions h/emails/mention_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
from pyramid.request import Request

from h import links
from h.emails.util import get_user_url
from h.notification.mention import MentionNotification
from h.services.email import EmailTag


def generate(request: Request, notification: MentionNotification):
selectors = notification.annotation.target[0].get("selector", [])
quote = next((s for s in selectors if s.get("type") == "TextQuoteSelector"), None)
context = {
"user_url": get_user_url(notification.mentioning_user, request),
"username": notification.mentioning_user.username,
"user_display_name": notification.mentioning_user.display_name
or notification.mentioning_user.username,
"annotation_url": links.incontext_link(request, notification.annotation)
Expand All @@ -18,6 +19,7 @@ def generate(request: Request, notification: MentionNotification):
or notification.annotation.target_uri,
"document_url": notification.annotation.target_uri,
"annotation": notification.annotation,
"annotation_quote": quote.get('exact') if quote else None,
}

subject = f"{context['user_display_name']} has mentioned you in an annotation"
Expand Down
Binary file added h/static/images/hypothesis-wordmark-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions h/templates/admin/mailer.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</div>
{% endif %}

<div class="card">
<div class="card mb-3">
<div class="card-header">
<h3 class="card-title mb-0">Send a test email</h3>
</div>
Expand All @@ -28,13 +28,13 @@
</div>
</div>

<div class="card mt-3">
<div class="card mb-3">
<div class="card-header">
<h3 class="card-title mb-0">Preview the Mentions Email Template</h3>
</div>
<iframe
class="card-body p-0"
style="height: 20em; border: none;"
style="height: 40em; border: none;"
src="{{ request.route_url("admin.mailer.preview.mention_notification") }}"
>
</iframe>
Expand Down
Loading

0 comments on commit 372f9f8

Please sign in to comment.