Merge branch 'main' into production

This commit is contained in:
Mouse Reeve 2020-11-02 14:13:48 -08:00
commit de66d77f4b
5 changed files with 78 additions and 13 deletions

View file

@ -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

View file

@ -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'

View file

@ -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'),

View file

@ -20,7 +20,8 @@
{% endif %}
</div>
{% if status.book or status.mention_books.count %}
{% if not hide_book %}
{% if status.book or status.mention_books.count %}
<div class="{% if status.status_type != 'GeneratedNote' %}box{% endif %}">
{% if status.book %}
{% include 'snippets/book_preview.html' with book=status.book %}
@ -29,3 +30,4 @@
{% endif %}
</div>
{% endif %}
{% endif %}

View file

@ -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',