From 4caa68200ffa44b381a0b44ba4507459ab4e2f76 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Thu, 6 Jan 2022 09:04:59 -0800 Subject: [PATCH] Adds more info to the about page --- bookwyrm/templates/about/about.html | 11 +++++-- bookwyrm/templates/about/layout.html | 20 ++++++++++++ bookwyrm/templates/user/user_preview.html | 26 +++++++-------- bookwyrm/views/landing/landing.py | 40 +++++++++++++++-------- 4 files changed, 68 insertions(+), 29 deletions(-) diff --git a/bookwyrm/templates/about/about.html b/bookwyrm/templates/about/about.html index 3481f7313..ec5e21407 100644 --- a/bookwyrm/templates/about/about.html +++ b/bookwyrm/templates/about/about.html @@ -1,4 +1,5 @@ {% extends 'about/layout.html' %} +{% load humanize %} {% load i18n %} {% load utilities %} @@ -7,10 +8,14 @@ {% endblock %} {% block about_content %} -
+
+

+ {% blocktrans with site_name=site.name %}Welcome to {{ site_name }}!{% endblocktrans %} +

+

{% blocktrans trimmed with site_name=site.name %} - {{ site_name }} is part of BookWyrm, a network of independent, self-directed communites for readers. + {{ site_name }} is part of BookWyrm, a network of independent, self-directed communities for readers. While you can interact seemlessly with users anywhere in the BookWyrm network, this community is unique. {% endblocktrans %}

@@ -61,7 +66,7 @@

- Join/request an invite to track your reading, share your thoughts, and discover what to read next on {{ site.name }}. + {% trans "Track your reading, talk about books, write reviews, and discover what to read next. Always ad-free, anti-corporate, and community-oriented, BookWyrm is human-scale software, designed to stay small and personal. If you have feature requests, bug reports, or grand dreams, reach out and make yourself heard." %}

diff --git a/bookwyrm/templates/about/layout.html b/bookwyrm/templates/about/layout.html index 82d8aaaee..458e4b1d1 100644 --- a/bookwyrm/templates/about/layout.html +++ b/bookwyrm/templates/about/layout.html @@ -1,7 +1,27 @@ {% extends 'landing/layout.html' %} +{% load humanize %} {% load i18n %} {% block about_panel %} +
+ {% include "snippets/about.html" with size="m" %} + {% if active_users %} +
    +
  • + {% trans "Active users:" %} + {{ active_users|intcomma }} +
  • +
  • + {% trans "Statuses posted:" %} + {{ status_count|intcomma }} +
  • +
  • + {% trans "Software version:" %} + {{ version }} +
  • +
+ {% endif %} +
{% endblock %} {% block panel %} diff --git a/bookwyrm/templates/user/user_preview.html b/bookwyrm/templates/user/user_preview.html index c6b3ea842..c46563e59 100755 --- a/bookwyrm/templates/user/user_preview.html +++ b/bookwyrm/templates/user/user_preview.html @@ -21,23 +21,23 @@

{{ user.username }}

{% blocktrans with date=user.created_date|naturaltime %}Joined {{ date }}{% endblocktrans %}

- {% if is_self %} + {% if request.user.id == user.id %} - {% blocktrans count counter=user.followers.count %}{{ counter }} follower{% plural %}{{ counter }} followers{% endblocktrans %}, - {% blocktrans with counter=user.following.count %}{{ counter }} following{% endblocktrans %} + {% blocktrans count counter=user.followers.count %}{{ counter }} follower{% plural %}{{ counter }} followers{% endblocktrans %}, + {% blocktrans with counter=user.following.count %}{{ counter }} following{% endblocktrans %} {% elif request.user.is_authenticated %} - {% mutuals_count user as mutuals %} - - {% if mutuals %} - {% blocktrans with mutuals_display=mutuals|intcomma count counter=mutuals %}{{ mutuals_display }} follower you follow{% plural %}{{ mutuals_display }} followers you follow{% endblocktrans %} - {% elif request.user in user.following.all %} - {% trans "Follows you" %} - {% else %} - {% trans "No followers you follow" %} - {% endif %} - + {% mutuals_count user as mutuals %} + + {% if mutuals %} + {% blocktrans with mutuals_display=mutuals|intcomma count counter=mutuals %}{{ mutuals_display }} follower you follow{% plural %}{{ mutuals_display }} followers you follow{% endblocktrans %} + {% elif request.user in user.following.all %} + {% trans "Follows you" %} + {% else %} + {% trans "No followers you follow" %} + {% endif %} + {% endif %}

diff --git a/bookwyrm/views/landing/landing.py b/bookwyrm/views/landing/landing.py index d9955dd7a..d37f4c79f 100644 --- a/bookwyrm/views/landing/landing.py +++ b/bookwyrm/views/landing/landing.py @@ -1,10 +1,12 @@ """ non-interactive pages """ +from dateutil.relativedelta import relativedelta from django.db.models import Avg, StdDev, Count, Q from django.template.response import TemplateResponse +from django.utils import timezone from django.views import View from django.views.decorators.http import require_GET -from bookwyrm import forms, models +from bookwyrm import forms, models, settings from bookwyrm.views import helpers from bookwyrm.views.feed import Feed @@ -12,21 +14,33 @@ 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")), - ) - + six_months_ago = timezone.now() - relativedelta(months=6) + six_month_count = models.User.objects.filter( + is_active=True, local=True, last_active_date__gt=six_months_ago + ).count() data = { + "active_users": six_month_count, + "status_count": models.Status.objects.filter( + user__local=True, deleted=False + ).count(), "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(), + "version": settings.VERSION, } + + books = models.Edition.objects.exclude(cover__exact="") + + data["top_rated"] = books.annotate( + rating=Avg("review__rating") + ).order_by("rating").first() + + data["controversial"] = books.annotate( + deviation=StdDev("review__rating") + ).order_by("deviation").first() + + data["wanted"] = books.annotate( + shelf_count=Count("shelves", filter=Q(shelves__identifier="to-read")) + ).order_by("shelf_count").first() + return TemplateResponse(request, "about/about.html", data)