Discovery landing page

This commit is contained in:
Mouse Reeve 2021-01-03 11:10:04 -08:00
parent 71e1e259b5
commit ef42d29bd9
7 changed files with 159 additions and 14 deletions

View file

@ -108,7 +108,7 @@ class Connector(AbstractConnector):
def get_cover_url(self, cover_blob): def get_cover_url(self, cover_blob):
''' ask openlibrary for the cover ''' ''' ask openlibrary for the cover '''
cover_id = cover_blob[0] cover_id = cover_blob[0]
image_name = '%s-M.jpg' % cover_id image_name = '%s-L.jpg' % cover_id
return '%s/b/id/%s' % (self.covers_url, image_name) return '%s/b/id/%s' % (self.covers_url, image_name)

View file

@ -67,11 +67,15 @@ input.toggle-control:checked ~ .modal.toggle-content {
width: max-content; width: max-content;
max-width: 250px; max-width: 250px;
} }
.cover-container.is-large {
height: 500px;
max-width: 500px;
}
.cover-container.is-medium { .cover-container.is-medium {
height: 150px; height: 200px;
} }
.cover-container.is-small { .cover-container.is-small {
height: 100px; height: 150px;
} }
@media only screen and (max-width: 768px) { @media only screen and (max-width: 768px) {
.cover-container { .cover-container {

View file

@ -0,0 +1,97 @@
{% extends 'layout.html' %}
{% load bookwyrm_tags %}
{% block content %}
<div class="block">
<h1 class="title has-text-centered">{{ site.name }}: Social Reading and Reviewing</h1>
</div>
<section class="tile is-ancestor">
<div class="tile is-7 is-parent">
<div class="tile is-child block">
{% include 'snippets/about.html' %}
</div>
</div>
<div class="tile is-5 is-parent">
<div class="tile is-child box has-background-primary-light">
{% if site.allow_registration %}
<h2 class="title">Join {{ site.name }}</h2>
<form name="register" method="post" action="/user-register">
{% include 'snippets/register_form.html' %}
</form>
{% else %}
<h2 class="title">This instance is closed</h2>
<p>Contact an administrator to get an invite</p>
{% endif %}
</div>
</div>
</section>
<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">
<div class="columns">
<div class="column is-narrow">
{% include 'snippets/book_cover.html' with book=books.2 size="large" %}
{% include 'snippets/stars.html' with rating=books.2.review__rating__avg %}
</div>
<div class="column">
{% include 'snippets/book_titleby.html' with book=books.2 %}
<blockquote class="content">{{ books.2|book_description|to_markdown|safe|truncatewords_html:50 }}</blockquote>
</div>
</div>
</div>
</div>
<div class="tile">
<div class="tile is-parent is-6">
<div class="tile is-child box has-background-white-ter">
{% include 'snippets/book_cover.html' with book=books.0 %}
{% include 'snippets/book_titleby.html' with book=books.0 %}
{% include 'snippets/stars.html' with rating=books.0.review__rating__avg %}
</div>
</div>
<div class="tile is-parent is-6">
<div class="tile is-child box has-background-white-ter">
{% include 'snippets/book_cover.html' with book=books.1 %}
{% include 'snippets/book_titleby.html' with book=books.1 %}
{% include 'snippets/stars.html' with rating=books.1.review__rating__avg %}
</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 'snippets/book_cover.html' with book=books.4 %}
{% include 'snippets/book_titleby.html' with book=books.4 %}
{% include 'snippets/stars.html' with rating=books.4.review__rating__avg %}
</div>
</div>
<div class="tile is-parent is-6">
<div class="tile is-child box has-background-white-ter">
{% include 'snippets/book_cover.html' with book=books.5 %}
{% include 'snippets/book_titleby.html' with book=books.5 %}
{% include 'snippets/stars.html' with rating=books.5.review__rating__avg %}
</div>
</div>
</div>
<div class="tile is-parent">
<div class="tile is-child box has-background-white-ter">
<div class="columns">
<div class="column is-narrow">
{% include 'snippets/book_cover.html' with book=books.3 size="large" %}
{% include 'snippets/stars.html' with rating=books.3.review__rating__avg %}
</div>
<div class="column">
{% include 'snippets/book_titleby.html' with book=books.3 %}
<blockquote class="content">{{ books.3|book_description|to_markdown|safe|truncatewords_html:50 }}</blockquote>
</div>
</div>
</div>
</div>
</div>
</section>
{% endblock %}

View file

@ -119,10 +119,28 @@
</div> </div>
{% else %} {% else %}
<div class="navbar-item"> <div class="navbar-item">
<div class="buttons"> <div class="columns">
<a href="/login" class="button is-primary"> <div class="column">
Join <form name="login" method="post" action="/user-login">
</a> <div class="field is-grouped">
<div class="control">
<label class="is-sr-only" for="id_username">Username:</label>
<input type="text" name="username" maxlength="150" class="input" required="" id="id_username" placeholder="username">
</div>
<div class="control">
<label class="is-sr-only" for="id_password">Username:</label>
<input type="password" name="password" maxlength="128" class="input" required="" id="id_password" placeholder="password">
<p class="help"><a href="/password-reset">Forgot your password?</a></p>
</div>
<button class="button is-primary" type="submit">Log in</button>
</div>
</form>
</div>
<div class="column is-narrow">
<a href="/login" class="button is-link">
Join
</a>
</div>
</div> </div>
</div> </div>
{% endif %} {% endif %}

View file

@ -1,7 +1,12 @@
<h1 class="title">About {{ site.name }}</h1> <div class="columns">
<div class="block"> <div class="column is-narrow">
<img src="/static/images/logo.png" alt="BookWyrm"> <figure class="block">
<img src="/static/images/logo.png" alt="BookWyrm">
</figure>
</div>
<div class="content">
<p class="block">
{{ site.instance_description | safe }}
</p>
</div>
</div> </div>
<p class="block">
{{ site.instance_description }}
</p>

View file

@ -52,6 +52,7 @@ urlpatterns = [
path('', views.home), path('', views.home),
re_path(r'^(?P<tab>home|local|federated)/?$', views.home_tab), re_path(r'^(?P<tab>home|local|federated)/?$', views.home_tab),
re_path(r'^discover/?$', views.discover_page),
re_path(r'^notifications/?$', views.notifications_page), re_path(r'^notifications/?$', views.notifications_page),
re_path(r'^direct-messages/?$', views.direct_messages_page), re_path(r'^direct-messages/?$', views.direct_messages_page),
re_path(r'^import/?$', views.import_page), re_path(r'^import/?$', views.import_page),

View file

@ -4,7 +4,7 @@ import re
from django.contrib.auth.decorators import login_required, permission_required from django.contrib.auth.decorators import login_required, permission_required
from django.contrib.postgres.search import TrigramSimilarity from django.contrib.postgres.search import TrigramSimilarity
from django.core.paginator import Paginator from django.core.paginator import Paginator
from django.db.models import Avg, Q from django.db.models import Avg, Count, Q
from django.db.models.functions import Greatest from django.db.models.functions import Greatest
from django.http import HttpResponseNotFound, JsonResponse from django.http import HttpResponseNotFound, JsonResponse
from django.core.exceptions import PermissionDenied from django.core.exceptions import PermissionDenied
@ -131,6 +131,26 @@ def get_suggested_books(user, max_books=5):
return suggested_books return suggested_books
@require_GET
def discover_page(request):
''' tiled book activity page '''
books = models.Edition.objects.exclude(
cover__exact=''
).annotate(
Count('review')
).annotate(
Avg('review__rating')
).order_by('-review__count')
data = {
'title': 'Discover',
'login_form': forms.LoginForm(),
'register_form': forms.RegisterForm(),
'books': books
}
return TemplateResponse(request, 'discover.html', data)
@login_required @login_required
@require_GET @require_GET
def direct_messages_page(request, page=1): def direct_messages_page(request, page=1):