Placeholder discover books page

This commit is contained in:
Mouse Reeve 2020-03-16 17:45:34 -07:00
parent c8a65ae6e1
commit b1ad8ba317
4 changed files with 43 additions and 1 deletions

View file

@ -178,6 +178,17 @@ ul.menu a {
flex-grow: 0;
width: max-content;
}
.row.wrap {
flex-wrap: wrap;
}
.book-grid .book-cover {
height: 11em;
width: auto;
}
.book-grid > * {
margin-bottom: 2em;
}
.follow-requests .row {
margin-bottom: 0.5em;

View file

@ -0,0 +1,17 @@
{% extends 'layout.html' %}
{% load fr_display %}
{% block content %}
<div class="content-container">
<h2>Recently Added Books</h2>
<div class="book-grid row wrap">
{% for book in books %}
<div class="book-preview">
<a href="{{ book.absolute_id }}">
{% include 'snippets/book_cover.html' with book=book %}
</a>
{% include 'snippets/shelve_button.html' with book=book %}
</div>
{% endfor %}
</div>
</div>
{% endblock %}

View file

@ -30,11 +30,12 @@ urlpatterns = [
# ui views
re_path(r'^login/?$', views.login_page),
# should return a ui view or activitypub json blob as requested
path('', views.home),
re_path(r'^(?P<tab>home|local|federated)/?$', views.home_tab),
re_path(r'^notifications/?', views.notifications_page),
re_path(r'books/?$', views.books_page),
# should return a ui view or activitypub json blob as requested
# users
re_path(r'%s/?$' % user_path, views.user_page),
re_path(r'%s\.json$' % local_user_path, views.user_page),

View file

@ -95,6 +95,19 @@ def home_tab(request, tab):
return TemplateResponse(request, 'feed.html', data)
def books_page(request):
''' discover books '''
recent_books = models.Book.objects.filter(
~Q(shelfbook__shelf__user=request.user)
).order_by(
'-created_date'
)[:50]
data = {
'books': recent_books,
}
return TemplateResponse(request, 'books.html', data)
def login_page(request):
''' authentication '''
# send user to the login page