From 50f2f4788e3d83c208312dd219c4f7963877f422 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 29 Sep 2020 17:43:30 -0700 Subject: [PATCH] Adds review box to main page layout --- bookwyrm/static/css/format.css | 16 +++-- bookwyrm/static/js/shared.js | 2 +- bookwyrm/templates/feed.html | 70 +++++++++++++------ bookwyrm/templates/snippets/covers_shelf.html | 6 +- .../templates/snippets/create_status.html | 56 +++++++-------- bookwyrm/views.py | 27 ------- 6 files changed, 89 insertions(+), 88 deletions(-) diff --git a/bookwyrm/static/css/format.css b/bookwyrm/static/css/format.css index aacb12c09..51aea3571 100644 --- a/bookwyrm/static/css/format.css +++ b/bookwyrm/static/css/format.css @@ -81,15 +81,27 @@ input.toggle-control:checked ~ .toggle-content { .cover-container { height: 250px; } +.cover-container.is-medium { + height: 150px; +} +.cover-container.is-medium .no-cover div { + font-size: 0.9em; + padding: 0.3em; +} .cover-container.is-small { height: 100px; } +.cover-container.is-small .no-cover div { + font-size: 0.7em; + padding: 0.1em; +} .book-cover { height: 100%; object-fit: scale-down; } .no-cover { position: relative; + white-space: normal; } .no-cover div { position: absolute; @@ -99,10 +111,6 @@ input.toggle-control:checked ~ .toggle-content { left: 0; text-align: center; } -.is-small .no-cover div { - font-size: 0.7em; - padding: 0.1em; -} /* --- AVATAR --- */ diff --git a/bookwyrm/static/js/shared.js b/bookwyrm/static/js/shared.js index 6ed72a4a7..9b16174e7 100644 --- a/bookwyrm/static/js/shared.js +++ b/bookwyrm/static/js/shared.js @@ -32,7 +32,7 @@ function rate_stars(e) { } function tabChange(e) { - var target = e.target.parentElement.parentElement; + var target = e.target.closest('li') var identifier = target.getAttribute('data-id'); var tabs = target.parentElement.children; diff --git a/bookwyrm/templates/feed.html b/bookwyrm/templates/feed.html index 4499ea09e..2c3766d2b 100644 --- a/bookwyrm/templates/feed.html +++ b/bookwyrm/templates/feed.html @@ -2,31 +2,55 @@ {% load fr_display %} {% block content %} -
- {% for activity in activities %} -
- {% include 'snippets/status.html' with status=activity %} +
+
+

Recent Books

+
+ +
+ {% for book in user_books|slice:3 %} +
+ + +
+ {% endfor %}
- {% endfor %} - + +
{% endblock %} diff --git a/bookwyrm/templates/snippets/covers_shelf.html b/bookwyrm/templates/snippets/covers_shelf.html index 7e38f9e62..69b8114f1 100644 --- a/bookwyrm/templates/snippets/covers_shelf.html +++ b/bookwyrm/templates/snippets/covers_shelf.html @@ -1,14 +1,15 @@ {% load fr_display %} +
{% for shelf in shelves %} {% if shelf.books %} -
+

{{ shelf.name }} {% if shelf.size > shelf.books|length %} (See all {{ shelf.size }}) {% endif %}

-
+
{% for book in shelf.books %}
{% endif %} {% endfor %} +
diff --git a/bookwyrm/templates/snippets/create_status.html b/bookwyrm/templates/snippets/create_status.html index 3ab7fbeb8..1a6438872 100644 --- a/bookwyrm/templates/snippets/create_status.html +++ b/bookwyrm/templates/snippets/create_status.html @@ -1,71 +1,65 @@ {% load humanize %} {% load fr_display %} -
- -
-
- {% if not hide_cover %} -
- {% include 'snippets/book_cover.html' with book=book %} -
- {% endif %} -
+
+ +
+
- +
- +
- + diff --git a/bookwyrm/views.py b/bookwyrm/views.py index 654dd26e3..85a9e0237 100644 --- a/bookwyrm/views.py +++ b/bookwyrm/views.py @@ -56,26 +56,6 @@ def home_tab(request, tab): except ValueError: page = 1 - shelves = [] - shelves = get_user_shelf_preview( - request.user, - [('reading', 3), ('read', 1), ('to-read', 3)] - ) - size = sum(len(s['books']) for s in shelves) - # books new to the instance, for discovery - if size < 6: - recent_books = models.Work.objects.order_by( - '-created_date' - )[:6 - size] - recent_books = [b.default_edition for b in recent_books] - shelves.append({ - 'name': 'Recently added', - 'identifier': None, - 'books': recent_books, - 'count': 6 - size, - }) - - # allows us to check if a user has shelved a book user_books = models.Edition.objects.filter(shelves__user=request.user).all() @@ -88,15 +68,8 @@ def home_tab(request, tab): prev_page = '/?page=%d' % (page - 1) data = { 'user': request.user, - 'shelves': shelves, 'user_books': user_books, 'activities': activities, - 'feed_tabs': [ - {'id': 'home', 'display': 'Home'}, - {'id': 'local', 'display': 'Local'}, - {'id': 'federated', 'display': 'Federated'} - ], - 'active_tab': tab, 'review_form': forms.ReviewForm(), 'quotation_form': forms.QuotationForm(), 'comment_form': forms.CommentForm(),