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>
|
<h1>{{ book.data.title }}</h1>
|
||||||
by {{ book.authors.first.data.name }}
|
by {{ book.authors.first.data.name }}
|
||||||
{{ rating | stars }} {{ rating }}
|
{{ rating | stars }} {{ rating }}
|
||||||
<blockquote>{{ book.data.description }}</blockquote>
|
<blockquote>{{ book.data.description | description }}</blockquote>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<h3>Leave a review</h3>
|
<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">
|
<form class="review-form" name="review" action="/review/" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<input type="hidden" name="book" value="{{ book.openlibrary_key }}"></input>
|
<input type="hidden" name="book" value="{{ book.openlibrary_key }}"></input>
|
||||||
{{ review_form.as_p }}
|
{{ review_form.as_p }}
|
||||||
<button type="submit">Post review</button>
|
<button type="submit">Post review</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="reviews">
|
|
||||||
<h2>Reviews</h2>
|
|
||||||
{% if not reviews %}
|
|
||||||
<p>No reviews yet!</p>
|
|
||||||
{% endif %}
|
|
||||||
{% for review in reviews %}
|
{% for review in reviews %}
|
||||||
<div class="review">
|
<div class="review">
|
||||||
<h4>{{ review.name }}
|
<h4>{{ review.name }}
|
||||||
|
|
|
@ -86,7 +86,7 @@
|
||||||
<a href="{{ activity.book.openlibrary_key }}">{{ activity.book.data.title }}</a>
|
<a href="{{ activity.book.openlibrary_key }}">{{ activity.book.data.title }}</a>
|
||||||
by
|
by
|
||||||
<a href="" class="author">{{ activity.book.authors.first.data.name }}</a>
|
<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>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="interaction"><button>⭐️ Like</button></div>
|
<div class="interaction"><button>⭐️ Like</button></div>
|
||||||
|
@ -100,11 +100,10 @@
|
||||||
<a href="{{ activity.book.openlibrary_key }}">{{ activity.book.data.title }}</a>
|
<a href="{{ activity.book.openlibrary_key }}">{{ activity.book.data.title }}</a>
|
||||||
by
|
by
|
||||||
<a href="" class="author">{{ activity.book.authors.first.data.name }}</a>
|
<a href="" class="author">{{ activity.book.authors.first.data.name }}</a>
|
||||||
<blockquote>{{ activity.book.data.description }}</blockquote>
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h3>{{ activity.name }}</h3>
|
<h3>{{ activity.name }}</h3>
|
||||||
<p>{{ activity.rating | stars }} stars</p>
|
<p>{{ activity.rating | stars }}</p>
|
||||||
<p>{{ activity.review_content }}</p>
|
<p>{{ activity.review_content }}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="interaction"><button>⭐️ Like</button></div>
|
<div class="interaction"><button>⭐️ Like</button></div>
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
<div id="content">
|
<div id="content">
|
||||||
{% for shelf in shelves %}
|
{% for shelf in shelves %}
|
||||||
<div>
|
<div>
|
||||||
<h2>{{ shelf.shelf.name }}</h2>
|
<h2>{{ shelf.name }}</h2>
|
||||||
{% if shelf.books %}
|
{% if shelf.books %}
|
||||||
<table>
|
<table>
|
||||||
<tr class="book-preview">
|
<tr class="book-preview">
|
||||||
|
|
|
@ -11,5 +11,18 @@ def dict_key(d, k):
|
||||||
@register.filter(name='stars')
|
@register.filter(name='stars')
|
||||||
def stars(number):
|
def stars(number):
|
||||||
''' turn integers into stars '''
|
''' turn integers into stars '''
|
||||||
|
try:
|
||||||
number = int(number)
|
number = int(number)
|
||||||
|
except TypeError:
|
||||||
|
number = 0
|
||||||
return ('★' * number) + '☆' * (5 - number)
|
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