diff --git a/fedireads/templates/book.html b/fedireads/templates/book.html index 2f2a3384..72ad5d83 100644 --- a/fedireads/templates/book.html +++ b/fedireads/templates/book.html @@ -4,7 +4,7 @@
- {% include 'book_snippet.html' with book=book size=large rating=rating description=True %} + {% include 'snippets/book.html' with book=book size=large rating=rating description=True %}
@@ -21,7 +21,7 @@ {% for review in reviews %}

{{ review.name }} - {{ review.rating | stars }} stars, by {{ review.user.username }} + {{ review.rating | stars }} stars, by {% include 'snippets/username.html' with user=review.user %}

{{ review.review_content }}
diff --git a/fedireads/templates/feed.html b/fedireads/templates/feed.html index d9db63b8..046a6883 100644 --- a/fedireads/templates/feed.html +++ b/fedireads/templates/feed.html @@ -9,7 +9,7 @@

Start a book!

{% for book in to_read.books.all %}
- {% include 'book_snippet.html' with book=book size="small" %} + {% include 'snippets/book.html' with book=book size="small" %}
{% csrf_token %} @@ -21,7 +21,7 @@ {% for book in reading.books.all %}
- {% include 'book_snippet.html' with book=book size="small" %} + {% include 'snippets/book.html' with book=book size="small" %} {% csrf_token %} @@ -35,7 +35,7 @@

Recently Added Books

{% for book in recent_books %}
- {% include 'book_snippet.html' with book=book size="small" %} + {% include 'snippets/book.html' with book=book size="small" %} {% if not book in user_books.all %} {% csrf_token %} @@ -53,10 +53,8 @@ {% for activity in activities %}

- - {# TODO: a helper function for displaying a username #} - - {% if activity.user.localname %}{{ activity.user.localname }}{% else %}{{ activity.user.username }}{% endif %} + {% include 'snippets/avatar.html' with user=activity.user %} + {% include 'snippets/username.html' with user=activity.user %} {% if activity.fedireads_type == 'Shelve' %} {# display a reading/shelving activity #} {% if activity.shelf.shelf_type == 'to-read' %} @@ -69,9 +67,8 @@ shelved in "{{ activity.shelf.name }}" {% endif %}

- {# TODO: wouldn't it rule if this was a reusable piece of markup? #}
- {% include 'book_snippet.html' with book=activity.book size=large description=True %} + {% include 'snippets/book.html' with book=activity.book size=large description=True %}
{% elif activity.fedireads_type == 'Review' %} @@ -79,7 +76,7 @@ reviewed {{ activity.book.data.title }}
- {% include 'book_snippet.html' with book=activity.book size=large %} + {% include 'snippets/book.html' with book=activity.book size=large %}

{{ activity.name }}

{{ activity.rating | stars }}

diff --git a/fedireads/templates/layout.html b/fedireads/templates/layout.html index f4e88c78..ad951902 100644 --- a/fedireads/templates/layout.html +++ b/fedireads/templates/layout.html @@ -28,7 +28,7 @@ {% if user.is_authenticated %} {% csrf_token %} - Welcome, {{ request.user.localname }} + Welcome, {% include 'snippets/username.html' %} {% else %} diff --git a/fedireads/templates/snippets/avatar.html b/fedireads/templates/snippets/avatar.html new file mode 100644 index 00000000..6e9218a0 --- /dev/null +++ b/fedireads/templates/snippets/avatar.html @@ -0,0 +1,2 @@ + + diff --git a/fedireads/templates/book_snippet.html b/fedireads/templates/snippets/book.html similarity index 100% rename from fedireads/templates/book_snippet.html rename to fedireads/templates/snippets/book.html diff --git a/fedireads/templates/snippets/username.html b/fedireads/templates/snippets/username.html new file mode 100644 index 00000000..553724c5 --- /dev/null +++ b/fedireads/templates/snippets/username.html @@ -0,0 +1,2 @@ +{% if user.localname %}{{ user.localname }}{% else %}{{ user.username }}{% endif %} + diff --git a/fedireads/templates/user.html b/fedireads/templates/user.html index 53fb2a94..416ca201 100644 --- a/fedireads/templates/user.html +++ b/fedireads/templates/user.html @@ -5,7 +5,7 @@