Better docs

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

Nicer docs

No 3rd stage

Add mix.deps get before docs

Add :ex_doc on test env so that it runs into CI
This commit is contained in:
Thomas Citharel
2019-03-14 15:00:34 +01:00
parent c20eaa379c
commit bba6629046
19 changed files with 772 additions and 150 deletions

View File

@@ -0,0 +1,53 @@
# Development
Clone the repo, and start the project trough Docker. You'll need both Docker and Docker-Compose.
```bash
git clone https://framagit.org/framasoft/mobilizon && cd mobilizon
make
```
## Manual
### Server
* Install dependencies:
* Elixir (and Erlang) by following the instructions at [https://elixir-lang.github.io/install.html](https://elixir-lang.github.io/install.html)
* Fetch backend Elixir dependencies with `mix deps.get`.
* [PostgreSQL]() with PostGIS
* Start services:
* Start postgres
* Setup services:
* Make sure the postgis extension is installed on your system.
* Create a postgres user with database creation capabilities, using the
following: `createuser -d -P mobilizon` and set `mobilizon` as the password.
* Create your database with `mix ecto.create`.
* Create the postgis extension on the database with a postgres user that has
superuser capabilities: `psql mobilizon_dev`
``` create extension if not exists postgis; ```
* Run migrations: `mix ecto.migrate`.
* Start Phoenix endpoint with `mix phx.server`.
Now you can visit [`localhost:4000`](http://localhost:4000) from your browser
and see the website (server *and* client) in action.
### Client
If you plan to specifically change the client side (frontend), do the following
once the server is running:
* Install the NodeJS (we guarantee support for the latest LTS and later) ![](https://img.shields.io/badge/node-%3E%3D%2010.0+-brightgreen.svg)
* Change directory to `js/` and do:
* Install JavaScript package dependencies: `npm install`.
* Run the developement server in watch mode: `npm run dev`. This will open a
browser on [`localhost:8080`](http://localhost:8080) that gets
automatically reloaded on change.
## Docker
You need to install the latest supported [Docker](https://docs.docker.com/install/#supported-platforms) and [Docker-Compose](https://docs.docker.com/compose/install/) before using the Docker way of installing Mobilizon.
Just run :
```bash
make start
```
to start a database container, an API container and the front-end dev container running on localhost.

View File

@@ -0,0 +1,16 @@
# Styleguide
# Elixir
We format our code with the Elixir Formatter and check for issues with [Credo](https://github.com/rrrene/credo) (a few rules are not blocking).
Please run those two commands before pushing code :
* `mix format`
* `mix credo`
These two commands must not return an error code, since they are required to pass inside CI.
# Front
We use `tslint` with the `tslint-config-airbnb` preset.
Errors should be reported when running in dev mode `npm run dev` or when building a production bundle `npm run build`.

View File

@@ -0,0 +1,36 @@
# Tests
## Backend
The backend uses `ExUnit`.
To launch all the tests:
```bash
mix test
```
If you want the coverage:
```bash
mix coveralls.html
```
It will show the coverage and will output a `cover/excoveralls.html` file.
If you want to test a single file:
```bash
mix test test/mobilizon/actors/actors_test.exs
```
If you want to test a specific test, block or line:
```bash
mix test test/mobilizon/actors/actors_test.exs:85
```
> Note: The coveralls.html also works the same
## Front-end
Waiting for [https://framagit.org/framasoft/mobilizon/merge_requests/42](https://framagit.org/framasoft/mobilizon/merge_requests/42) to be ready.

View File

@@ -0,0 +1,52 @@
# Dependencies
- [Debian / Ubuntu and derivatives](#debian--ubuntu-and-derivatives)
- [Arch Linux](#arch-linux)
- [Other distributions](#other-distributions)
## Debian / Ubuntu and derivatives
1. On a fresh Debian/Ubuntu, as root user, install basic utility programs needed for the installation
```
sudo apt-get install curl sudo unzip vim
```
2. It would be wise to disable root access and to continue this tutorial with a user with sudoers group access
3. Install certbot (choose instructions for nginx and your distribution) :
[https://certbot.eff.org/all-instructions](https://certbot.eff.org/all-instructions)
4. Install NodeJS 10.x (current LTS):
[https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions](https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions)
5. Install Erlang and Elixir:
[https://elixir-lang.org/install.html#unix-and-unix-like](https://elixir-lang.org/install.html#unix-and-unix-like)
6. Install PostGIS:
[https://postgis.net/install/](https://postgis.net/install/)
6. Run:
```
sudo apt update
sudo apt install nginx postgresql postgresql-contrib openssl make git esl-erlang elixir postgis
```
Now that dependencies are installed, before running MobiliZon you should start PostgreSQL:
```
sudo systemctl start postgresql
```
## Arch Linux
1. Run:
```
sudo pacman -S nodejs postgresql openssl git wget unzip base-devel npm nginx elixir postgis
```
Now that dependencies are installed, before running MobiliZon you should start PostgreSQL and Redis:
```
sudo systemctl start postgresql
```
## Other distributions
Feel free to update this file in a pull request!

View File

@@ -0,0 +1,15 @@
# Docker
You can quickly get a server running using Docker. You'll need both [Docker](https://www.docker.com/community-edition) and [Docker-Compose](https://docs.docker.com/compose/install/).
Start by cloning the repo
```bash
git clone https://framagit.org/framasoft/mobilizon && cd mobilizon
```
Then, just run `make` to build containers.
```bash
make
```
This will start a database container, an API container and the front-end container running on localhost.

View File

@@ -0,0 +1,131 @@
# Install
## Dependencies
Follow the steps of the [dependencies guide](dependencies.html)
## Database
Create the production database and a mobilizon user inside PostgreSQL:
```bash
sudo -u postgres createuser -P mobilizon
sudo -u postgres createdb -O mobilizon mobilizon_prod
```
Then enable extensions PeerTube needs:
```bash
sudo -u postgres psql -c "CREATE EXTENSION postgis;" mobilizon_prod
sudo -u postgres psql -c "CREATE EXTENSION pg_trgm;" mobilizon_prod
sudo -u postgres psql -c "CREATE EXTENSION unaccent;" mobilizon_prod
```
## MobiliZon user
Create a `mobilizon` user with `/home/mobilizon` home:
```bash
sudo adduser --disabled-login mobilizon
sudo -i -u mobilizon
```
**On FreeBSD**
```bash
sudo pw useradd -n mobilizon -d /home/mobilizon -s /usr/local/bin/bash -m
sudo passwd mobilizon
```
You can now fetch the code with git:
```bash
git clone https://framagit.org/framasoft/mobilizon live && cd live
```
## Configuration
### Backend
Install Elixir dependencies
```bash
mix deps.get
```
Configure your instance with
```bash
mix mobilizon.instance gen
```
This will ask you questions about your instance and generate an `.env.prod` file.
### Migration
Run database migrations: `mix ecto.migrate`. You will have to do this again after most updates.
> If some migrations fail, it probably means you're not using a recent enough version of PostgreSQL,
or that you didn't installed [the required extensions](#database).
### Front-end
Go into the `js/` directory
```bash
cd js/
```
and install the Javascript dependencies
```bash
npm install
```
Finally, build the front-end with
```bash
npm run build
```
### Testing
Go back to the previous directory
```bash
cd ../
```
Now try to run the server
```bash
mix phx.server
```
It runs on port 4000.
## Services
### Systemd
Copy the `support/systemd/mobilizon.service` to `/etc/systemd/system`.
```bash
sudo cp support/systemd/mobilizon.service /etc/systemd/system/
```
Reload Systemd to detect your new file
```bash
sudo systemctl daemon-reload
```
And enable the service
```bash
systemctl enable --now mobilizon.service
```
It will run MobiliZon and enable startup on boot. You can follow the logs with
```bash
sudo journalctl -fu mobilizon.service
```

View File

@@ -0,0 +1,64 @@
# Mobilizon
<p align="center">
<a href="https://joinmobilizon.org">
<img src="http://lutim.cpy.re/m9Y8rXRU.png" alt="Mobilizon">
</a>
</p>
MobiliZon is your federated organization and mobilization platform. Gather people with a convivial, ethical, and emancipating tool.
<p align="center">
<strong>Developed with ♥ by <a href="https://framasoft.org">Framasoft</a></strong>
</p>
<p align="center">
<a href="https://framasoft.org">
<img width="150px" src="http://lutim.cpy.re/Prd3ci7G.png" alt="Framasoft logo"/>
</a>
</p>
## Introduction
Mobilizon is a tool designed to create platforms for managing communities and events. Its purpose is to help as many people as possible to free themselves from Facebook groups and events, from Meetup, etc.
The MobiliZon software is under a Free licence, so anyone can host a MobiliZon server, called an instance. These instances may federate with each other, so any person with an account on *ExampleMeet* will be able to register to an event created on *SpecimenEvent*.
## ✨ Features
### 👤 Identities
Do you want to separate your family gatherings from your associative activities or militant mobilizations?
You will have the power to create multiple identities from the same account, like so many social masks.
---
### 📅 Events and groups
Create your events and make sure they will appeal to everybody.
Privacy settings and participants roles are supported.
There's no lock-in, you can interact with the event without registration.
---
## Contributing
We appreciate any contribution to MobiliZon. Check our [CONTRIBUTING](contributing.html) file for more information.
## Links
### Learn more
* 🌐 Official website: [https://joinmobilizon.org](https://joinmobilizon.org)
* 💻 Source: [https://framagit.org/framasoft/mobilizon](https://framagit.org/framasoft/mobilizon)
* 📝 Wiki: [https://framagit.org/framasoft/mobilizon/wikis/home](https://framagit.org/framasoft/mobilizon/wikis/home)
### Discuss
* 💬 Matrix: `#Mobilizon:matrix.org` [Riot](https://riot.im/app/#/room/#Mobilizon:matrix.org)
* #⃣ IRC `#mobilizon` on Freenode
* 🗣️ Forum: [https://framacolibri.org/c/mobilizon](https://framacolibri.org/c/mobilizon)
### Follow
* 🐘 Mastodon: [https://framapiaf.org/@mobilizon](https://framapiaf.org/@mobilizon)
* 🐦 Twitter [https://twitter.com/@joinmobilizon](https://twitter.com/@joinmobilizon)
Note: Most federation code comes from [Pleroma](https://pleroma.social), which is `Copyright © 2017-2018 Pleroma Authors - AGPL-3.0`

View File

@@ -0,0 +1,57 @@
# default nginx site config for Mobilizon
#
# Simple installation instructions:
# 1. Install your TLS certificate, possibly using Let's Encrypt.
# 2. Replace 'example.tld' with your instance's domain wherever it appears.
# 3. Copy this file to /etc/nginx/sites-available/ and then add a symlink to it
# in /etc/nginx/sites-enabled/ and run 'nginx -s reload' or restart nginx.
server {
server_name example.tld;
listen 80;
listen [::]:80;
return 301 https://$server_name$request_uri;
}
server {
server_name example.tld;
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_session_timeout 5m;
ssl_trusted_certificate /etc/letsencrypt/live/example.tld/fullchain.pem;
ssl_certificate /etc/letsencrypt/live/example.tld/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.tld/privkey.pem;
# Add TLSv1.3 if it's supported by your system
ssl_protocols TLSv1.2;
ssl_ciphers 'EECDH+aRSA+AESGCM:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH:+CAMELLIA256:+AES256:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!ECDSA';
ssl_prefer_server_ciphers on;
ssl_ecdh_curve prime256v1;
# ssl_ecdh_curve X25519:prime256v1:secp384r1:secp521r1;
ssl_stapling on;
ssl_stapling_verify on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript application/activity+json application/atom+xml;
# the nginx default is 1m, not enough for large media uploads
client_max_body_size 16m;
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_pass http://localhost:4000;
client_max_body_size 16m;
}
}