bookwyrm/bookwyrm/templates/book/book.html

419 lines
19 KiB
HTML
Raw Normal View History

2020-01-28 02:47:54 +00:00
{% extends 'layout.html' %}
2021-06-07 16:13:24 +00:00
{% load i18n %}
2022-01-18 20:28:59 +00:00
{% load book_display_tags %}
2021-06-07 16:13:24 +00:00
{% load humanize %}
{% load utilities %}
{% load static %}
2020-09-29 18:00:54 +00:00
2021-05-24 13:54:43 +00:00
{% block title %}{{ book|book_title }}{% endblock %}
{% block opengraph %}
{% include 'snippets/opengraph.html' with title=book.title description=book|book_description image=book.preview_image %}
{% endblock %}
{% block content %}
{% if update_error %}
<div class="notification is-danger is-light">
<span class="icon icon-x" aria-hidden="true"></span>
<span>
{% trans "Unable to connect to remote source." %}
</span>
</div>
{% endif %}
2021-04-09 21:57:49 +00:00
{% with user_authenticated=request.user.is_authenticated can_edit_book=perms.bookwyrm.edit_book %}
<div class="block" itemscope itemtype="https://schema.org/Book">
2021-02-23 21:04:24 +00:00
<div class="columns is-mobile">
2020-12-17 22:11:24 +00:00
<div class="column">
2022-12-06 20:26:52 +00:00
<h1 class="title" itemprop="name" dir="auto">
{{ book.title }}
</h1>
{% if book.subtitle or book.series %}
<p class="subtitle title is-5">
{% if book.subtitle %}
<meta
itemprop="alternativeHeadline"
content="{{ book.subtitle | escape }}"
>
2022-12-06 20:26:52 +00:00
<span class="has-text-weight-bold" dir="auto">
{{ book.subtitle }}
</span>
2021-04-09 21:57:49 +00:00
{% endif %}
{% if book.series %}
<meta itemprop="isPartOf" content="{{ book.series | escape }}">
<meta itemprop="volumeNumber" content="{{ book.series_number }}">
2021-04-09 21:57:49 +00:00
({{ book.series }}{% if book.series_number %} #{{ book.series_number }}{% endif %})
{% endif %}
</p>
{% endif %}
2021-04-09 21:57:49 +00:00
2021-09-02 15:48:53 +00:00
{% if book.authors.exists %}
2022-12-06 20:26:52 +00:00
<div class="subtitle" dir="auto">
{% trans "by" %} {% include 'snippets/authors.html' with book=book %}
</div>
2020-12-17 22:11:24 +00:00
{% endif %}
</div>
2020-09-29 18:00:54 +00:00
2021-04-09 21:57:49 +00:00
{% if user_authenticated and can_edit_book %}
2020-12-17 22:11:24 +00:00
<div class="column is-narrow">
2021-07-12 23:17:20 +00:00
<a href="{% url 'edit-book' book.id %}">
2021-05-18 17:45:51 +00:00
<span class="icon icon-pencil" title="{% trans "Edit Book" %}" aria-hidden=True></span>
<span class="is-hidden-mobile">{% trans "Edit Book" %}</span>
2020-09-30 03:36:43 +00:00
</a>
</div>
{% endif %}
2020-09-29 18:00:54 +00:00
</div>
<div class="columns">
2021-03-28 18:18:01 +00:00
<div class="column is-one-fifth">
{% if not book.cover %}
{% if user_authenticated %}
2021-12-30 22:07:30 +00:00
<button
type="button"
class="cover-container no-cover is-h-m-mobile"
data-modal-open="add_cover_{{ book.id }}"
>
2021-12-29 16:10:44 +00:00
<img
class="book-cover"
src="{% static "images/no_cover.jpg" %}"
alt=""
aria-hidden="true"
>
<span class="cover-caption">
<span>{{ book.alt_text }}</span>
<span>{% trans "Click to add cover" %}</span>
</span>
2021-12-30 09:43:23 +00:00
<span class="button-invisible-overlay has-text-centered">
{% trans "Click to add cover" %}
</span>
</button>
2021-12-30 22:07:30 +00:00
{% join "add_cover" book.id as modal_id %}
{% include 'book/cover_add_modal.html' with id=modal_id %}
{% if request.GET.cover_error %}
<p class="help is-danger">{% trans "Failed to load cover" %}</p>
{% endif %}
{% else %}
2021-12-29 16:10:44 +00:00
{% include 'snippets/book_cover.html' with book=book cover_class='is-h-m-mobile' %}
{% endif %}
{% endif %}
{% if book.cover %}
2021-12-29 17:55:02 +00:00
<button type="button" data-modal-open="cover_show_modal" class="cover-container is-h-m-mobile is-relative">
{% include 'snippets/book_cover.html' with size='xxlarge' size_mobile='medium' book=book cover_class='is-h-m-mobile' %}
2021-12-30 09:43:23 +00:00
<span class="button-invisible-overlay has-text-centered">
2021-12-29 17:55:02 +00:00
{% trans "Click to enlarge" %}
</span>
</button>
{% include 'book/cover_show_modal.html' with book=book id="cover_show_modal" %}
{% endif %}
{% include 'snippets/rate_action.html' with user=request.user book=book %}
<div class="mb-3" id="tour-shelve-button">
{% include 'snippets/shelve_button/shelve_button.html' %}
</div>
2020-03-27 15:36:57 +00:00
<section class="is-clipped">
{% with book=book %}
<div class="content">
{% include 'book/publisher_info.html' %}
2021-01-05 01:42:02 +00:00
</div>
<div class="my-3">
{% include 'book/book_identifiers.html' %}
2021-01-05 01:42:02 +00:00
</div>
{% endwith %}
2021-01-05 01:42:02 +00:00
2021-12-07 20:41:11 +00:00
{% trans "Load data" as button_text %}
2021-01-05 01:42:02 +00:00
{% if book.openlibrary_key %}
2021-12-05 21:02:42 +00:00
<p>
<a href="{{ book.openlibrary_link }}" target="_blank" rel="nofollow noopener noreferrer">
2021-12-30 22:19:31 +00:00
{% trans "View on OpenLibrary" %}
</a>
2021-12-05 21:24:40 +00:00
{% if request.user.is_authenticated and perms.bookwyrm.edit_book %}
<button class="button is-small button-paragraph" type="button" data-modal-open="openlibrary_sync">
2021-12-30 22:19:31 +00:00
<span class="icon icon-download" title="{{ button_text }}"></span>
<span class="is-sr-only-mobile">{{ button_text }}</span>
</button>
{% include "book/sync_modal.html" with source="openlibrary.org" source_name="OpenLibrary" id="openlibrary_sync" %}
2021-12-05 21:24:40 +00:00
{% endif %}
2021-12-05 21:02:42 +00:00
</p>
2020-04-02 02:38:07 +00:00
{% endif %}
2021-04-29 18:14:20 +00:00
{% if book.inventaire_id %}
<p>
<a href="{{ book.inventaire_link }}" target="_blank" rel="nofollow noopener noreferrer">
2021-12-30 22:19:31 +00:00
{% trans "View on Inventaire" %}
</a>
{% if request.user.is_authenticated and perms.bookwyrm.edit_book %}
<button class="button is-small button-paragraph" type="button" data-modal-open="inventaire_sync">
2021-12-30 22:19:31 +00:00
<span class="icon icon-download" title="{{ button_text }}"></span>
<span class="is-sr-only-mobile">{{ button_text }}</span>
</button>
{% include "book/sync_modal.html" with source="inventaire.io" source_name="Inventaire" id="inventaire_sync" %}
{% endif %}
</p>
2021-04-29 18:14:20 +00:00
{% endif %}
{% if book.isfdb %}
<p>
<a href="{{ book.isfdb_link }}" target="_blank" rel="nofollow noopener noreferrer">
{% trans "View on ISFDB" %}
</a>
</p>
{% endif %}
2021-01-05 01:42:02 +00:00
</section>
2020-03-28 22:06:16 +00:00
</div>
2020-04-02 02:38:07 +00:00
<div class="column is-three-fifths">
2020-09-29 18:00:54 +00:00
<div class="block">
<div
2021-04-09 21:57:49 +00:00
class="field is-grouped"
itemprop="aggregateRating"
itemscope
itemtype="https://schema.org/AggregateRating"
>
<meta itemprop="ratingValue" content="{{ rating|floatformat }}">
{# @todo Is it possible to not hard-code the value? #}
<meta itemprop="bestRating" content="5">
<meta itemprop="reviewCount" content="{{ review_count }}">
{% include 'snippets/stars.html' with rating=rating %}
2021-04-09 21:57:49 +00:00
{% blocktrans count counter=review_count trimmed %}
({{ review_count }} review)
{% plural %}
({{ review_count }} reviews)
{% endblocktrans %}
</div>
2020-04-02 02:38:07 +00:00
2021-04-09 21:57:49 +00:00
{% with full=book|book_description itemprop='abstract' %}
{% include 'snippets/trimmed_text.html' %}
{% endwith %}
2020-04-02 02:38:07 +00:00
2021-04-09 21:57:49 +00:00
{% if user_authenticated and can_edit_book and not book|book_description %}
{% trans 'Add Description' as button_text %}
{% include 'snippets/toggle/open_button.html' with class="mb-2" text=button_text controls_text="add_description" controls_uid=book.id focus="id_description" hide_active=True id="hide_description" %}
<div class="box is-hidden" id="add_description_{{ book.id }}">
2021-12-15 20:40:01 +00:00
<form name="add-description" method="POST" action="{% url "add-description" book.id %}">
{% csrf_token %}
<div class="field">
<label class="label" for="id_description_{{ book.id }}">{% trans "Description:" %}</label>
<textarea name="description" cols="None" rows="None" class="textarea" id="id_description_{{ book.id }}"></textarea>
</div>
<div class="field">
<button class="button is-primary" type="submit">{% trans "Save" %}</button>
{% trans "Cancel" as button_text %}
{% include 'snippets/toggle/close_button.html' with text=button_text controls_text="add_description" controls_uid=book.id hide_inactive=True %}
2020-11-28 15:55:31 +00:00
</div>
</form>
2020-11-28 15:55:31 +00:00
</div>
{% endif %}
{% with work=book.parent_work editions_count=book.parent_work.editions.count %}
2022-03-17 14:40:55 +00:00
<p>
<a href="{{ work.local_path }}/editions" id="tour-other-editions-link">
{% blocktrans trimmed count counter=editions_count with count=editions_count|intcomma %}
2022-03-17 14:40:55 +00:00
{{ count }} edition
{% plural %}
{{ count }} editions
{% endblocktrans %}
</a>
</p>
{% endwith %}
2020-09-29 18:00:54 +00:00
</div>
2020-04-02 02:38:07 +00:00
{# user's relationship to the book #}
2021-01-07 02:34:21 +00:00
<div class="block">
{% if user_shelfbooks.count > 0 %}
<h2 class="title is-5">
{% trans "You have shelved this edition in:" %}
</h2>
<ul>
2021-05-23 03:14:57 +00:00
{% for shelf in user_shelfbooks %}
<li class="box">
2021-12-04 22:40:25 +00:00
<a href="{{ shelf.shelf.local_path }}">{{ shelf.shelf.name }}</a>
<div class="is-pulled-right">
{% include 'snippets/shelf_selector.html' with shelf=shelf.shelf class="is-small" readthrough=readthrough %}
</div>
</li>
{% endfor %}
</ul>
{% endif %}
{% for shelf in other_edition_shelves %}
<p>
{% blocktrans with book_path=shelf.book.local_path shelf_path=shelf.shelf.local_path shelf_name=shelf.shelf.name %}A <a href="{{ book_path }}">different edition</a> of this book is on your <a href="{{ shelf_path }}">{{ shelf_name }}</a> shelf.{% endblocktrans %}
2020-12-12 00:57:38 +00:00
{% include 'snippets/switch_edition_button.html' with edition=book %}
</p>
{% endfor %}
2021-01-07 02:34:21 +00:00
</div>
2020-11-06 20:51:49 +00:00
2021-04-09 21:57:49 +00:00
{% if user_authenticated %}
<hr aria-hidden="true">
<section class="block">
<header class="columns">
<div class="column">
<h2 class="title is-5">{% trans "Your reading activity" %}</h2>
</div>
<div class="column is-narrow">
<button class="button is-small" data-modal-open="add-readthrough" id="tour-add-readthrough">
2022-01-11 17:50:04 +00:00
<span class="icon icon-plus m-mobile-0" aria-hidden="true"></span>
<span class="is-sr-only-mobile">
{% trans "Add read dates" %}
</span>
</button>
</div>
</header>
2022-01-11 18:27:10 +00:00
{% include "readthrough/readthrough_modal.html" with id="add-readthrough" %}
2022-01-11 17:50:04 +00:00
{% if not readthroughs.exists %}
<p>{% trans "You don't have any reading activity for this book." %}</p>
{% endif %}
{% for readthrough in readthroughs %}
2022-01-11 17:58:28 +00:00
{% include 'readthrough/readthrough_list.html' with readthrough=readthrough %}
{% endfor %}
</section>
<hr aria-hidden="true">
2020-10-29 19:32:37 +00:00
2021-01-18 04:19:09 +00:00
<section class="box">
2021-09-29 22:52:08 +00:00
{% with 0|uuid as controls_uid %}
{% include 'snippets/create_status.html' with book=book hide_cover=True %}
2021-09-29 22:52:08 +00:00
{% endwith %}
2021-01-18 04:19:09 +00:00
</section>
2020-09-29 18:00:54 +00:00
{% endif %}
<div class="block" id="reviews">
{% if request.user.is_authenticated %}
2021-05-18 18:09:19 +00:00
{% if user_statuses.review_count or user_statuses.comment_count or user_statuses.quotation_count %}
<nav class="tabs">
<ul>
{% url 'book' book.id book.name|slugify as tab_url %}
<li {% if tab_url == request.path %}class="is-active"{% endif %}>
<a href="{{ tab_url }}#reviews">{% trans "Reviews" %} ({{ review_count }})</a>
</li>
{% if user_statuses.review_count %}
{% url 'book-user-statuses' book.id 'review' as tab_url %}
<li {% if tab_url == request.path %}class="is-active"{% endif %}>
<a href="{{ tab_url }}#reviews">{% trans "Your reviews" %} ({{ user_statuses.review_count }})</a>
</li>
{% endif %}
{% if user_statuses.comment_count %}
{% url 'book-user-statuses' book.id 'comment' as tab_url %}
<li {% if tab_url == request.path %}class="is-active"{% endif %}>
<a href="{{ tab_url }}#reviews">{% trans "Your comments" %} ({{ user_statuses.comment_count }})</a>
</li>
{% endif %}
{% if user_statuses.quotation_count %}
{% url 'book-user-statuses' book.id 'quote' as tab_url %}
<li {% if tab_url == request.path %}class="is-active"{% endif %}>
<a href="{{ tab_url }}#reviews">{% trans "Your quotes" %} ({{ user_statuses.quotation_count }})</a>
</li>
{% endif %}
</ul>
</nav>
{% endif %}
{% endif %}
2021-05-18 18:17:59 +00:00
{% for status in statuses %}
<div
class="block"
2021-05-18 18:17:59 +00:00
{% if status.status_type == 'Review' or status.status_type == 'Rating' %}
itemprop="review"
itemscope
itemtype="https://schema.org/Review"
2021-05-18 18:17:59 +00:00
{% endif %}
>
2021-05-18 18:17:59 +00:00
{% include 'snippets/status/status.html' with status=status hide_book=True depth=1 %}
</div>
{% endfor %}
2021-05-18 18:09:19 +00:00
{% if ratings %}
<div class="block is-flex is-flex-wrap-wrap">
{% for rating in ratings %}
2021-05-18 18:17:59 +00:00
{% include 'book/rating.html' with user=rating.user rating=rating %}
{% endfor %}
</div>
2021-05-18 18:09:19 +00:00
{% endif %}
<div class="block">
{% include 'snippets/pagination.html' with page=statuses path=request.path anchor="#reviews" %}
</div>
</div>
2020-04-12 04:49:06 +00:00
</div>
2021-12-15 21:35:10 +00:00
<div class="column is-one-fifth is-clipped">
2021-01-05 01:42:02 +00:00
{% if book.subjects %}
2021-04-09 21:57:49 +00:00
<section class="content block">
<h2 class="title is-5">{% trans "Subjects" %}</h2>
<ul>
{% for subject in book.subjects %}
<li itemprop="about">{{ subject }}</li>
{% endfor %}
</ul>
</section>
2021-01-05 01:42:02 +00:00
{% endif %}
{% if book.subject_places %}
<section class="content block">
<h2 class="title is-5">{% trans "Places" %}</h2>
2021-01-05 01:42:02 +00:00
<ul>
2021-03-07 15:35:38 +00:00
{% for place in book.subject_places %}
2021-01-05 01:42:02 +00:00
<li>{{ place }}</li>
{% endfor %}
</ul>
</section>
{% endif %}
2021-02-15 19:30:22 +00:00
2021-03-15 21:44:03 +00:00
{% if lists.exists or request.user.list_set.exists %}
2021-12-15 21:35:10 +00:00
<section class="content block is-clipped">
<h2 class="title is-5">{% trans "Lists" %}</h2>
2021-02-15 19:30:22 +00:00
<ul>
{% for list in lists %}
2021-12-15 21:23:25 +00:00
<li><a href="{{ list.local_path }}">{{ list.name }}</a></li>
2021-02-15 19:30:22 +00:00
{% endfor %}
</ul>
2021-03-15 21:44:03 +00:00
{% if list_options.exists %}
2021-03-15 21:44:03 +00:00
<form name="list-add" method="post" action="{% url 'list-add-book' %}">
{% csrf_token %}
<input type="hidden" name="book" value="{{ book.id }}">
<input type="hidden" name="user" value="{{ request.user.id }}">
2021-03-15 21:44:03 +00:00
<label class="label" for="id_list">{% trans "Add to list" %}</label>
<div class="field has-addons">
2021-12-15 21:35:10 +00:00
<div class="select control is-clipped">
<select name="book_list" id="id_list">
{% for list in list_options %}
2021-03-15 21:44:03 +00:00
<option value="{{ list.id }}">{{ list.name }}</option>
{% endfor %}
</select>
</div>
<div class="control">
<button type="submit" class="button is-link">{% trans "Add" %}</button>
</div>
</div>
</form>
{% endif %}
2021-02-15 19:30:22 +00:00
</section>
{% endif %}
2021-12-15 20:40:01 +00:00
<section class="content block" id="tour-book-file-links">
2022-01-13 00:46:14 +00:00
{% include "book/file_links/links.html" %}
2021-12-15 20:40:01 +00:00
</section>
2021-01-05 01:42:02 +00:00
</div>
</div>
2020-03-17 00:19:38 +00:00
</div>
2021-04-09 21:57:49 +00:00
{% endwith %}
2020-01-28 02:47:54 +00:00
{% endblock %}
2021-03-22 19:37:01 +00:00
{% block scripts %}
<script src="{% static "js/tabs.js" %}?v={{ js_cache }}"></script>
2022-01-13 01:06:36 +00:00
<script src="{% static "js/autocomplete.js" %}?v={{ js_cache }}"></script>
2022-07-09 00:23:09 +00:00
{% if request.user.show_guided_tour %}
{% include 'guided_tour/book.html' %}
{% endif %}
2021-03-22 19:37:01 +00:00
{% endblock %}