bookwyrm/fedireads/templates/feed.html

109 lines
4.9 KiB
HTML
Raw Normal View History

2020-01-25 23:25:19 +00:00
{% extends 'layout.html' %}
{% block content %}
<div id="sidebar">
2020-01-29 01:23:38 +00:00
<div>
<h2>Currently Reading</h2>
{# listing books currently on user's shelves #}
2020-01-29 08:05:58 +00:00
{% if not reading.books.all %}
2020-01-29 01:23:38 +00:00
<p>Start a book!</p>
2020-01-29 08:05:58 +00:00
{% for book in to_read.books.all %}
<div class="book-preview">
<img class="book-cover small" src="{% if book.cover %}/images/{{ book.cover }}{% else %}/static/images/no_cover.jpg{% endif %}">
<p class="title"><a href="{{ book.openlibrary_key }}">{{ book.data.title }}</a></p>
<p>by <a href="" class="author">{{ book.authors.first.data.name }}</a></p>
<button>start reading</button>
</div>
{% endfor %}
2020-01-25 23:25:19 +00:00
{% endif %}
2020-01-29 08:05:58 +00:00
{% for book in reading.books.all %}
2020-01-29 01:23:38 +00:00
<div class="book-preview">
2020-01-29 08:05:58 +00:00
<img class="book-cover small" src="{% if book.cover %}/images/{{ book.cover }}{% else %}/static/images/no_cover.jpg{% endif %}">
2020-01-29 01:23:38 +00:00
<p class="title"><a href="{{ book.openlibrary_key }}">{{ book.data.title }}</a></p>
<p>by <a href="" class="author">{{ book.authors.first.data.name }}</a></p>
<button>done reading</button>
</div>
{% endfor %}
2020-01-25 23:25:19 +00:00
</div>
2020-01-29 01:23:38 +00:00
<div>
<h2>Recently Added Books</h2>
2020-01-27 01:55:02 +00:00
{% for book in recent_books %}
<div class="book-preview">
2020-01-29 08:05:58 +00:00
<img class="book-cover small" src="{% if book.cover %}/images/{{ book.cover }}{% else %}/static/images/no_cover.jpg{% endif %}">
2020-01-28 02:47:54 +00:00
<p class="title">
<a href="{{ book.openlibrary_key }}">{{ book.data.title }}</a>
2020-01-28 23:23:49 +00:00
by
{# TODO: there should be a helper function for listing authors #}
<a href="" class="author">{{ book.authors.first.data.name }}</a>
2020-01-28 02:47:54 +00:00
</p>
2020-01-29 01:23:38 +00:00
{% if not book in user_books.all %}
2020-01-28 07:20:32 +00:00
<form name="shelve" action="/shelve/{{ request.user.localname }}_to-read/{{ book.id }}" method="post">
2020-01-27 01:55:02 +00:00
<input type="hidden" name="book" value="book.id"></input>
2020-01-28 23:23:49 +00:00
<button type="submit">Want to read</button>
2020-01-27 01:55:02 +00:00
</form>
{% endif %}
</div>
{% endfor %}
</div>
2020-01-29 01:23:38 +00:00
</div>
<div id="feed">
2020-01-28 02:47:54 +00:00
{% for activity in activities %}
2020-01-25 23:25:19 +00:00
<div class="update">
2020-01-29 01:23:38 +00:00
<h2>
2020-01-29 07:23:05 +00:00
<img class="user-pic" src="{% if activity.user.avatar %}/images/{{ activity.user.avatar }}{% else %}/static/images/default_avi.jpg{% endif %}">
2020-01-29 01:23:38 +00:00
{# TODO: a helper function for displaying a username #}
<a href="/user/{% if activity.user.localname %}{{ activity.user.localname }}{% else %}{{ activity.user.username }}{% endif %}" class="user">
{% if activity.user.localname %}{{ activity.user.localname }}{% else %}{{ activity.user.username }}{% endif %}</a>
{% if activity.fedireads_type == 'Shelve' %}
{# display a reading/shelving activity #}
{% if activity.shelf.shelf_type == 'to-read' %}
wants to read
{% elif activity.shelf.shelf_type == 'read' %}
finished reading
{% elif activity.shelf.shelf_type == 'reading' %}
started reading
2020-01-28 23:23:49 +00:00
{% else %}
2020-01-29 01:23:38 +00:00
shelved in "{{ activity.shelf.name }}"
2020-01-28 23:23:49 +00:00
{% endif %}
2020-01-29 01:23:38 +00:00
</h2>
{# TODO: wouldn't it rule if this was a reusable piece of markup? #}
<div class="book-preview">
2020-01-29 08:05:58 +00:00
<img class="book-cover" src="{% if activity.book.cover %}/images/{{ activity.book.cover }}{% else %}/static/images/no_cover.jpg{% endif %}">
2020-01-29 01:23:38 +00:00
<p class="title">
<a href="{{ activity.book.openlibrary_key }}">{{ activity.book.data.title }}</a>
by
<a href="" class="author">{{ activity.book.authors.first.data.name }}</a>
</p>
</div>
{% elif activity.fedireads_type == 'Review' %}
{# display a review #}
reviewed {{ activity.book.data.title }}
</h2>
<div class="book-preview review">
2020-01-29 08:05:58 +00:00
<img class="book-cover" src="{% if activity.book.cover %}/images/{{ activity.book.cover }}{% else %}/static/images/no_cover.jpg{% endif %}">
2020-01-29 01:23:38 +00:00
<p class="title">
<a href="{{ activity.book.openlibrary_key }}">{{ activity.book.data.title }}</a>
by
<a href="" class="author">{{ activity.book.authors.first.data.name }}</a>
</p>
<h3>{{ activity.name }}</h3>
<p>{{ activity.rating }} stars</p>
<p>{{ activity.review_content }}</p>
</div>
{% elif activity.activity_type == 'Follow' %}
started following someone
</h2>
{% else %}
{# generic handling for a misc activity, which perhaps should not be displayed at all #}
did {{ activity.activity_type }}
</h2>
{% endif %}
2020-01-25 23:25:19 +00:00
</div>
2020-01-28 02:47:54 +00:00
{% endfor %}
2020-01-25 23:25:19 +00:00
</div>
{% endblock %}