-
Notifications
You must be signed in to change notification settings - Fork 85
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
Explore using Jinja for templating #376
Merged
Merged
Changes from 39 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
ed107ee
add jinja to setup
H-Shay 338bd5d
update send_email function to render templates with jinja
H-Shay 589c396
change templates to use jinja
H-Shay 8e40335
lints
H-Shay 7c81e22
Add changelog
H-Shay c34bd99
merge with main to update branch
H-Shay a2106c1
add .j2 templates
H-Shay 35eea47
check if jinja templates available and if so use them
H-Shay 3f22e70
rename changelog file, version jinja in setup.py
H-Shay a97b0ae
lints
H-Shay 525be72
requested changes
H-Shay 308f9dc
revoke change to terms.py
H-Shay a721485
add some tests
H-Shay a542201
use jinja environment and autoescape
H-Shay fb7db3c
format jinja templates for autoescape and test
H-Shay 35c2640
fix tests, fix jinja templates
H-Shay a3adf42
lints + update tests
H-Shay dd46fae
reset terms
H-Shay 96580b9
update templates with safe filter
H-Shay c35fd94
move jinja environment creation to startup, add env to sydent
H-Shay 56e0750
update tests
H-Shay 4606fde
lints
H-Shay a5f1416
update template files
H-Shay 808b539
update tests and send_email function
H-Shay f0f25cd
reset terms
H-Shay e75c4d7
update templates
H-Shay ab9ccec
only manually escape old templates
H-Shay 5c8dc2e
update tests
H-Shay e43f0f9
add smaple text for testing
H-Shay 3e3b116
update tests name
H-Shay 6c60693
lints + rename jinja tests
H-Shay 9880e0c
update sydent.py
H-Shay 5379f85
requested changes + lints
H-Shay 611ee4a
update templates
H-Shay 0baa33c
requested changes + add licence
H-Shay 4010fd5
lints
H-Shay a9dcbcf
slight refactor
H-Shay d4d0486
requested change + lints
H-Shay 2da3529
Merge branch 'main' into jinja
H-Shay b0599a7
fix error in redering emails
H-Shay File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add support for using Jinja2 in e-mail templates. Contributed by H-Shay. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"token": "{{ token }}", | ||
"room_alias": "{{ room_alias }}", | ||
"room_avatar_url": "{{ room_avatar_url }}", | ||
"room_name": "{{ room_name }}", | ||
"sender_display_name": "{{ sender_display_name }}", | ||
"sender_avatar_url": "{{ sender_avatar_url }}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<<<{{ token }}>>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
Date: {{ date|safe }} | ||
From: {{ from|safe }} | ||
To: {{ to|safe }} | ||
Message-ID: {{ messageid|safe }} | ||
Subject: {{ subject_header_value|safe }} | ||
MIME-Version: 1.0 | ||
Content-Type: multipart/alternative; | ||
boundary="{{ multipart_boundary|safe }}" | ||
|
||
--{{ multipart_boundary|safe }} | ||
Content-Type: text/plain; charset=UTF-8 | ||
Content-Disposition: inline | ||
|
||
Hi, | ||
|
||
{{ sender_display_name|safe }} {{ bracketed_verified_sender|safe }}has invited you into a room | ||
{{ bracketed_room_name|safe }}on Matrix. To join the conversation, either pick a | ||
Matrix client from https://matrix.org/docs/projects/try-matrix-now.html or use | ||
the single-click link below to join via Element (requires Chrome, Firefox, | ||
Safari, iOS or Android) | ||
|
||
|
||
{{ web_client_location }}/#/room/{{ room_id|urlencode }}?email={{ to|urlencode }}&signurl=https%3A%2F%2Fmatrix.org%2F_matrix%2Fidentity%2Fapi%2Fv1%2Fsign-ed25519%3Ftoken%3D{{ token|urlencode }}%26private_key%3D{{ ephemeral_private_key|urlencode }}&room_name={{ room_name|urlencode }}&room_avatar_url={{ room_avatar_url|urlencode }}&inviter_name={{ sender_display_name|urlencode }}&guest_access_token={{ guest_access_token|urlencode }}&guest_user_id={{ guest_user_id|urlencode }} | ||
|
||
|
||
About Matrix: | ||
|
||
Matrix.org is an open standard for interoperable, decentralised, real-time communication | ||
over IP, supporting group chat, file transfer, voice and video calling, integrations to | ||
other apps, bridges to other communication systems and much more. It can be used to power | ||
Instant Messaging, VoIP/WebRTC signalling, Internet of Things communication - or anywhere | ||
you need a standard HTTP API for publishing and subscribing to data whilst tracking the | ||
conversation history. | ||
|
||
Matrix defines the standard, and provides open source reference implementations of | ||
Matrix-compatible Servers, Clients, Client SDKs and Application Services to help you | ||
create new communication solutions or extend the capabilities and reach of existing ones. | ||
|
||
Thanks, | ||
|
||
Matrix | ||
|
||
--{{ multipart_boundary|safe }} | ||
Content-Type: text/html; charset=UTF-8 | ||
Content-Disposition: inline | ||
|
||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<style type="text/css"> | ||
body { | ||
margin: 0px; | ||
} | ||
|
||
pre, code { | ||
word-break: break-word; | ||
white-space: pre-wrap; | ||
} | ||
|
||
#page { | ||
font-family: 'Open Sans', Helvetica, Arial, Sans-Serif; | ||
font-color: #454545; | ||
font-size: 12pt; | ||
width: 100%%; | ||
padding: 20px; | ||
} | ||
|
||
.low-contrast { | ||
color: #666666 | ||
} | ||
|
||
#inner { | ||
width: 640px; | ||
} | ||
|
||
.header { | ||
width: 100%%; | ||
height: 87px; | ||
color: #454545; | ||
border-bottom: 4px solid #e5e5e5; | ||
} | ||
|
||
.logo { | ||
text-align: right; | ||
margin-left: 20px; | ||
} | ||
|
||
|
||
</style> | ||
</head> | ||
<body> | ||
<table id="page"> | ||
<tr> | ||
<td> </td> | ||
<td id="inner"> | ||
<table class="header"> | ||
<tr> | ||
<td> | ||
</td> | ||
<td class="logo"> | ||
<img src="http://matrix.org/img/matrix-120x51.png" width="120" height="51" alt="[matrix]"/> | ||
</td> | ||
</tr> | ||
</table> | ||
|
||
<p>Hi,</p> | ||
|
||
<p>{{ sender_display_name }} <span class="low-contrast">{{ bracketed_verified_sender }}</span> has invited you into a room {{ bracketed_room_name }} on | ||
Matrix. To join the conversation, either <a href="https://matrix.org/docs/projects/try-matrix-now.html">pick a Matrix client</a> or use the single-click | ||
link below to join via Element (requires | ||
<a href="https://www.google.com/chrome">Chrome</a>, | ||
<a href="https://www.getfirefox.com">Firefox</a> or | ||
<a href="https://www.apple.com/safari">Safari</a> on the web, | ||
or iOS or Android on mobile.)</p> | ||
</p> | ||
|
||
<p> | ||
<a | ||
href="https://app.element.io/#/room/{{ room_id|urlencode }}?email={{ to|urlencode }}&signurl=https%3A%2F%2Fmatrix.org%2F_matrix%2Fidentity%2Fapi%2Fv1%2Fsign-ed25519%3Ftoken%3D{{ token|urlencode }}%26private_key%3D{{ ephemeral_private_key|urlencode }}&room_name={{ room_name|urlencode }}&room_avatar_url={{ room_avatar_url|urlencode }}&inviter_name={{ sender_display_name|urlencode }}&guest_access_token={{ guest_access_token|urlencode }}&guest_user_id={{ guest_user_id|urlencode }}">Join the conversation.</a> | ||
</p> | ||
|
||
<br> | ||
<p>About Matrix:</p> | ||
|
||
<p>Matrix.org is an open standard for interoperable, decentralised, real-time communication | ||
over IP, supporting group chat, file transfer, voice and video calling, integrations to | ||
other apps, bridges to other communication systems and much more. It can be used to power | ||
Instant Messaging, VoIP/WebRTC signalling, Internet of Things communication - or anywhere | ||
you need a standard HTTP API for publishing and subscribing to data whilst tracking the | ||
conversation history.</p> | ||
|
||
<p>Matrix defines the standard, and provides open source reference implementations of | ||
Matrix-compatible Servers, Clients, Client SDKs and Application Services to help you | ||
create new communication solutions or extend the capabilities and reach of existing ones.</p> | ||
|
||
<p>Thanks,</p> | ||
|
||
<p>Matrix</p> | ||
</td> | ||
<td> </td> | ||
</tr> | ||
</table> | ||
</body> | ||
</html> | ||
|
||
--{{ multipart_boundary|safe }}-- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
Date: {{ date|safe }} | ||
From: {{ from|safe }} | ||
To: {{ to|safe }} | ||
Message-ID: {{ messageid|safe }} | ||
Subject: Confirm your email address for Matrix | ||
MIME-Version: 1.0 | ||
Content-Type: multipart/alternative; | ||
boundary="{{ multipart_boundary|safe }}" | ||
|
||
--{{ multipart_boundary|safe }} | ||
Content-Type: text/plain; charset=UTF-8 | ||
Content-Disposition: inline | ||
|
||
Hello, | ||
|
||
We have received a request to use this email address with a matrix.org identity | ||
server. If this was you who made this request, you may use the following link | ||
to complete the verification of your email address: | ||
|
||
{{ link|safe }} | ||
|
||
If your client requires a code, the code is {{ token|safe }} | ||
|
||
If you aren't aware of making such a request, please disregard this email. | ||
|
||
|
||
About Matrix: | ||
|
||
Matrix is an open standard for interoperable, decentralised, real-time communication | ||
over IP. It can be used to power Instant Messaging, VoIP/WebRTC signalling, Internet | ||
of Things communication - or anywhere you need a standard HTTP API for publishing and | ||
subscribing to data whilst tracking the conversation history. | ||
|
||
Matrix defines the standard, and provides open source reference implementations of | ||
Matrix-compatible Servers, Clients, Client SDKs and Application Services to help you | ||
create new communication solutions or extend the capabilities and reach of existing ones. | ||
|
||
--{{ multipart_boundary|safe }} | ||
Content-Type: text/html; charset=UTF-8 | ||
Content-Disposition: inline | ||
|
||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title></title> | ||
<style> | ||
body { | ||
font-family: "Myriad Pro", "Myriad", Helvetica, Arial, sans-serif; | ||
font-size: 12pt; | ||
margin: 0px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<p>Hello,</p> | ||
|
||
<p>We have received a request to use this email address with a matrix.org | ||
identity server. If this was you who made this request, you may use the | ||
following link to complete the verification of your email address:</p> | ||
|
||
<p><a href="{{ link }}">Complete email verification</a></p> | ||
|
||
<p>...or copy this link into your web browser:</p> | ||
|
||
<p>{{ link }}</p> | ||
|
||
<p>If your client requires a code, the code is {{ token }}</p> | ||
|
||
<p>If you aren't aware of making such a request, please disregard this | ||
email.</p> | ||
|
||
<br> | ||
<p>About Matrix:</p> | ||
|
||
<p>Matrix is an open standard for interoperable, decentralised, real-time communication | ||
over IP. It can be used to power Instant Messaging, VoIP/WebRTC signalling, Internet | ||
of Things communication - or anywhere you need a standard HTTP API for publishing and | ||
subscribing to data whilst tracking the conversation history.</p> | ||
|
||
<p>Matrix defines the standard, and provides open source reference implementations of | ||
Matrix-compatible Servers, Clients, Client SDKs and Application Services to help you | ||
create new communication solutions or extend the capabilities and reach of existing ones.</p> | ||
|
||
</body> | ||
</html> | ||
|
||
--{{ multipart_boundary|safe }}-- |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Huh, should this be using
{{ web_client_location }}
here too? (Probably copied from the non-Jinja version though.) We might want to fix that separately.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.
This is indeed from the older version, I will fix in separate PR.