diff --git a/bookwyrm/templates/snippets/stars.html b/bookwyrm/templates/snippets/stars.html index 2b40a9e3c..ac049f254 100644 --- a/bookwyrm/templates/snippets/stars.html +++ b/bookwyrm/templates/snippets/stars.html @@ -1,7 +1,7 @@ {% spaceless %} {% load i18n %} -

+ {% if rating %} {% blocktranslate trimmed with rating=rating|floatformat count counter=rating|length %} @@ -23,5 +23,5 @@ aria-hidden="true" > {% endfor %} -

+ {% endspaceless %} diff --git a/bookwyrm/templates/snippets/status/book_preview.html b/bookwyrm/templates/snippets/status/book_preview.html deleted file mode 100644 index 920b9f538..000000000 --- a/bookwyrm/templates/snippets/status/book_preview.html +++ /dev/null @@ -1,14 +0,0 @@ -{% load bookwyrm_tags %} -
-
-
- {% include 'snippets/book_cover.html' with book=book %} - {% include 'snippets/stars.html' with rating=book|rating:request.user %} - {% include 'snippets/shelve_button/shelve_button.html' with book=book %} -
-
-
-

{% include 'snippets/book_titleby.html' with book=book %}

- {% include 'snippets/trimmed_text.html' with full=book|book_description %} -
-
diff --git a/bookwyrm/templates/snippets/status/content_status.html b/bookwyrm/templates/snippets/status/content_status.html new file mode 100644 index 000000000..5225f04e1 --- /dev/null +++ b/bookwyrm/templates/snippets/status/content_status.html @@ -0,0 +1,128 @@ +{% load bookwyrm_tags %} +{% load i18n %} + +{% with status_type=status.status_type %} +
+ +
+ {% if not hide_book %} + {% with book=status.book|default:status.mention_books.first %} + {% if book %} +
+ {% include 'snippets/book_cover.html' with book=book %} + {% include 'snippets/stars.html' with rating=book|rating:request.user %} + {% include 'snippets/shelve_button/shelve_button.html' with book=book %} +
+ {% endif %} + {% endwith %} + {% endif %} + +
+ {% if status_type == 'Review' %} +
+

+ {{ status.name|escape }} +

+ +

+ + {% include 'snippets/stars.html' with rating=status.rating %} +

+
+ {% endif %} + + {% if status.content_warning %} +
+

{{ status.content_warning }}

+ + {% trans "Show more" as button_text %} + + {% with text=button_text class="is-small" controls_text="show-status-cw" controls_uid=status.id %} + {% include 'snippets/toggle/open_button.html' %} + {% endwith %} +
+ {% endif %} + + +
+
+
+ +{% endwith %} + diff --git a/bookwyrm/templates/snippets/status/generated_status.html b/bookwyrm/templates/snippets/status/generated_status.html new file mode 100644 index 000000000..f3bbae44b --- /dev/null +++ b/bookwyrm/templates/snippets/status/generated_status.html @@ -0,0 +1,23 @@ +{% spaceless %} + +{% load bookwyrm_tags %} +{% load i18n %} + +{% if not hide_book %} +{% with book=status.book|default:status.mention_books.first %} +
+
+
+ {% include 'snippets/book_cover.html' with book=book size="small" %} +
+
+
+

{% include 'snippets/book_titleby.html' with book=book %}

+

{{ book|book_description|default:""|truncatewords_html:20 }}

+ {% include 'snippets/shelve_button/shelve_button.html' with book=book %} +
+
+{% endwith %} +{% endif %} + +{% endspaceless %} diff --git a/bookwyrm/templates/snippets/status/layout.html b/bookwyrm/templates/snippets/status/layout.html new file mode 100644 index 000000000..00e15857e --- /dev/null +++ b/bookwyrm/templates/snippets/status/layout.html @@ -0,0 +1,85 @@ +{% extends 'components/card.html' %} +{% load i18n %} +{% load bookwyrm_tags %} +{% load humanize %} + +{% block card-header %} +

+ {% include 'snippets/status/status_header.html' with status=status %} +

+{% endblock %} + +{% block card-content %}{% endblock %} + +{% block card-footer %} + + + + + +{% if not moderation_mode %} + +{% endif %} +{% endblock %} + + +{% block card-bonus %} +{% if request.user.is_authenticated and not moderation_mode %} +{% with status.id|uuid as uuid %} + +{% endwith %} +{% endif %} +{% endblock %} diff --git a/bookwyrm/templates/snippets/status/status_body.html b/bookwyrm/templates/snippets/status/status_body.html index 0eff4ea93..2c8a0e045 100644 --- a/bookwyrm/templates/snippets/status/status_body.html +++ b/bookwyrm/templates/snippets/status/status_body.html @@ -1,90 +1,14 @@ -{% extends 'components/card.html' %} -{% load i18n %} - -{% load bookwyrm_tags %} -{% load humanize %} - -{% block card-header %} -

- {% include 'snippets/status/status_header.html' with status=status %} -

-{% endblock %} - +{% extends 'snippets/status/layout.html' %} {% block card-content %} - {% include 'snippets/status/status_content.html' with status=status %} -{% endblock %} +{% with status_type=status.status_type %} - -{% block card-footer %} - - - - - -{% if not moderation_mode %} - +{% if status_type == 'GeneratedNote' or status_type == 'Rating' %} + {% include 'snippets/status/generated_status.html' with status=status %} +{% else %} + {% include 'snippets/status/content_status.html' with status=status %} {% endif %} -{% endblock %} - -{% block card-bonus %} -{% if request.user.is_authenticated and not moderation_mode %} -{% with status.id|uuid as uuid %} - {% endwith %} -{% endif %} {% endblock %} + diff --git a/bookwyrm/templates/snippets/status/status_header.html b/bookwyrm/templates/snippets/status/status_header.html index 6493bd548..0fa74ddd1 100644 --- a/bookwyrm/templates/snippets/status/status_header.html +++ b/bookwyrm/templates/snippets/status/status_header.html @@ -40,10 +40,29 @@ {% endwith %} {% endif %} + {% if status.book %} -{{ status.book.title }} + {% if status.status_type == 'GeneratedNote' or status.status_type == 'Rating' %} + {{ status.book.title }}{% if status.status_type == 'Rating' %}: + + + + {% include 'snippets/stars.html' with rating=status.rating %} + {% endif %} + {% else %} + {% include 'snippets/book_titleby.html' with book=status.book %} + {% endif %} {% elif status.mention_books %} -{{ status.mention_books.first.title }} + {{ status.mention_books.first.title }} {% endif %} {% if status.progress %} diff --git a/bookwyrm/templates/snippets/trimmed_text.html b/bookwyrm/templates/snippets/trimmed_text.html index 6a3fa007b..0dd19e6ee 100644 --- a/bookwyrm/templates/snippets/trimmed_text.html +++ b/bookwyrm/templates/snippets/trimmed_text.html @@ -4,7 +4,7 @@ {% with 0|uuid as uuid %} {% if full %} {% with full|to_markdown|safe as full %} - {% with full|to_markdown|safe|truncatewords_html:60 as trimmed %} + {% with full|to_markdown|safe|truncatewords_html:150 as trimmed %} {% if not no_trim and trimmed != full %}
diff --git a/bookwyrm/templatetags/bookwyrm_tags.py b/bookwyrm/templatetags/bookwyrm_tags.py index 5d9819091..69e762cef 100644 --- a/bookwyrm/templatetags/bookwyrm_tags.py +++ b/bookwyrm/templatetags/bookwyrm_tags.py @@ -1,11 +1,8 @@ """ template filters """ from uuid import uuid4 -from datetime import datetime -from dateutil.relativedelta import relativedelta from django import template from django.db.models import Avg -from django.utils import timezone from bookwyrm import models, views from bookwyrm.views.status import to_markdown