Skip to content

Commit

Permalink
Improve story info in emails
Browse files Browse the repository at this point in the history
  • Loading branch information
andreymal committed Jul 3, 2023
1 parent c12e461 commit bc88126
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 36 deletions.
21 changes: 5 additions & 16 deletions mini_fiction/templates/email/author_story.html
Expand Up @@ -4,20 +4,9 @@
{% block body %}
Опубликован новый рассказ:<br/>
<br/>
{{ macro.storylink(story.id, story.title) }}<br/>
<span style="font-size: 12px; color: #999;">
{{- ngettext("%(num)d word", "%(num)d words", story.words) }} от {% for author in story.authors %}
{%- if loop.first -%}
{{- macro.userlink(author.id, author.username) -}}
{%- if loop.length > 1 %} (в соавторстве с {% endif -%}
{%- endif -%}
{%- if not loop.first -%}
{{- macro.userlink(author.id, author.username) -}}
{%- if loop.revindex0 == 1 %} и {% endif %}{% if loop.revindex0 > 1 %}, {% endif -%}
{%- if loop.last and loop.length > 1 %}){% endif -%}
{%- endif -%}
{% endfor -%}
</span><br/><br/>

<span>{{ story.summary_as_html|striptags }}</span>
{{ macro.story_info_html(story) }}
{% if story.notes %}
<p>Заметки к рассказу:</p>
{{ story.notes_as_html }}
{% endif %}
{% endblock %}
21 changes: 7 additions & 14 deletions mini_fiction/templates/email/author_story.txt
@@ -1,24 +1,17 @@
{%- extends 'email/base.txt' -%}
{%- import 'email/macro.html' as macro with context -%}

{%- block content -%}
{%- autoescape false -%}
На сайте {{ url_for('index.index', _external=True) }} опубликован новый рассказ:

«{{ story.title }}»
{{ url_for('story.view', pk=story.id, _external=True) }}
{{ macro.story_info_plain(story) }}

{{ ngettext("%(num)d word", "%(num)d words", story.words) }} от {% for author in story.authors -%}
{%- if loop.first -%}
{{- author.username -}}
{%- if loop.length > 1 %} (в соавторстве с {% endif -%}
{%- endif -%}
{%- if not loop.first -%}
{{- author.username -}}
{%- if loop.revindex0 == 1 %} и {% endif %}{% if loop.revindex0 > 1 %}, {% endif -%}
{%- if loop.last and loop.length > 1 %}){% endif -%}
{%- endif -%}
{%- endfor %}
{%- if story.notes %}

{{ story.summary_as_html|striptags }}
Заметки к рассказу:

{{ story.notes|striptags }}
{%- endif %}
{%- endautoescape -%}
{%- endblock -%}
29 changes: 26 additions & 3 deletions mini_fiction/templates/email/macro.html
Expand Up @@ -30,7 +30,18 @@

{% macro story_info_plain(story) -%}
{%- autoescape false -%}
«{{ story.title }}» ({{ ngettext("%(num)d word", "%(num)d words", story.words) }})
«{{ story.title }}»
{{ ngettext("%(num)d word", "%(num)d words", story.words) }} {{ pgettext('story_by', 'by') }} {% for author in story.authors -%}
{{- author.username -}}
{%- if loop.first %}
{%- if not loop.last %} ({{ pgettext('story_in_collaboration_with', 'in collaboration with') }} {% endif -%}
{% else %}
{%- if loop.revindex0 > 1 %}, {% endif -%}
{%- if loop.revindex0 == 1 %}{{ pgettext('story_in_collaboration_with', ' and') }} {% endif -%}
{%- if loop.last %}){% endif -%}
{%- endif -%}
{% endfor %}

{{ url_for('story.view', pk=story.id, _external=True) }}

{{ story.summary|striptags }}
Expand All @@ -56,14 +67,26 @@ <h3 style="font-family: 'Trebuchet MS', Arial, sans-serif; font-weight: 400; fon
</h3>

<p style="color: #999;">
{%- for tag in story.prepared_tags.primary -%}
{%- for tag in story.prepared_tags.primary -%}
<a
style="margin: 0 4px 2px 0; padding: 2px 7px; color: #fff; background-color: #999; display: inline-block; line-height: 16px; text-decoration: none; border-radius: 5px;"
href="{{ url_for('tags.tag_index', tag_name=tag.iname, _external=True) }}">
{{- tag.name -}}
</a>
{% endfor -%}
{{ ngettext("%(num)d word", "%(num)d words", story.words) }}
<br/>
{{ ngettext("%(num)d word", "%(num)d words", story.words) }} {{ pgettext('story_by', 'by') }} {% for author in story.authors -%}
<a href="{{ url_for('author.info', user_id=author.id, _external=True) }}" style="color: #999; font-weight: 700;">
{{- author.username -}}
</a>
{%- if loop.first %}
{%- if not loop.last %} ({{ pgettext('story_in_collaboration_with', 'in collaboration with') }} {% endif -%}
{% else %}
{%- if loop.revindex0 > 1 %}, {% endif -%}
{%- if loop.revindex0 == 1 %}{{ pgettext('story_in_collaboration_with', ' and') }} {% endif -%}
{%- if loop.last %}){% endif -%}
{%- endif -%}
{% endfor -%}
</p>

<p>{{ story.summary|striptags }}</p>
Expand Down
9 changes: 8 additions & 1 deletion mini_fiction/templates/email/story_publish_noappr.html
Expand Up @@ -2,5 +2,12 @@
{% import 'email/macro.html' as macro with context %}

{% block body %}
Пользователь {{ macro.userlink(author.id, author.username) }} опубликовал рассказ {{ macro.storylink(story.id, story.title) }} без премодерации.
Пользователь {{ macro.userlink(author.id, author.username) }} опубликовал рассказ без премодерации:
<br>
<br>
{{ macro.story_info_html(story) }}
{% if story.notes %}
<p>Заметки к рассказу:</p>
{{ story.notes_as_html }}
{% endif %}
{% endblock %}
12 changes: 10 additions & 2 deletions mini_fiction/templates/email/story_publish_noappr.txt
@@ -1,9 +1,17 @@
{%- extends 'email/base.txt' -%}
{%- import 'email/macro.html' as macro with context -%}

{%- block content -%}
{%- autoescape false -%}
Пользователь {{ author.username }} на сайте {{ url_for('index.index', _external=True) }} опубликовал рассказ «{{ story.title }}» без премодерации.
Пользователь {{ author.username }} на сайте {{ url_for('index.index', _external=True) }} опубликовал рассказ без премодерации:

{{ url_for('story.view', pk=story.id, _external=True) }}
{{ macro.story_info_plain(story) }}

{%- if story.notes %}

Заметки к рассказу:

{{ story.notes|striptags }}
{%- endif %}
{%- endautoescape -%}
{%- endblock -%}

0 comments on commit bc88126

Please sign in to comment.