This commit is contained in:
Mouse Reeve 2021-08-07 12:33:45 -07:00
parent 040758c833
commit b5153f3df1
6 changed files with 154 additions and 8 deletions

View file

@ -0,0 +1,54 @@
{% extends "layout.html" %}
{% load i18n %}
{% block title %}{% trans "Discover" %}{% endblock %}
{% block content %}
<header class="block">
<h1 class="title has-text-centered">{% trans "Discover" %}</h1>
</header>
<section class="tile is-ancestor">
<div class="tile is-vertical">
<div class="tile is-parent">
<div class="tile is-child box has-background-white-ter">
{% include 'discover/large-book.html' with status=large.0 %}
</div>
</div>
<div class="tile">
<div class="tile is-parent is-6">
<div class="tile is-child box has-background-white-ter">
{% include 'discover/small-book.html' with status=small.0 %}
</div>
</div>
<div class="tile is-parent is-6">
<div class="tile is-child box has-background-white-ter">
{% include 'discover/small-book.html' with status=small.1 %}
</div>
</div>
</div>
</div>
<div class="tile is-vertical">
<div class="tile">
<div class="tile is-parent is-6">
<div class="tile is-child box has-background-white-ter">
{% include 'discover/small-book.html' with status=small.2 %}
</div>
</div>
<div class="tile is-parent is-6">
<div class="tile is-child box has-background-white-ter">
{% include 'discover/small-book.html' with status=small.3 %}
</div>
</div>
</div>
<div class="tile is-parent">
<div class="tile is-child box has-background-white-ter">
{% include 'discover/large-book.html' with status=large.1 %}
</div>
</div>
</div>
</section>
{% endblock %}

View file

@ -0,0 +1,38 @@
{% load bookwyrm_tags %}
{% load markdown %}
{% load i18n %}
{% if book %}
{% with book=book %}
<div class="columns is-gapless">
<div class="column is-5-tablet is-cover">
<a
class="align to-b to-l"
href="{{ book.local_path }}"
>{% include 'snippets/book_cover.html' with cover_class='is-w-l-mobile is-w-auto-tablet' %}</a>
{% include 'snippets/stars.html' with rating=book|rating:request.user %}
</div>
<div class="column mt-3-mobile ml-3-tablet">
<h3 class="title is-5">
<a href="{{ book.local_path }}">{{ book.title }}</a>
</h3>
{% if book.authors %}
<p class="subtitle is-5">
{% trans "by" %}
{% include 'snippets/authors.html' with limit=3 %}
</p>
{% endif %}
{% if book|book_description %}
<blockquote class="content">
{{ book|book_description|to_markdown|safe|truncatewords_html:50 }}
</blockquote>
{% endif %}
</div>
</div>
{% endwith %}
{% endif %}

View file

@ -0,0 +1,41 @@
{% load bookwyrm_tags %}
{% load utilities %}
{% load i18n %}
{% if status %}
{% with book=status.book %}
<a href="{{ book.local_path }}">
{% include 'snippets/book_cover.html' with cover_class='is-w-l-mobile is-h-l-tablet is-w-auto align to-b to-l' %}
</a>
{% include 'snippets/stars.html' with rating=book|rating:request.user %}
<h3 class="title is-6">
<a href="{{ book.local_path }}">{{ book.title }}</a>
</h3>
{% if book.authors %}
<p class="subtitle is-6">
{% trans "by" %}
{% include 'snippets/authors.html' with limit=3 %}
</p>
{% endif %}
<div class="media">
<figure class="media-left" aria-hidden="true">
<a class="image is-48x48" href="{{ status.user.local_path }}">
{% include 'snippets/avatar.html' with user=status.user ariaHide="true" medium="true" %}
</a>
</figure>
<div class="media-content">
<h3 class="has-text-weight-bold">
<a href="{{ status.user.local_path }}">
<span>{{ status.user.display_name }}</span>
</a>
</h3>
</div>
</div>
{% endwith %}
{% endif %}

View file

@ -23,7 +23,7 @@
{% if book.authors %}
<p class="subtitle is-5">
{% trans "by" %}
{% include 'snippets/authors.html' %}
{% include 'snippets/authors.html' with limit=3 %}
</p>
{% endif %}

View file

@ -16,7 +16,7 @@
{% if book.authors %}
<p class="subtitle is-6">
{% trans "by" %}
{% include 'snippets/authors.html' %}
{% include 'snippets/authors.html' with limit=3 %}
</p>
{% endif %}
{% endwith %}

View file

@ -1,11 +1,14 @@
""" What's up locally """
from django.contrib.auth.decorators import login_required
from django.core.paginator import Paginator
from django.db.models import Q
from django.template.response import TemplateResponse
from django.utils.decorators import method_decorator
from django.views import View
from bookwyrm import forms
from . import helpers
from bookwyrm import models
from bookwyrm.settings import PAGE_LENGTH
from .helpers import privacy_filter
# pylint: disable= no-self-use
@ -15,9 +18,19 @@ class Discover(View):
def get(self, request):
"""tiled book activity page"""
activities = privacy_filter(
request.user,
models.Status.objects.select_subclasses().filter(
Q(comment__isnull=False)
| Q(review__isnull=False)
| Q(quotation__isnull=False),
user__local=True
),
#privacy_levels=["public"]
)
#paginated = Paginator(activities, PAGE_LENGTH)
data = {
"register_form": forms.RegisterForm(),
"request_form": forms.InviteRequestForm(),
"books": helpers.get_landing_books(),
"large": activities.filter(~Q(review__isnull=True, review__content=None))[:2],
"small": activities.filter(~Q(content=None))[:4],
}
return TemplateResponse(request, "landing/landing.html", data)
return TemplateResponse(request, "discover/discover.html", data)