This is the documentation for the current development code. Choose a version from the menu to see documentation for released versions since v0.7.5.

Developer Environment

Pré-requisitos

Estas instruções supoem que você esteja rodando a BookWyrm utilizando o Docker. Você vai precisar instalar o Docker e o docker-compose para começar.

Configurando o ambiente de desenvolvimento

Get the code

  1. Faça uma cópia do código da BookWyrm no GitHub. Você pode criar uma bifurcação (fork) do repositório e então usar git clone pra baixar o código para seu computador.
  2. Vá ao diretório onde o código foi baixado no seu computador; você trabalhará a partir dele daqui em diante.
  3. Configure as variáveis do seu ambiente de trabalho copiando o arquivo de ambiente de exemplo (.env.example) e renomeando o arquivo para .env. Na linha de comando, você pode fazer assim:
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. In the command line, run:
./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".

Se estiver curiosa: o comando ./bw-dev é um shell script simples que executa várias ferramentas: no exemplo acima, você poderia pular o script e executar docker-compose build ou docker-compose up diretamente, se preferir. ./bw-dev só junta esses comandos em um só, por conveniência. 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!

Editando e criando Modelos (Models)

Se você quiser editar ou criar um modelo, você provavelmente vai alterar a estrutura do banco de dados. Para que essas alterações funcionem, você precisará executar o comando makemigrations do Django para criar um novo arquivo de migrações do Django e então migrá-lo:

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

Editando arquivos estáticos

Toda vez que você alterar o CSS ou o JavaScript, você precisará rodar o comando collectstaticdo Django para que as alterações passem a funcionar:

./bw-dev collectstatic

Se você tiver o yarn instalado, você pode executar yarn watch:static para executar automaticamente o script toda vez que houver alguma mudança no diretório bookwyrm/static.