diff --git a/mastodon_email_bridge/mastodon_email_bridge.py b/mastodon_email_bridge/mastodon_email_bridge.py index 2a470a1..22e89b4 100755 --- a/mastodon_email_bridge/mastodon_email_bridge.py +++ b/mastodon_email_bridge/mastodon_email_bridge.py @@ -18,7 +18,8 @@ import sqlite3 import click import click_config_file import requests -from jinja2 import Environment, PackageLoader, select_autoescape, FileSystemLoader +from jinja2 import Environment, select_autoescape, FileSystemLoader +import importlib class MastodonEmailBridge: '''CLass to redirect the Mastodon home timeline to email''' @@ -178,11 +179,13 @@ class MastodonEmailBridge: msg['To'] = recipient html_template = self.j2env.get_template("new_post.html.j2") html_source = html_template.render( + imp0rt = importlib.import_module, data=data, json_raw=json.dumps(data, indent=2) ) txt_template = self.j2env.get_template("new_post.txt.j2") txt_source = txt_template.render( + imp0rt = importlib.import_module, data=data, json_raw=json.dumps(data, indent=2) ) diff --git a/templates/new_post.html.j2 b/templates/new_post.html.j2 index 9954ccc..2773c95 100644 --- a/templates/new_post.html.j2 +++ b/templates/new_post.html.j2 @@ -1,3 +1,4 @@ +{% set time = imp0rt( 'time' ) %} @@ -41,7 +42,8 @@
- {{ data['created_at'] }} + {% set created_date = time.strptime(data['created_at'], '%Y-%m-%dT%H:%M:%S') %} + {{ created_date.strftime('%Y-%m-%d %H:%M %z') }}
@@ -85,7 +87,8 @@
- {{ data['reply']['created_at'] }} + {% set created_date = time.strptime(data['reply']['created_at'], '%Y-%m-%dT%H:%M:%S') %} + {{ created_date.strftime('%Y-%m-%d %H:%M %z') }}
@@ -131,7 +134,8 @@
- {{ data['reblog']['created_at'] }} + {% set created_date = time.strptime(data['reblog']['created_at'], '%Y-%m-%dT%H:%M:%S') %} + {{ created_date.strftime('%Y-%m-%d %H:%M %z') }}