From ef07a797e24a7b44827b816ea0d797bf77da6978 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sun, 21 Mar 2021 14:31:51 -0700 Subject: [PATCH 01/11] Copies over the production README --- README.md | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 10f77c04..e6a75375 100644 --- a/README.md +++ b/README.md @@ -213,17 +213,6 @@ Congrats! You did it, go to your domain and enjoy the fruits of your labors. ``` - Go to the site settings (`/settings/site-settings` on your domain) and configure your instance name, description, code of conduct, and toggle whether registration is open on your instance - -## Book data -The application is set up to share book and author data between instances, and get book data from arbitrary outside sources. Right now, the only connector is to OpenLibrary, but other connectors could be written. - -There are three concepts in the book data model: -- `Book`, an abstract, high-level concept that could mean either a `Work` or an `Edition`. No data is saved as a `Book`, it serves as shared model for `Work` and `Edition` -- `Work`, the theoretical umbrella concept of a book that encompasses every edition of the book, and -- `Edition`, a concrete, actually published version of a book - -Whenever a user interacts with a book, they are interacting with a specific edition. Every work has a default edition, but the user can select other editions. Reviews aggregated for all editions of a work when you view an edition's page. - ### Backups BookWyrm's db service dumps a backup copy of its database to its `/backups` directory daily at midnight UTC. @@ -238,6 +227,15 @@ You can copy backups from the backups volume to your host machine with `docker c - Run `docker-compose ps` to confirm the db service's full name (it's probably `bookwyrm_db_1`. - Run `docker cp :/backups ` +### Updating your instance + +When there are changes available in the production branch, you can install and get them running on your instance using the command `./bw-dev update`. This does a number of things: +- `git pull` gets the updated code from the git repository. If there are conflicts, you may need to run `git pull` separately and resolve the conflicts before trying the `./bw-dev update` script again. +- `docker-compose build` rebuilds the images, which ensures that the correct packages are installed. This step takes a long time and is only needed when the dependencies (including pip `requirements.txt` packages) have changed, so you can comment it out if you want a quicker update path and don't mind un-commenting it as needed. +- `docker-compose exec web python manage.py migrate` runs the database migrations in Django +- `docker-compose exec web python manage.py collectstatic --no-input` loads any updated static files (such as the JavaScript and CSS) +- `docker-compose restart` reloads the docker containers + ### Port Conflicts BookWyrm has multiple services that run on their default ports. @@ -317,3 +315,14 @@ To set up your server: - restart nginx If everything worked correctly, your BookWyrm instance should now be externally accessible. + + +## Book data +The application is set up to share book and author data between instances, and get book data from arbitrary outside sources. Right now, the only connector is to OpenLibrary, but other connectors could be written. + +There are three concepts in the book data model: +- `Book`, an abstract, high-level concept that could mean either a `Work` or an `Edition`. No data is saved as a `Book`, it serves as shared model for `Work` and `Edition` +- `Work`, the theoretical umbrella concept of a book that encompasses every edition of the book, and +- `Edition`, a concrete, actually published version of a book + +Whenever a user interacts with a book, they are interacting with a specific edition. Every work has a default edition, but the user can select other editions. Reviews aggregated for all editions of a work when you view an edition's page. From ad8baa9122e90d3b6b28579f3d6a947ec4ec054f Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sun, 21 Mar 2021 14:32:18 -0700 Subject: [PATCH 02/11] Adds compiled german translations --- locale/de_DE/LC_MESSAGES/django.mo | Bin 24140 -> 26527 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/locale/de_DE/LC_MESSAGES/django.mo b/locale/de_DE/LC_MESSAGES/django.mo index 40fbee8d9c94aee1ae58b831cb6482f9801e9893..61a659d88d5d224d5972244a1911861061102464 100644 GIT binary patch delta 10033 zcmb8!2Xs|czQ^$s=~W=~dPqp4B=i#LJwT`dq;r#dl6%c9;TD1@TogMh%C%uceb}*} zW^BNWDD#|$Is$e?85Kp}2&m6Oah@~Z-#r_JwceVw-dXd{XYYOX*=N_2;Jmpj?Y@0! ziNmex-fnTl(k!bp?rLILKagJBPNkNW+s(3~n1@&67Hp20wq^Ci{@4bWU?+@XU)+cn z;%-z^`>_jtjU`yWyJcltR>E3DLN~5NHFQ5_;Pc4;tb?Zf7wka3B{v6RFI2P31v&1?KU7>je_&6nus)@h7a04YDk&AvVW4*bWG4QMU)$NRAX@3-C|p$86OEBqYm;!mg-ok3Q`YRr5! z!?vjVJ+KAl;Wb!@8o(>4rFaL`fp4)s{sYxsogBA39TTcxlchNw<`){J2KWNI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AkDzjrn>(?TPg*(J{C{XWbu4fR{N49$%JYd_`eD73XC$-Emk6YmjU z5toVgiM1NPf^|b34M!5}!*ty>+>lJ&8=uHf!z6t)9(D5%~O`ybY zJ-bF}L&_gny*@1i-~TsRMIHPP5l*AV#5JoAyi1gaTSwnh&L*BE#u4$v4MHDcd=@#u zv};EEMmdzILHPjgCu$NM$aVZ(KeYdKtwQ-${orUvoezf+*_7*IJz@y)*D;#HqeM62 zb|Qj!fq0X+i%2A1CH_I&NmL=4+gNq*A#(2we(WYD6M0ld6Q5Dmaf!G>Xp+^apNSFJ zl4wA5AkRV_ei!FYj3Js6`c%}>gIKNtN4~ZHf^sbnU8hp9l%zk=hH_Kl8_ItW|0ISH zI=@_qC1)h~XJ_mV_dnckqsQN6fY;+YGVp!hp6nR^x$K@nzIj7h_~M4%;afO# zyT33m%Hw-1Kgqu*zeyF(a9>hxtZ#5Zh;L@WCSUf5H2 Date: Sun, 21 Mar 2021 12:53:30 -0700 Subject: [PATCH 03/11] Lets users opt in to directory --- bookwyrm/migrations/0057_user_discoverable.py | 19 +++++++++++++++++++ bookwyrm/models/user.py | 1 + 2 files changed, 20 insertions(+) create mode 100644 bookwyrm/migrations/0057_user_discoverable.py diff --git a/bookwyrm/migrations/0057_user_discoverable.py b/bookwyrm/migrations/0057_user_discoverable.py new file mode 100644 index 00000000..522f0869 --- /dev/null +++ b/bookwyrm/migrations/0057_user_discoverable.py @@ -0,0 +1,19 @@ +# Generated by Django 3.1.6 on 2021-03-21 21:44 + +import bookwyrm.models.fields +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('bookwyrm', '0056_auto_20210321_0303'), + ] + + operations = [ + migrations.AddField( + model_name='user', + name='discoverable', + field=bookwyrm.models.fields.BooleanField(default=False), + ), + ] diff --git a/bookwyrm/models/user.py b/bookwyrm/models/user.py index 46f08509..84391e10 100644 --- a/bookwyrm/models/user.py +++ b/bookwyrm/models/user.py @@ -103,6 +103,7 @@ class User(OrderedCollectionPageMixin, AbstractUser): last_active_date = models.DateTimeField(auto_now=True) manually_approves_followers = fields.BooleanField(default=False) show_goal = models.BooleanField(default=True) + show_in_directory = models.BooleanField(default=False) name_field = "username" From 3e75253ff179842dc4942f5acb21e49e6d09dd59 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sun, 21 Mar 2021 14:50:36 -0700 Subject: [PATCH 04/11] Updates activitpub and tests for discoverability --- bookwyrm/activitypub/person.py | 2 +- bookwyrm/models/user.py | 2 +- bookwyrm/templates/layout.html | 2 +- bookwyrm/tests/data/ap_user.json | 3 +++ bookwyrm/tests/views/test_inbox.py | 1 + 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bookwyrm/activitypub/person.py b/bookwyrm/activitypub/person.py index f1298b92..dafd1910 100644 --- a/bookwyrm/activitypub/person.py +++ b/bookwyrm/activitypub/person.py @@ -30,5 +30,5 @@ class Person(ActivityObject): icon: Image = field(default_factory=lambda: {}) bookwyrmUser: bool = False manuallyApprovesFollowers: str = False - discoverable: str = True + discoverable: str = False type: str = "Person" diff --git a/bookwyrm/models/user.py b/bookwyrm/models/user.py index 84391e10..c2a74c63 100644 --- a/bookwyrm/models/user.py +++ b/bookwyrm/models/user.py @@ -103,7 +103,7 @@ class User(OrderedCollectionPageMixin, AbstractUser): last_active_date = models.DateTimeField(auto_now=True) manually_approves_followers = fields.BooleanField(default=False) show_goal = models.BooleanField(default=True) - show_in_directory = models.BooleanField(default=False) + discoverable = fields.BooleanField(default=False) name_field = "username" diff --git a/bookwyrm/templates/layout.html b/bookwyrm/templates/layout.html index c7d10b57..b25bef45 100644 --- a/bookwyrm/templates/layout.html +++ b/bookwyrm/templates/layout.html @@ -107,7 +107,7 @@ {% endif %} {% if perms.bookwyrm.create_invites %}
  • - + {% trans 'Invites' %}
  • diff --git a/bookwyrm/tests/data/ap_user.json b/bookwyrm/tests/data/ap_user.json index b159ae65..bc4488e3 100644 --- a/bookwyrm/tests/data/ap_user.json +++ b/bookwyrm/tests/data/ap_user.json @@ -28,6 +28,9 @@ }, "bookwyrmUser": true, "manuallyApprovesFollowers": false, + "discoverable": true, + "devices": "https://friend.camp/users/tripofmice/collections/devices", + "tag": [], "icon": { "type": "Image", "mediaType": "image/png", diff --git a/bookwyrm/tests/views/test_inbox.py b/bookwyrm/tests/views/test_inbox.py index b681b961..10f55f89 100644 --- a/bookwyrm/tests/views/test_inbox.py +++ b/bookwyrm/tests/views/test_inbox.py @@ -789,6 +789,7 @@ class Inbox(TestCase): self.assertEqual(user.name, "MOUSE?? MOUSE!!") self.assertEqual(user.username, "mouse@example.com") self.assertEqual(user.localname, "mouse") + self.assertTrue(user.discoverable) def test_handle_update_edition(self): """ update an existing edition """ From ba00672e66b19987c83897625f8fadd438422955 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sun, 21 Mar 2021 16:37:52 -0700 Subject: [PATCH 05/11] Directory view --- bookwyrm/forms.py | 4 +- bookwyrm/templates/directory.html | 67 +++++++++++++++++++ bookwyrm/templates/edit_author.html | 4 +- bookwyrm/templates/preferences/edit_user.html | 8 +++ bookwyrm/templates/snippets/avatar.html | 2 +- bookwyrm/urls.py | 1 + bookwyrm/views/__init__.py | 1 + bookwyrm/views/directory.py | 32 +++++++++ bookwyrm/views/landing.py | 2 +- 9 files changed, 115 insertions(+), 6 deletions(-) create mode 100644 bookwyrm/templates/directory.html create mode 100644 bookwyrm/views/directory.py diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index d330211c..4e92b32e 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -3,7 +3,6 @@ import datetime from collections import defaultdict from django import forms -from django.core.exceptions import ValidationError from django.forms import ModelForm, PasswordInput, widgets from django.forms.widgets import Textarea from django.utils import timezone @@ -130,8 +129,9 @@ class EditUserForm(CustomForm): "name", "email", "summary", - "manually_approves_followers", "show_goal", + "manually_approves_followers", + "discoverable", ] help_texts = {f: None for f in fields} diff --git a/bookwyrm/templates/directory.html b/bookwyrm/templates/directory.html new file mode 100644 index 00000000..9323752f --- /dev/null +++ b/bookwyrm/templates/directory.html @@ -0,0 +1,67 @@ +{% extends 'layout.html' %} +{% load i18n %} +{% load bookwyrm_tags %} +{% load humanize %} + +{% block title %}{% trans "Directory" %}{% endblock %} + +{% block content %} +
    +

    + {% trans "Directory" %} +

    +
    +
    + {% for user in users %} +
    +
    +
    +
    + + {% include 'snippets/avatar.html' with user=user large=True %} + +
    + + {{ user.display_name }} + @{{ user|username }} + + {% include 'snippets/follow_button.html' with user=user %} +
    +
    + + {% if user.summary %} +
    + {{ user.summary | to_markdown | safe | truncatechars_html:40 }} +
    + {% endif %} +
    +
    + + + +
    +
    +
    + {% endfor %} +
    + +
    + {% include 'snippets/pagination.html' with page=users path="/directory" %} +
    + +{% endblock %} diff --git a/bookwyrm/templates/edit_author.html b/bookwyrm/templates/edit_author.html index 0316a66f..542b57f9 100644 --- a/bookwyrm/templates/edit_author.html +++ b/bookwyrm/templates/edit_author.html @@ -2,11 +2,11 @@ {% load i18n %} {% load humanize %} -{% block title %}{% trans "Edit Author" %}: {{ author.name }}{% endblock %} +{% block title %}{% trans "Edit Author:" %} {{ author.name }}{% endblock %} {% block content %}
    -

    +

    Edit "{{ author.name }}"

    diff --git a/bookwyrm/templates/preferences/edit_user.html b/bookwyrm/templates/preferences/edit_user.html index ca0f81c2..327d745b 100644 --- a/bookwyrm/templates/preferences/edit_user.html +++ b/bookwyrm/templates/preferences/edit_user.html @@ -53,6 +53,14 @@ {{ form.manually_approves_followers }}
    +
    + + {% url 'directory' as path %} +

    {% blocktrans %}Your account will show up in the directory, and may be recommended to other BookWyrm users.{% endblocktrans %}

    +
    {% endblock %} diff --git a/bookwyrm/templates/snippets/avatar.html b/bookwyrm/templates/snippets/avatar.html index 6d27cd85..d53acf2b 100644 --- a/bookwyrm/templates/snippets/avatar.html +++ b/bookwyrm/templates/snippets/avatar.html @@ -1,3 +1,3 @@ {% load bookwyrm_tags %} -{{ user.alt_text }} +{{ user.alt_text }} diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 4aced6fe..76622799 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -96,6 +96,7 @@ urlpatterns = [ path("", views.Home.as_view(), name="landing"), re_path(r"^discover/?$", views.Discover.as_view()), re_path(r"^notifications/?$", views.Notifications.as_view()), + re_path(r"^directory/?", views.Directory.as_view(), name="directory"), # feeds re_path(r"^(?Phome|local|federated)/?$", views.Feed.as_view()), re_path( diff --git a/bookwyrm/views/__init__.py b/bookwyrm/views/__init__.py index 3402e65f..f1ebfc4c 100644 --- a/bookwyrm/views/__init__.py +++ b/bookwyrm/views/__init__.py @@ -4,6 +4,7 @@ from .author import Author, EditAuthor from .block import Block, unblock from .books import Book, EditBook, ConfirmEditBook, Editions from .books import upload_cover, add_description, switch_edition, resolve_book +from .directory import Directory from .error import not_found_page, server_error_page from .federation import Federation from .feed import DirectMessage, Feed, Replies, Status diff --git a/bookwyrm/views/directory.py b/bookwyrm/views/directory.py new file mode 100644 index 00000000..bbfbffe8 --- /dev/null +++ b/bookwyrm/views/directory.py @@ -0,0 +1,32 @@ +""" who all's here? """ +from django.contrib.auth.decorators import login_required +from django.core.paginator import Paginator +from django.template.response import TemplateResponse +from django.views import View +from django.utils.decorators import method_decorator + +from bookwyrm import models + +# pylint: disable=no-self-use +@method_decorator(login_required, name="dispatch") +class Directory(View): + """ display of known bookwyrm users """ + + def get(self, request): + """ lets see your cute faces """ + try: + page = int(request.GET.get("page", 1)) + except ValueError: + page = 1 + + users = models.User.objects.filter( + discoverable=True, + bookwyrm_user=True, + is_active=True, + ).order_by('-last_active_date') + paginated = Paginator(users, 12) + + data = { + "users": paginated.page(page), + } + return TemplateResponse(request, "directory.html", data) diff --git a/bookwyrm/views/landing.py b/bookwyrm/views/landing.py index 86f7d3e9..407451fb 100644 --- a/bookwyrm/views/landing.py +++ b/bookwyrm/views/landing.py @@ -2,7 +2,7 @@ from django.template.response import TemplateResponse from django.views import View -from bookwyrm import forms, models +from bookwyrm import forms from .feed import Feed from . import helpers From 6e3a203b466d24ef02518b1f6aa442801e308364 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sun, 21 Mar 2021 16:43:13 -0700 Subject: [PATCH 06/11] Adds directory to main menu --- bookwyrm/templates/layout.html | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bookwyrm/templates/layout.html b/bookwyrm/templates/layout.html index b25bef45..e57f6152 100644 --- a/bookwyrm/templates/layout.html +++ b/bookwyrm/templates/layout.html @@ -83,18 +83,18 @@