Skip to content

Commit

Permalink
Merge branch 'main' of github.com:acannistra/avymail
Browse files Browse the repository at this point in the history
  • Loading branch information
acannistra committed Oct 10, 2024
2 parents 0f2bad6 + fdf986d commit 6052bcd
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
**/*.html
!mailtemplate.html
!web/*.html
**/*.whl
# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
40 changes: 36 additions & 4 deletions mailtemplate.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Simple Transactional Email</title>
<title>
The most recent avalanche forecast for {{forecast_zone[0]['name']}}.
</title>
<style>
@media only screen and (max-width: 620px) {
table.body h1 {
Expand Down Expand Up @@ -53,6 +55,13 @@
max-width: 100% !important;
width: auto !important;
}

.banner {
background-color: #fff9c4;
text-align: center;
padding: 10px;
font-size: 18px;
}
}

@media all {
Expand Down Expand Up @@ -192,6 +201,29 @@
width="100%"
>
<!-- START MAIN CONTENT AREA -->
<tr>
<td
class="banner"
style="
font-family: sans-serif;
font-size: 14px;
vertical-align: top;
box-sizing: border-box;
padding: 20px;
background-color: #fff9c4;
text-align: center;
font-size: 18px;
"
valign="top"
>
<b>Welcome 2024-2025 Season!</b>
<p>
Want to change your email preferences? please visit
<a href="https://avy.email">this page</a>.
</p>
</td>
</tr>

<tr>
<td
class="wrapper"
Expand Down Expand Up @@ -396,7 +428,7 @@
{%- endif %}
</tr>
</table>
{%- endif %}
{%- endif %} {% if bottom_line %}
<p
style="
font-family: sans-serif;
Expand All @@ -409,8 +441,8 @@
Bottom Line
</p>

{{bottom_line}} {% if forecast_avalanche_problems|length
> 0 %}
{{bottom_line}} {%- endif %} {% if
forecast_avalanche_problems|length> 0 %}
<p
style="
font-family: sans-serif;
Expand Down
17 changes: 13 additions & 4 deletions send-avymail.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import requests
import json
from os import environ
from subprocess import check_output
from subprocess import check_output, CalledProcessError
from typing import Optional

import jinja2
Expand All @@ -27,9 +27,13 @@
TEMPLATE_FILE = environ.get("EMAIL_TEMPLATE", "mailtemplate.html")
A3_API = avalanche.AvalancheAPI()
RECIPIENTS_DB = s3records.S3Records(S3_STORE)
CODE_VERSION_HASH = (
check_output(["git", "rev-parse", "--short", "HEAD"]).decode("ascii").strip()
)
CODE_VERSION_HASH = ""
try:
CODE_VERSION_HASH = (
check_output(["git", "rev-parse", "--short", "HEAD"]).decode("ascii").strip()
)
except CalledProcessError:
CODE_VERSION_HASH = environ.get("SHORT_SHA", "")


def load_email_config() -> dict:
Expand Down Expand Up @@ -237,3 +241,8 @@ def main(*args, **kwargs):

if __name__ == "__main__":
main()


def lambda_handler(event, context):
main()
return {"statusCode": 200, "body": "ok"}
15 changes: 12 additions & 3 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,13 @@
<span style="font-weight: bolder"
>Avalanche Forecast E-mails</span
>
<small style="float: right"
><em
><a href="https://avy.email/unsubscribe.html"
>Unsubscribe</a
></em
></small
>
</p>
<p
style="
Expand Down Expand Up @@ -383,8 +390,9 @@
></span
>
made this. This service is not affiliated with or endorsed
by any avalanche forecasting center. This will always be a free service,
but you can <span
by any avalanche forecasting center. This will always be a
free service, but you can
<span
style="
text-decoration: underline;
color: #999999;
Expand All @@ -394,7 +402,8 @@
><a href="https://www.buymeacoffee.com/tonycannistra"
>buy me a coffee</a
></span
> if you like.
>
if you like.
</span>
</td>
</tr>
Expand Down

0 comments on commit 6052bcd

Please sign in to comment.