Expands about pages

This commit is contained in:
Mouse Reeve 2022-01-05 21:42:41 -08:00
parent 69bd9246dd
commit b855464396
11 changed files with 222 additions and 50 deletions

View file

@ -0,0 +1,111 @@
{% extends 'about/layout.html' %}
{% load i18n %}
{% load utilities %}
{% block title %}
{% trans "About" %}
{% endblock %}
{% block about_content %}
<section class="block content pb-4">
<p class="subtitle notification has-background-primary-light">
{% blocktrans trimmed with site_name=site.name %}
{{ site_name }} is part of BookWyrm, a network of independent, self-directed communites for readers.
While you can interact seemlessly with users anywhere in the <a href="https://joinbookwyrm.com/instances/" target="_blank">BookWyrm network</a>, this community is unique.
{% endblocktrans %}
</p>
<div class="columns">
<div class="column is-one-third">
<div class="media notification">
<div class="media-left">
<a href="{{ book.local_path }}">
{% include 'snippets/book_cover.html' with book=top_rated cover_class='is-h-m' size='medium' aria='show' %}
</a>
</div>
<div class="media-content">
{% blocktrans trimmed with title=top_rated|book_title site_name=site.name rating=top_rated.rating|floatformat:1 %}
<em>{{ title }}</em> is {{ site_name }}'s most beloved book, with a {{ rating }} rating out of 5
{% endblocktrans %}
</div>
</div>
</div>
<div class="column is-one-third">
<div class="media notification">
<div class="media-left">
<a href="{{ book.local_path }}">
{% include 'snippets/book_cover.html' with book=wanted cover_class='is-h-m' size='medium' aria='show' %}
</a>
</div>
<div class="media-content">
{% blocktrans trimmed with title=wanted|book_title site_name=site.name %}
More {{ site_name }} users want to read <em>{{ title }}</em>
{% endblocktrans %}
</div>
</div>
</div>
<div class="column is-one-third">
<div class="media notification">
<div class="media-left">
<a href="{{ book.local_path }}">
{% include 'snippets/book_cover.html' with book=controversial cover_class='is-h-m' size='medium' aria='show' %}
</a>
</div>
<div class="media-content">
{% blocktrans trimmed with title=controversial|book_title site_name=site.name %}
<em>{{ title }}</em> has the most divisive ratings of any book on {{ site_name }}
{% endblocktrans %}
</div>
</div>
</div>
</div>
<p>
Join/request an invite to track your reading, share your thoughts, and discover what to read next on {{ site.name }}.
</p>
</section>
<section class="block">
<header class="content">
<h2 class="title is-3">{% trans "Meet your admins" %}</h2>
<p>
these nice people run your instance, when you have a problem, talk to them. when you make a report, they are the ones that receive it
</p>
</header>
<div class="columns is-multiline">
{% for user in admins %}
<div class="column">
<div class="card is-stretchable">
{% with role=user.groups.first.name %}
<div class="card-header {% if role == "moderator" %}has-background-info-light{% else %}has-background-success-light{% endif %}">
<span class="card-header-title is-size-7 pt-1 pb-1">
{% if role == "moderator" %}
{% trans "Moderator" %}
{% else %}
{% trans "Admin" %}
{% endif %}
</span>
</div>
{% endwith %}
<div class="cord-content p-5">
{% include 'user/user_preview.html' with user=user %}
</div>
{% if request.user.is_authenticated and user.id != request.user.id %}
<div class="has-background-white-bis card-footer">
<div class="card-footer-item">
{% include 'snippets/follow_button.html' with user=user minimal=True %}
</div>
<div class="card-footer-item">
<a href="{% url 'direct-messages-user' user|username %}">{% trans "Send direct message" %}</a>
</div>
</div>
{% endif %}
</div>
</div>
{% endfor %}
</div>
</section>
{% endblock %}

View file

@ -0,0 +1,15 @@
{% extends 'about/layout.html' %}
{% load i18n %}
{% block title %}{% trans "Code of Conduct" %}{% endblock %}
{% block about_content %}
<div class="block content">
<h2>{% trans "Code of Conduct" %}</h2>
<div class="content">
{{ site.code_of_conduct | safe }}
</div>
</div>
{% endblock %}

View file

@ -0,0 +1,37 @@
{% extends 'landing/layout.html' %}
{% load i18n %}
{% block about_panel %}
{% endblock %}
{% block panel %}
<div class="block columns pt-4">
<nav class="menu column is-one-quarter">
<h2 class="menu-label">{% blocktrans with site_name=site.name %}About {{ site_name }}{% endblocktrans %}</h2>
<ul class="menu-list">
<li>
{% url 'about' as path %}
<a href="{{ path }}" {% if request.path in path %}class="is-active"{% endif %}>
{% trans "About" %}
</a>
</li>
<li>
{% url 'conduct' as path %}
<a href="{{ path }}" {% if request.path in path %}class="is-active"{% endif %}>
{% trans "Code of Conduct" %}
</a>
</li>
<li>
{% url 'privacy' as path %}
<a href="{{ path }}" {% if request.path in path %}class="is-active"{% endif %}>
{% trans "Privacy Policy" %}
</a>
</li>
</ul>
</nav>
<div class="column">
{% block about_content %}{% endblock %}
</div>
</div>
{% endblock %}

View file

@ -0,0 +1,15 @@
{% extends 'about/layout.html' %}
{% load i18n %}
{% block title %}{% trans "Privacy Policy" %}{% endblock %}
{% block about_content %}
<div class="block">
<h2 class="title">{% trans "Privacy Policy" %}</h2>
<div class="content">
{{ site.privacy_policy | safe }}
</div>
</div>
{% endblock %}

View file

@ -1,37 +0,0 @@
{% extends 'landing/layout.html' %}
{% load i18n %}
{% block panel %}
<div class="block columns mt-4">
<nav class="menu column is-one-quarter">
<h2 class="menu-label">{% blocktrans with site_name=site.name %}About {{ site_name }}{% endblocktrans %}</h2>
<ul class="menu-list">
<li>
<a href="#coc">{% trans "Code of Conduct" %}</a>
</li>
<li>
<a href="#privacy">{% trans "Privacy Policy" %}</a>
</li>
</ul>
</nav>
<div class="column content">
<div class="block" id="coc">
<h2 class="title">{% trans "Code of Conduct" %}</h2>
<div class="content">
{{ site.code_of_conduct | safe }}
</div>
</div>
<hr aria-hidden="true">
<div class="block" id="privacy">
<h2 class="title">{% trans "Privacy Policy" %}</h2>
<div class="content">
{{ site.privacy_policy | safe }}
</div>
</div>
</div>
</div>
{% endblock %}

View file

@ -31,6 +31,7 @@
</div>
</section>
{% block about_panel %}
<section class="tile is-ancestor">
<div class="tile is-7 is-parent">
<div class="tile is-child box">
@ -89,6 +90,7 @@
{% endif %}
</div>
</section>
{% endblock %}
{% block panel %}{% endblock %}

View file

@ -2,7 +2,7 @@
<div class="columns">
<div class="column is-narrow is-hidden-mobile">
<figure class="block is-w-xl">
<figure class="block is-w-{% if size %}{{ size }}{% else %}xl{% endif %}">
<img src="{% if site.logo %}{% get_media_prefix %}{{ site.logo }}{% else %}{% static "images/logo.png" %}{% endif %}" alt="BookWyrm logo">
</figure>
</div>

View file

@ -197,7 +197,9 @@ urlpatterns = [
),
re_path(r"^report/?$", views.make_report, name="report"),
# landing pages
re_path(r"^about/?$", views.About.as_view(), name="about"),
re_path(r"^about/?$", views.about, name="about"),
re_path(r"^privacy/?$", views.privacy, name="privacy"),
re_path(r"^conduct/?$", views.conduct, name="conduct"),
path("", views.Home.as_view(), name="landing"),
re_path(r"^discover/?$", views.Discover.as_view(), name="discover"),
re_path(r"^notifications/?$", views.Notifications.as_view(), name="notifications"),

View file

@ -34,7 +34,7 @@ from .books.edit_book import EditBook, ConfirmEditBook
from .books.editions import Editions, switch_edition
# landing
from .landing.landing import About, Home, Landing
from .landing.landing import Home, Landing, about, privacy, conduct
from .landing.login import Login, Logout
from .landing.register import Register, ConfirmEmail, ConfirmEmailCode, resend_link
from .landing.password import PasswordResetRequest, PasswordReset

View file

@ -160,7 +160,7 @@ def get_landing_books():
models.Edition.objects.filter(
review__published_date__isnull=False,
review__deleted=False,
review__user__local=True,
#review__user__local=True,
review__privacy__in=["public", "unlisted"],
)
.exclude(cover__exact="")

View file

@ -1,21 +1,48 @@
""" non-interactive pages """
from django.db.models import Avg, StdDev, Count, Q
from django.template.response import TemplateResponse
from django.views import View
from django.views.decorators.http import require_GET
from bookwyrm import forms
from bookwyrm import forms, models
from bookwyrm.views import helpers
from bookwyrm.views.feed import Feed
@require_GET
def about(request):
"""more information about the instance"""
books = models.Edition.objects.exclude(
cover__exact=""
).annotate(
rating=Avg("review__rating"),
deviation=StdDev("review__rating"),
shelf_count=Count("shelves", filter=Q(shelves__identifier="to-read")),
)
data = {
"admins": models.User.objects.filter(groups__name__in=["admin", "moderator"]),
"top_rated": books.order_by("rating").first(),
"controversial": books.order_by("deviation").first(),
"wanted": books.order_by("shelf_count").first(),
}
return TemplateResponse(request, "about/about.html", data)
@require_GET
def conduct(request):
"""more information about the instance"""
return TemplateResponse(request, "about/conduct.html")
@require_GET
def privacy(request):
"""more information about the instance"""
return TemplateResponse(request, "about/privacy.html")
# pylint: disable= no-self-use
class About(View):
"""create invites"""
def get(self, request):
"""more information about the instance"""
return TemplateResponse(request, "landing/about.html")
class Home(View):
"""landing page or home feed depending on auth"""