From efabe22615ccd172452c776b38f1b31c33f3d4e4 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 2 Nov 2020 11:59:03 -0800 Subject: [PATCH 1/4] Adds bookwyrm connector to default database config --- init_db.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/init_db.py b/init_db.py index a7a45c20..e2ade67b 100644 --- a/init_db.py +++ b/init_db.py @@ -68,6 +68,17 @@ Connector.objects.create( priority=1, ) +Connector.objects.create( + identifier='bookwyrm.social', + name='BookWyrm dot Social', + connector_file='bookwyrm_connector', + base_url='https://bookwyrm.social' , + books_url='https://bookwyrm.social/book', + covers_url='https://bookwyrm.social/images/covers', + search_url='https://bookwyrm.social/search?q=', + priority=2, +) + Connector.objects.create( identifier='openlibrary.org', name='OpenLibrary', From 81e207dcf87d799b90c75c2aef08b191d80ebd25 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 2 Nov 2020 13:00:11 -0800 Subject: [PATCH 2/4] Update README.md --- README.md | 66 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 57 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index f2a1b115..71b1a493 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,17 @@ cp .env.example .env For most testing, you'll want to use ngrok. Remember to set the DOMAIN in `.env` to your ngrok domain. + +#### With Docker +You'll have to install the Docker and docker-compose. When you're ready, run: + +```bash +docker-compose build +docker-compose up +docker-compose exec web python manage.py migrate +docker-compose exec web python manage.py shell -c 'import init_db' +``` + ### Without Docker You will need postgres installed and running on your computer. @@ -81,19 +92,56 @@ Initialize the database (or, more specifically, delete the existing database, ru ``` This creates two users, `mouse` with password `password123` and `rat` with password `ratword`. -The application uses Celery and Redis for task management, which must also be configured. (Further instructions pending, sorry! +The application uses Celery and Redis for task management, which must also be installed and configured. And go to the app at `localhost:8000` -#### With Docker -You'll have to install the Docker and docker-compose: -```bash -docker-compose build -docker-compose up -docker-compose exec web python manage.py migrate -docker-compose exec web python manage.py shell -c 'import init_db' -``` + +## Installing in Production + +This project is still young and isn't, at the momoment, very stable, so please procede with caution when running in production. +### Server setup + - Get a domain name and set up DNS for your server + - Set your server up with appropriate firewalls for running a web application (this instruction set is tested again Ubuntu 20.04) + - Set up a mailgun account and the appropriate DNS settings + - Install Docker and docker-compose +### Install and configure BookWyrm + - Get the application code: + `git clone git@github.com:mouse-reeve/bookwyrm.git` + - Switch to the `production` branch + `git checkout production` + - Create your environment variables file + `cp .env.example .env` + - Add your domain, email address, mailgun credentials + - Set a secure redis password and secret key + - Update your nginx configuration in `nginx/defautl.conf` + - Replace `your-domain.com` with your domain name + - Run the application (this should also set up a Certbot ssl cert for your domain) + `docker-compose up --build` + Make sure all the images build successfully + - When docker has built successfully, stop the process with `CTRL-C` + - Comment out the `command: certonly...` line in `docker-compose.yml` + - Run docker-compose in the background + `docker-compose up -d` + - Initialize the database + `./fr-dev initdb` + - Congrats! You did it, go to your domain and enjoy the fruits of your labors +### Configure your instance + - Register a user account in the applcation UI + - Make your account a superuser (warning: do *not* use django's `createsuperuser` command) + - On your server, open the django shell + `./fr-dev shell` + - Load your user and make it a superuser + ```python + from bookwyrm import models + user = models.User.objects.get(id=1) + user.is_admin = True + user.is_staff = True + user.is_superuser = True + user.save() + ``` + - Go to the admin panel (`/admin/bookwyrm/sitesettings/1/change` on your domain) and set your instance name, description, code of conduct, and toggle whether registration is open on your instance ## Project structure From 0c9dff61ca5798b4a46e85976b55fbce895c8aa1 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 2 Nov 2020 13:41:43 -0800 Subject: [PATCH 3/4] Re-adds hiding book in reviews feed --- bookwyrm/templates/snippets/status_content.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bookwyrm/templates/snippets/status_content.html b/bookwyrm/templates/snippets/status_content.html index 595b2642..503290da 100644 --- a/bookwyrm/templates/snippets/status_content.html +++ b/bookwyrm/templates/snippets/status_content.html @@ -20,7 +20,8 @@ {% endif %} -{% if status.book or status.mention_books.count %} +{% if not hide_book %} +{% if status.book or status.mention_books.count %}
{% if status.book %} {% include 'snippets/book_preview.html' with book=status.book %} @@ -29,3 +30,4 @@ {% endif %}
{% endif %} +{% endif %} From c5a215b11d93e220c13c2c29c360963be412fba0 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 2 Nov 2020 14:13:24 -0800 Subject: [PATCH 4/4] Fixes serialization of parent work remote_id --- bookwyrm/activitypub/interaction.py | 4 ++-- bookwyrm/models/book.py | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bookwyrm/activitypub/interaction.py b/bookwyrm/activitypub/interaction.py index 752b2fe3..2da00587 100644 --- a/bookwyrm/activitypub/interaction.py +++ b/bookwyrm/activitypub/interaction.py @@ -8,7 +8,7 @@ from .base_activity import ActivityObject class Like(ActivityObject): ''' a user faving an object ''' actor: str - object: str + object: ActivityObject type: str = 'Like' @@ -16,5 +16,5 @@ class Like(ActivityObject): class Boost(ActivityObject): ''' boosting a status ''' actor: str - object: str + object: ActivityObject type: str = 'Announce' diff --git a/bookwyrm/models/book.py b/bookwyrm/models/book.py index b993ef5e..b6261b8b 100644 --- a/bookwyrm/models/book.py +++ b/bookwyrm/models/book.py @@ -67,6 +67,10 @@ class Book(ActivitypubMixin, BookWyrmModel): url='https://%s%s' % (DOMAIN, self.cover.url), )] + @property + def ap_parent_work(self): + ''' reference the work via local id not remote ''' + return self.parent_work.local_id activity_mappings = [ ActivityMapping('id', 'remote_id'), @@ -89,7 +93,7 @@ class Book(ActivitypubMixin, BookWyrmModel): ActivityMapping('librarything_key', 'librarything_key'), ActivityMapping('goodreads_key', 'goodreads_key'), - ActivityMapping('work', 'parent_work'), + ActivityMapping('work', 'ap_parent_work'), ActivityMapping('isbn_10', 'isbn_10'), ActivityMapping('isbn_13', 'isbn_13'), ActivityMapping('oclc_number', 'oclc_number'),