Use compose tabs in book page

Fixes #144
This commit is contained in:
Mouse Reeve 2020-04-21 08:01:54 -07:00
parent 94e66829b8
commit 52651fdaa0
5 changed files with 16 additions and 21 deletions

View file

@ -75,13 +75,13 @@ def get_avatar(data):
def get_remote_reviews(user): def get_remote_reviews(user):
''' ingest reviews by a new remote fedireads user ''' ''' ingest reviews by a new remote fedireads user '''
# TODO: use the server as the data source instead of OL
outbox_page = user.outbox + '?page=true' outbox_page = user.outbox + '?page=true'
response = requests.get( response = requests.get(
outbox_page, outbox_page,
headers={'Accept': 'application/activity+json'} headers={'Accept': 'application/activity+json'}
) )
data = response.json() data = response.json()
# TODO: pagination?
for status in data['orderedItems']: for status in data['orderedItems']:
if status.get('fedireadsType') == 'Review': if status.get('fedireadsType') == 'Review':
create_review_from_activity(user, status) create_review_from_activity(user, status)

View file

@ -618,14 +618,14 @@ dd {
input:checked ~ .compose-suggestion { input:checked ~ .compose-suggestion {
display: block; display: block;
} }
.compose-suggestion .book-preview { .compose .book-preview {
background-color: #EEE; background-color: #EEE;
padding: 1em; padding: 1em;
} }
.compose-suggestion button { .compose button {
margin: 0; margin: 0;
} }
.compose-suggestion .stars { .compose .stars {
text-align: left; text-align: left;
} }

View file

@ -49,15 +49,8 @@
{% endif %} {% endif %}
{% if request.user.is_authenticated %} {% if request.user.is_authenticated %}
<div> <div class="compose">
<h3>Leave a review</h3> {% include 'snippets/create_status.html' with book=book hide_cover=True %}
<form class="review-form" name="review" action="/review/" method="post">
{% csrf_token %}
{% include 'snippets/rate_form.html' with book=book %}
<input type="hidden" name="book" value="{{ book.fedireads_key }}"></input>
{{ review_form.as_p }}
<button type="submit">Post review</button>
</form>
</div> </div>
<div> <div>

View file

@ -28,12 +28,19 @@
{% for book in shelf.books %} {% for book in shelf.books %}
<div class="compose-popout"> <div class="compose-popout">
<input name="book-popout" type="radio" id="book-{{ book.id }}-radio"></input> <input name="book-popout" type="radio" id="book-{{ book.id }}-radio"></input>
<div class="compose-suggestion" id="compose-book-{{ book.id }}"> <div class="compose compose-suggestion" id="compose-book-{{ book.id }}">
<label class="close icon icon-close" for="book-{{ book.id }}-radio-close" onclick="hide_element(this)"> <label class="close icon icon-close" for="book-{{ book.id }}-radio-close" onclick="hide_element(this)">
<span class="hidden-text">Close</span> <span class="hidden-text">Close</span>
</label> </label>
<input name="book-popout" type="radio" id="book-{{ book.id }}-radio-close"></input> <input name="book-popout" type="radio" id="book-{{ book.id }}-radio-close"></input>
<div class="content-container"> <div class="content-container">
<h2>
{% include 'snippets/avatar.html' with user=user %}
Your thoughts on
a <a href="/book/{{ book.fedireads_key }}">{{ book.title }}</a>
by {% include 'snippets/authors.html' with book=book %}
</h2>
{% include 'snippets/create_status.html' with book=book user=request.user %} {% include 'snippets/create_status.html' with book=book user=request.user %}
</div> </div>
</div> </div>

View file

@ -1,13 +1,6 @@
{% load humanize %} {% load humanize %}
{% load fr_display %} {% load fr_display %}
<h2>
{% include 'snippets/avatar.html' with user=user %}
Your thoughts on
a <a href="/book/{{ book.fedireads_key }}">{{ book.title }}</a>
by {% include 'snippets/authors.html' with book=book %}
</h2>
<div class="tabs secondary"> <div class="tabs secondary">
<div class="tab active" data-id="tab-review-{{ book.id }}" data-category="tab-option-{{ book.id }}"> <div class="tab active" data-id="tab-review-{{ book.id }}" data-category="tab-option-{{ book.id }}">
<a href="{{ book.absolute_id }}/review" onclick="tabChange(event)">Review</a> <a href="{{ book.absolute_id }}/review" onclick="tabChange(event)">Review</a>
@ -21,9 +14,11 @@ a <a href="/book/{{ book.fedireads_key }}">{{ book.title }}</a>
</div> </div>
<div class="book-preview row"> <div class="book-preview row">
{% if not hide_cover %}
<div class="cover-container"> <div class="cover-container">
{% include 'snippets/book_cover.html' with book=book %} {% include 'snippets/book_cover.html' with book=book %}
</div> </div>
{% endif %}
<form class="tab-option-{{ book.id }} review-form" name="review" action="/review/" method="post" id="tab-review-{{ book.id }}"> <form class="tab-option-{{ book.id }} review-form" name="review" action="/review/" method="post" id="tab-review-{{ book.id }}">
{% csrf_token %} {% csrf_token %}
<input type="hidden" name="book" value="{{ book.fedireads_key }}"></input> <input type="hidden" name="book" value="{{ book.fedireads_key }}"></input>