forked from mirrors/bookwyrm
Format descriptions
This commit is contained in:
parent
093f2d4fdd
commit
fa0f37fb0f
4 changed files with 24 additions and 16 deletions
|
@ -8,24 +8,20 @@
|
|||
<h1>{{ book.data.title }}</h1>
|
||||
by {{ book.authors.first.data.name }}
|
||||
{{ rating | stars }} {{ rating }}
|
||||
<blockquote>{{ book.data.description }}</blockquote>
|
||||
<blockquote>{{ book.data.description | description }}</blockquote>
|
||||
</div>
|
||||
|
||||
<h3>Leave a review</h3>
|
||||
|
||||
</div>
|
||||
<div class="reviews">
|
||||
<h2>Reviews</h2>
|
||||
{% if not reviews %}
|
||||
<p>No reviews yet!</p>
|
||||
{% endif %}
|
||||
<form class="review-form" name="review" action="/review/" method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="book" value="{{ book.openlibrary_key }}"></input>
|
||||
{{ review_form.as_p }}
|
||||
<button type="submit">Post review</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="reviews">
|
||||
<h2>Reviews</h2>
|
||||
{% if not reviews %}
|
||||
<p>No reviews yet!</p>
|
||||
{% endif %}
|
||||
{% for review in reviews %}
|
||||
<div class="review">
|
||||
<h4>{{ review.name }}
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
<a href="{{ activity.book.openlibrary_key }}">{{ activity.book.data.title }}</a>
|
||||
by
|
||||
<a href="" class="author">{{ activity.book.authors.first.data.name }}</a>
|
||||
<blockquote>{{ activity.book.data.description }}</blockquote>
|
||||
<blockquote>{{ activity.book.data.description | description }}</blockquote>
|
||||
</p>
|
||||
</div>
|
||||
<div class="interaction"><button>⭐️ Like</button></div>
|
||||
|
@ -100,11 +100,10 @@
|
|||
<a href="{{ activity.book.openlibrary_key }}">{{ activity.book.data.title }}</a>
|
||||
by
|
||||
<a href="" class="author">{{ activity.book.authors.first.data.name }}</a>
|
||||
<blockquote>{{ activity.book.data.description }}</blockquote>
|
||||
</p>
|
||||
|
||||
<h3>{{ activity.name }}</h3>
|
||||
<p>{{ activity.rating | stars }} stars</p>
|
||||
<p>{{ activity.rating | stars }}</p>
|
||||
<p>{{ activity.review_content }}</p>
|
||||
</div>
|
||||
<div class="interaction"><button>⭐️ Like</button></div>
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
<div id="content">
|
||||
{% for shelf in shelves %}
|
||||
<div>
|
||||
<h2>{{ shelf.shelf.name }}</h2>
|
||||
<h2>{{ shelf.name }}</h2>
|
||||
{% if shelf.books %}
|
||||
<table>
|
||||
<tr class="book-preview">
|
||||
|
|
|
@ -11,5 +11,18 @@ def dict_key(d, k):
|
|||
@register.filter(name='stars')
|
||||
def stars(number):
|
||||
''' turn integers into stars '''
|
||||
number = int(number)
|
||||
try:
|
||||
number = int(number)
|
||||
except TypeError:
|
||||
number = 0
|
||||
return ('★' * number) + '☆' * (5 - number)
|
||||
|
||||
@register.filter(name='description')
|
||||
def description_format(description):
|
||||
''' handle the various OL description formats '''
|
||||
if isinstance(description, dict) and 'value' in description:
|
||||
description = description['value']
|
||||
if '----------' in description:
|
||||
description = description.split('----------')[0]
|
||||
|
||||
return description.strip()
|
||||
|
|
Loading…
Reference in a new issue