Fix subject template

This commit is contained in:
Antonio J. Delgado 2024-08-30 19:42:41 +03:00
parent 92c40adcd7
commit a6ec889b11
4 changed files with 51 additions and 37 deletions

View file

@ -324,7 +324,7 @@ class MastodonEmailBridge:
@click.option(
'--subjet-template',
'-t',
default='{% if data["in_reply_to_id"] %}FediReply{% else %}FediPost{% endif %} from {{ data["account"]["display_name"] }} ({{ data["account"]["username"] }}){% for tag in data["tags"] %} #{{ tag["name"] }}{% endfor %}',
default='{{ data["account"]["display_name"] }} ({{ data["account"]["username"] }}) {% if data["in_reply_to_id"] %}replied {% else %}posted{% endif %}{% for tag in data["tags"] %} #{{ tag["name"] }}{% endfor %}',
help='Jinja2 template for the subject of the emails.'
)
@click.option('--log-file', '-l', help="File to store all debug messages.")

View file

@ -7,7 +7,7 @@ Homepage = "https://codeberg.org/adelgado/mastodon_email_bridge"
[project]
name = "mastodon_email_bridge"
version = "0.0.8"
version = "0.0.9"
description = "Redirect your Mastodon Home timeline to your email"
readme = "README.md"
authors = [{ name = "Antonio J. Delgado", email = "ad@susurrando.com" }]

View file

@ -1,6 +1,6 @@
[metadata]
name = mastodon_email_bridge
version = 0.0.8
version = 0.0.9
[options]
packages = mastodon_email_bridge

View file

@ -68,38 +68,45 @@
<!-- media -->
{% if data['media_attachments'] %}
{% for media in data['media_attachments'] %}
{% if media['type'] == 'image' %}
{% if media['type'] == 'image' -%}
<IMG SRC="{{ media['preview_url'] }}" ALT="{{ media['description'] }}">
{% elif media['type'] == 'video' or media['type'] == 'gifv' %}
{% elif media['type'] == 'video' or media['type'] == 'gifv' -%}
<video controls height="50%">
<source src="{{ media['url'] }}" type="video/webm" />
<A HREF="{{ media['url'] }}">Download video</A>
</video>
{% elif media['type'] == 'audio' %}
{% elif media['type'] == 'audio' -%}
<audio controls src="{{ media['url'] }}"></audio>
<A HREF="{{ media['url'] }}">Download audio</A>
{% endif %}
{%- endif %}
{% endfor %}
{% endif %}
{% if data['meb_reply_to'] %}
{% for reply in data['meb_reply_to'] %}
<!-- reply -->
<DIV STYLE="margin:5%;">
<DIV>
<A TARGET="_blank" HREF="{{ reply['url'] }}">Reply original page</A>
</DIV>
<!-- creation_date -->
<P STYLE='font-size: 12px;'>
{% set reply_created_date = time.strptime(reply['created_at'], '%Y-%m-%dT%H:%M:%S.%fZ') %}
{{ time.strftime('%Y-%m-%d %H:%M:%S %zUTC', reply_created_date) }}
</P>
<DIV STYLE="margin:1%;">
<!-- reply-account -->
<DIV>
<A HREF="{{ reply['account']['url'] }}" TARGET="_blank"></A>
<IMG ALT="{{ reply['account']['display_name'] }} avatar image" SRC="{{ reply['account']['avatar_static'] }}" STYLE='width:64px;height:64px;margin:1%;float: left;'>
<B>{{ reply['account']['display_name'] }} ({{ reply['account']['username'] }})</B>
<TABLE>
<TR>
<TD>
<A HREF="{{ reply['account']['url'] }}" TARGET="_blank">
<IMG ALT="{{ reply['account']['display_name'] }} avatar image" SRC="{{ reply['account']['avatar_static'] }}" STYLE="width:64px;height:64px;margin:1%;float: left;">
</A>
</DIV>
<!-- reply_creation_date -->
<DIV STYLE='font-size: 12px;'>
{% set created_date = time.strptime(reply['created_at'], '%Y-%m-%dT%H:%M:%S.%fZ') %}
{{ time.strftime('%Y-%m-%d %H:%M:%S %zUTC', created_date) }}
</DIV>
</TD>
<TD>
<A HREF="{{ reply['account']['url'] }}" TARGET="_blank">
<B>{{ reply['account']['display_name'] }} ({{ reply['account']['acct'] }})</B>
</A>
</TD>
</TR>
</TABLE>
<!-- reply_content_bloc -->
<DIV STYLE='font-size: 24px;'>
<!-- reply_spoiler -->
@ -132,22 +139,29 @@
{% endif %}
{% if data['reblog'] %}
<!-- reblog -->
<DIV STYLE="margin:5%;">
<DIV>
<DIV STYLE="margin:1%;">
<!-- reply -->
<A TARGET="_blank" HREF="{{ data['reblog']['url'] }}">Reply original page</A>
</DIV>
<!-- creation_date -->
<P STYLE='font-size: 12px;'>
{% set reblog_created_date = time.strptime(data['reblog']['created_at'], '%Y-%m-%dT%H:%M:%S.%fZ') %}
{{ time.strftime('%Y-%m-%d %H:%M:%S %zUTC', reblog_created_date) }}
</P>
<!-- reblog-account -->
<DIV>
<A HREF="{{ data['reblog']['account']['url'] }}" TARGET="_blank"></A>
<IMG ALT="{{ data['reblog']['account']['display_name'] }} avatar image" SRC="{{ data['reblog']['account']['avatar_static'] }}" STYLE='width:64px;height:64px;margin:1%;float: left;'>
<B>{{ data['reblog']['account']['display_name'] }} ({{ data['reblog']['account']['username'] }})</B>
<TABLE>
<TR>
<TD>
<A HREF="{{ data['reblog']['account']['url'] }}" TARGET="_blank">
<IMG ALT="{{ data['reblog']['account']['display_name'] }} avatar image" SRC="{{ data['reblog']['account']['avatar_static'] }}" STYLE="width:64px;height:64px;margin:1%;float: left;">
</A>
</DIV>
<!-- reblog_creation_date -->
<DIV STYLE='font-size: 12px;'>
{% set created_date = time.strptime(data['reblog']['created_at'], '%Y-%m-%dT%H:%M:%S.%fZ') %}
{{ time.strftime('%Y-%m-%d %H:%M:%S %zUTC', created_date) }}
</DIV>
</TD>
<TD>
<A HREF="{{ data['reblog']['account']['url'] }}" TARGET="_blank">
<B>{{ data['reblog']['account']['display_name'] }} ({{ data['reblog']['account']['acct'] }})</B>
</A>
</TD>
</TR>
</TABLE>
<!-- reblog_content_bloc -->
<DIV STYLE='font-size: 24px;'>
<!-- reblog_spoiler -->