Developer Environment

Voraussetzungen

Diese Anweisungen gehen davon aus, dass du BookWyrm mit Docker entwickelst. Du musst Docker und docker-compose installieren, um loszulegen.

Entwicklungsumgebung einrichten

Get the code

  1. Kopiere die der BookWyrm-Codebasis von GitHub. Du kannst einen Fork des Projekts erstellen und verwende dann git clone, um den Code auf deinen Computer herunterzuladen.
  2. Gehe in das Verzeichnis, das den Code auf Ihrem Computer enthält. Du arbeitest von hier aus.
  3. Richte deine Datei für Entwicklungsumgebungsvariablen durch Kopieren der Beispielumgebungsdatei (.env.example) in eine neue Datei namens .env ein. In der Kommandozeile kannst du das wie folgt tun:
cp .env.example .env

Configure your environment settings

In .env:

  1. change DEBUG to true
  2. If you use a tunneling/proxy service like ngrok, set DOMAIN to to the domain name you are using (e.g. abcd-1234.ngrok-free.app). Otherwise, set DOMAIN to localhost
  3. change NGINX_SETUP to reverse_proxy (this prevents BookWyrm trying to set up https certificates on your development machine)
  4. If you need to use a particular port (e.g. if you are tunneling via ngrok), uncomment PORT and set it (e.g. PORT=1333). If using localhost this is optional.

If you try to register your admin account and see a message that CSRF verification failed, you should check these settings, as you may have set your domain or port incorrectly.

Email (optional)

If you want to test sending emails, you will need to set up appropriate values in the "Email config" section. You do not need to change anything for the separate EMAIL setting.

Build and run

  1. Führe Folgendes über die Kommandozeile aus:
./bw-dev build            # Build the docker images
./bw-dev setup            # Initialize the database and run migrations. Note the ADMIN key at the end of this output. You'll need it to register the first admin user.
./bw-dev up               # Start the docker containers
  1. Once the build is complete, you can access the instance at http://localhost, your ngrok domain, or http://localhost:{PORT}, depending on you domain and port configuration.
  2. You can now enter your admin key and create an admin user. From here everything is the same as described in "Running BookWyrm".

Wenn du neugierig bist: das ./bw-dev Kommando ist ein simples Shell-Script, das verschiedene Tools ansteuert: darüber hinaus könntest du es überspringen und direk docker-compose build oder docker-compose up laufen lassen, wenn du magst. ./bw-dev sammelt sie einfach an einem gemeinsamen Ort zur Bequemlichkeit. Run it without arguments to get a list of available commands, read the documentation page for it, or open it up and look around to see exactly what each command is doing!

Modelle editieren oder erstellen

Wenn du ein Modell änderst oder erstellst, wird sich wahrscheinlich die Datenbankstruktur ändern. Damit diese Änderungen wirksam werden, musst du Djangos makemigrations-Befehl ausführen, um eine neue Django Migrationsdateizu erstellen und dann diese migrieren:

./bw-dev makemigrations
./bw-dev migrate

Statische Dateien editieren

Jedes Mal, wenn du CSS oder JavaScript bearbeitest, musst du Djangos collectstatic-Befehl erneut ausführen, damit deine Änderungen wirksam werden:

./bw-dev collectstatic

Wenn du yarn installierstt haben, kannst du yarn watch:static ausführen, um das vorherige Skript bei jeder Änderung automatisch im Verzeichnis bookwyrm/static auszuführen.