Skip to content

Commit

Permalink
More readable email format (#12)
Browse files Browse the repository at this point in the history
* More readable email format

* Fixed unit test
  • Loading branch information
marblestation authored Jul 5, 2020
1 parent d69736d commit ad41695
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 55 deletions.
34 changes: 20 additions & 14 deletions myadsp/templates/email.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,42 +45,48 @@
</style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%" id="bodyTable" style="background-color: #E0E0E0;;">
<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%" id="bodyTable" style="background-color: #FFFFFF;">
<tr>
<td align="center" valign="top">
<table border="0" cellpadding="10" cellspacing="0" width="100%" style="max-width: 800px;" id="emailContainer" >
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 1024px;" id="emailContainer" >
<tr>
<td align="center" valign="top" style="font-family:Helvetica;">
<table border="0" cellpadding="20" cellspacing="0" width="100%" id="emailBody" style="background-color: #ffffff; border: 1px solid #BBBBBB;border-collapse: collapse !important;">
<td align="center" valign="top" style="font-family:Arial;">
<table border="0" cellpadding="0" cellspacing="0" width="100%" id="emailBody" style="">
<tr>
<td align="center" valign="top" background="https://ui.adsabs.harvard.edu/styles/img/background.jpg" style="width:100%; background-color: #150E35" >
<img src="https://ui.adsabs.harvard.edu/styles/img/ads_logo.png" alt="Astrophysics Data System" style="width: 70%; color: #ffffff; font-size: 34px; font-family: Helvetica;"/>
<td align="center" valign="center" background="https://ui.adsabs.harvard.edu/styles/img/background.jpg" style="width:100%; background-color: #150E35; padding: 10px;" >
<p><img src="https://ui.adsabs.harvard.edu/styles/img/ads_logo.png" alt="Astrophysics Data System" style="width: 50%; color: #ffffff; font-size: 34px; font-family: Arial;"/></p>
</td>
</tr>
<tr>
<td align="center" valign="top" style="width:100%; background-color: #ffffff;">
<h2 style="margin-top: 0;margin-right: 0;margin-bottom: 10px;margin-left: 0;"> myADS Personal Notification Service </h2>
<h3 style="margin-top: 0;margin-right: 0;margin-bottom: 10px;margin-left: 0;"> {{ frequency.capitalize() }} email ({{ date }}) </h3>
<td align="center" valign="top" style="width:100%;">
&nbsp;
</td>
</tr>
<tr>
<td align="center" valign="top" style="width:100%;">
<h3 style="margin-top: 0;margin-right: 0;margin-bottom: 10px;margin-left: 0;">myADS - {{ frequency.capitalize() }} email ({{ date }})</h3>
</td>
</tr>
<tr>
<td align="center" style="width:100%; font-size: 14px; font-family:Arial">
{% block payload %} {% endblock payload %}
</td>
</tr>
<tr>
<td valign="top" align="center" class="footerContent" style="width:100%; font-size: 14px; font-family:Helvetica; color: #606060; text-align: center;">
<a href="https://ui.adsabs.harvard.edu/" style="color: #606060;">Search ADS</a>&nbsp;&nbsp;&nbsp;<a href="https://ui.adsabs.harvard.edu/user/settings/myads" style="color: #606060;">myADS settings</a>&nbsp;
<td valign="top" align="center" class="footerContent" style="width:100%; font-size: 14px; font-family:Arial; color: #606060; text-align: center; padding: 10px">
<a href="https://ui.adsabs.harvard.edu/user/settings/myads" style="text-decoration: underline; color: #606060;">myADS notification settings</a>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center" valign="top">
<table border="0" cellpadding="20" cellspacing="0" width="100%" id="emailFooter" style="color: #999999; font-size: 12px; text-align: center; font-family: Helvetica;">
<table border="0" cellpadding="10" cellspacing="0" width="100%" id="emailFooter" style="color: #999999; font-size: 12px; text-align: center; font-family: Arial;">
<tr>
<td align="center" valign="top">
<p> This message was sent to {{ email_address }}. </p>
<p> &copy; SAO/NASA <a href="https://ui.adsabs.harvard.edu">Astrophysics Data System</a> <br> 60 Garden Street <br> Cambridge, MA, USA</p>
<p> &copy; SAO/NASA <a href="https://ui.adsabs.harvard.edu" style="text-decoration: underline; color: #999999">Astrophysics Data System</a> <br> 60 Garden Street <br> Cambridge, MA, USA</p>
</td>
</tr>
</table>
Expand All @@ -91,4 +97,4 @@ <h3 style="margin-top: 0;margin-right: 0;margin-bottom: 10px;margin-left: 0;"> {
</tr>
</table>
</body>
</html>
</html>
48 changes: 37 additions & 11 deletions myadsp/templates/one_col.html
Original file line number Diff line number Diff line change
@@ -1,31 +1,57 @@
{% extends "email.html" %}
{% block payload %}
<table border="0" cellpadding="0" cellspacing="0" width="100%" id="templateColumns" style="background-color: #FFFFFF; border-top: 1px solid #FFFFFF;border-bottom: 1px solid #CCCCCC; border: 1px solid #BBBBBB;border-collapse: collapse !important;">
<table border="0" cellpadding="0" cellspacing="0" width="100%" id="templateColumns" style="max-width: 512px;">
<tr>
<td align="center" valign="top" width="100%" class="templateColumnContainer">
<table border="0" cellpadding="10" cellspacing="0" width="100%">
<tr>
<td valign="top" class="templateColumnContainer">
<td align="justify" valign="top" class="templateColumnContainer">
{% for p in payload %}
<h3><a href="{{ p.query_url.format(p.qtype, p.id) }}" title="{{ p.query }}" style="color: #000000; font-weight: bold;">{{ p.name }}</a></h3>
<h3><a href="{{ p.query_url.format(p.qtype, p.id) }}" title="{{ p.query }}" style="text-decoration: underline; color: #000000; font-weight: bold;">{{ p.name }}</a></h3>
{% if p.results|length > 0 %}
<table border="0" cellpadding="0" cellspacing="0" width="100%">
{% for r in p.results %}
{% if (r.bibstem[0] == 'arXiv') and ('arxiv_id' in r) %}
<p style="margin: 0;margin-block-start: 0;margin-block-end: 0;line-height: 19.5px;"><b><a href="{{ abs_url.format(r.bibcode, p.qtype, p.id, loop.index) }}" style="color: #5081E9;font-weight: normal;text-decoration: underline;">{{ _get_title(r) }}</a></b></p>
<p style="text-indent: 20px;margin: 0;margin-block-start: 0;margin-block-end: 0;line-height: 19.5px;">{{ _get_first_author_formatted(r, num_authors=3) }} (<a href="{{ arxiv_url.format(r.bibcode, p.qtype, p.id, loop.index) }}" style="color: #5081E9;font-weight: normal;text-decoration: underline;">{{ r.arxiv_id }}</a>)</p>
{% else %}
<p style="margin: 0;margin-block-start: 0;margin-block-end: 0;line-height: 19.5px;"><b><a href="{{ abs_url.format(r.bibcode, p.qtype, p.id, loop.index) }}" style="color: #5081E9;font-weight: normal;text-decoration: underline;">{{ _get_title(r) }}</a></b></p>
<p style="text-indent: 20px;margin: 0;margin-block-start: 0;margin-block-end: 0;line-height: 19.5px;">{{ _get_first_author_formatted(r, num_authors=3) }} ({{ r.bibcode }})</p>
{% endif %}
<tr>
<td align="left" valign="top">
</td>
<td align="left" valign="top">
{% if (r.bibstem[0] == 'arXiv') and ('arxiv_id' in r) %}
<p style="margin: 0;margin-block-start: 0;margin-block-end: 0;line-height: 19.5px;">
<a href="{{ arxiv_url.format(r.bibcode, p.qtype, p.id, loop.index) }}" style="color: #999999;font-weight: normal;text-decoration: none;">{{ r.bibcode }}</a>
</p>
{% else %}
<p style="margin: 0;margin-block-start: 0;margin-block-end: 0;line-height: 19.5px; color: #999999;">
{{ r.bibcode }}
</p>
{% endif %}
</td>
</tr>
<tr>
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<p style="margin: 0;margin-block-start: 0;margin-block-end: 0;line-height: 19.5px;"><a href="{{ abs_url.format(r.bibcode, p.qtype, p.id, loop.index) }}" style="text-decoration: none; color: #5081E9;font-weight: normal;">{{ _get_title(r) }}</a></p>
</td>
</tr>
<tr>
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<p style="margin: 0;margin-block-start: 0;margin-block-end: 0;line-height: 19.5px;">{{ _get_first_author_formatted(r, num_authors=1) }}</p>
<p style="margin: 0;margin-block-start: 0;margin-block-end: 0;line-height: 9.5px;">&nbsp;</p>
</td>
</tr>
{% endfor %}
</table>
{% else %}
<p>No new articles found</p>
{% endif %}
<p style="margin: 0;margin-block-start: 0;margin-block-end: 0;line-height: 19.5px;">&nbsp;</p>
{% endfor %}
</td>
</tr>
</table>
</td>
</tr>
</table>
{% endblock payload %}
{% endblock payload %}
Loading

0 comments on commit ad41695

Please sign in to comment.