From bba662904625bc3b5849df39b3f4cc6d790e9475 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 14 Mar 2019 15:00:34 +0100 Subject: [PATCH] Better docs Signed-off-by: Thomas Citharel Nicer docs No 3rd stage Add mix.deps get before docs Add :ex_doc on test env so that it runs into CI --- .gitlab-ci.yml | 15 ++ .gitlab/issue_templates/Bug.md | 29 +++ CONTRIBUTING.md | 141 +++++------- README.md | 97 ++++----- lib/mobilizon_web/resolvers/user.ex | 2 +- .../service => service/users}/activation.ex | 4 +- .../users}/reset_password.ex | 4 +- .../users/service => service/users}/tools.ex | 2 +- mix.exs | 200 +++++++++++++++++- support/guides/development/development.md | 53 +++++ support/guides/development/styleguide.md | 16 ++ support/guides/development/tests.md | 36 ++++ support/guides/install/dependencies.md | 52 +++++ support/guides/install/docker.md | 15 ++ support/guides/install/install.md | 131 ++++++++++++ support/guides/introduction.md | 64 ++++++ support/nginx/mobilizon.vhost | 57 +++++ .../service => service/users}/tools.exs | 2 +- .../resolvers/user_resolver_test.exs | 2 +- 19 files changed, 772 insertions(+), 150 deletions(-) create mode 100644 .gitlab/issue_templates/Bug.md rename lib/{mobilizon/users/service => service/users}/activation.ex (93%) rename lib/{mobilizon/users/service => service/users}/reset_password.ex (95%) rename lib/{mobilizon/users/service => service/users}/tools.ex (95%) create mode 100644 support/guides/development/development.md create mode 100644 support/guides/development/styleguide.md create mode 100644 support/guides/development/tests.md create mode 100644 support/guides/install/dependencies.md create mode 100644 support/guides/install/docker.md create mode 100644 support/guides/install/install.md create mode 100644 support/guides/introduction.md create mode 100644 support/nginx/mobilizon.vhost rename test/mobilizon/{users/service => service/users}/tools.exs (94%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6fdc5f21e..e7f986de8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -74,6 +74,21 @@ elixir_deps: paths: - deps +doc: + stage: back + before_script: + - mix deps.get + script: + - mix docs + - mv doc public + cache: + paths: + - deps + artifacts: + expire_in: 1 hour + paths: + - public + mix: stage: back services: diff --git a/.gitlab/issue_templates/Bug.md b/.gitlab/issue_templates/Bug.md new file mode 100644 index 000000000..cabd94455 --- /dev/null +++ b/.gitlab/issue_templates/Bug.md @@ -0,0 +1,29 @@ +#### Description + +[Description of the issue] + +#### Steps to Reproduce + +1. [First Step] +2. [Second Step] +3. [and so on...] + +#### Expected behaviour: + +[What you expect to happen] + +#### Actual behaviour: + +[What actually happens] + +#### Reproduces how often: + +[What percentage of the time does it reproduce?] + +#### Versions + +[What Mobilizon instance you're using, and the versions of each relevant app or component, including your OS and browser.] + +#### Additional Information + +[Any additional information, configuration or data that might be necessary to reproduce the issue.] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 914bb8d03..fcb1d3d7d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,7 +6,9 @@ First off, thank you for considering contributing to Mobilizon! -Our aim is for this project to make you feel welcome as a contributor. We hugely value the comments and contributions of community members in the various publicly-accessible areas in use, which currently are: +Our aim is for this project to make you feel welcome as a contributor. +We hugely value the comments and contributions of community members in the various +publicly-accessible areas in use, which currently are: * Home: [Home](https://joinmobilizon.org) * Wiki: [Project Wiki](https://framagit.org/framasoft/mobilizon/wikis) (Gitlab) @@ -93,13 +95,13 @@ Project maintainers who do not follow or enforce the Code of Conduct in good fai ### Submitting Feature Requests, Enhancement Suggestions or Bug Reports -This section guides you through submitting a :sparkles: feature request, :lipstick: enhancement suggestions, and :bug: bug reports for Mobilizon - anything from errors and crashes, to minor improvements, to completely new features. +This section guides you through submitting a โœจ feature request, ๐Ÿ’„ enhancement suggestions, and ๐Ÿ› bug reports for Mobilizon - anything from errors and crashes, to minor improvements, to completely new features. When you post an issue, please include as many details as possible. **Fill in the issue template** (available below) to help us resolve issues faster. ### Before making a submission -Please go through the checklist below before posting any :sparkles: :lipstick: :bug: +Please go through the checklist below before posting any โœจ ๐Ÿ’„ ๐Ÿ› * **Check if you're using the latest version** of Mobilizon and all its relevant components and if you can get the desired behaviour by changing some config settings. * **Perform a cursory search** in the issue tracker to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one. @@ -121,7 +123,7 @@ Open an issue providing the following information: * **Explain why this enhancement would be useful** to most participants of Mobilizon and isn't something that can or should be implemented as a community extension. * **List some other communities, platforms or apps where this enhancement exists.** -### Reporting Bugs :bug: +### Reporting Bugs ๐Ÿ› Open an issue providing the following information by filling in issue template below, explaining the problem and including additional details to help maintainers reproduce the problem: @@ -149,76 +151,42 @@ Include details about your configuration and environment: --- -### Template for submitting issues - -#### Description - -[Description of the issue] - -#### Steps to Reproduce - -1. [First Step] -2. [Second Step] -3. [and so on...] - -#### Expected behaviour: - -[What you expect to happen] - -#### Actual behaviour: - -[What actually happens] - -#### Reproduces how often: - -[What percentage of the time does it reproduce?] - -#### Versions - -[What Mobilizon instance you're using, and the versions of each relevant app or component, including your OS and browser.] - -#### Additional Information - -[Any additional information, configuration or data that might be necessary to reproduce the issue.] - ---- - ### Contributing A common misconception about contributing to free and open source projects is that you need to contribute code. In fact, itโ€™s often the other parts of a project that are most overlooked. Youโ€™ll do the project a huge favour by offering to pitch in with these types of contributions! Even if you like to write code, other types of contributions are a great way to get involved with a project and meet other community members. Building those relationships may open up unexpected opportunities. -#### Do you like to design? :art: +#### Do you like to design? ๐ŸŽจ * Restructure layouts to improve the project's usability * Conduct user research to reorganise and refine the project's navigation or menus * Create art for icons and app screens -#### Do you like to write? :pencil2: +#### Do you like to write? โœ * Write and improve the project's documentation * Write tutorials for the project * Curate a wiki page of examples showing how the project can be used -#### Do you like organising? :inbox_tray: +#### Do you like organising? ๐Ÿ“ฅ * Link to duplicate issues, and suggest new issue labels, to keep things organised * Go through open issues and suggest revisiting or closing old ones * Ask clarifying questions on recently opened issues to move the discussion forward -#### Do you like helping people? :raising_hand: +#### Do you like helping people? ๐Ÿ™‹ * Answer questions about the project on forums and other sites * Answer questions for people on open issues -#### Do you like helping others code? :open_hands: +#### Do you like helping others code? ๐Ÿ‘ * Review code on other peopleโ€™s submissions * Write tutorials for how a project can be used * Offer to mentor another contributor -#### Do you like to code? :nut_and_bolt: +#### Do you like to code? ๐Ÿ”ฉ * Find an open issue to tackle * Offer to help write a new feature @@ -231,24 +199,23 @@ Even if you like to write code, other types of contributions are a great way to Unsure where to begin contributing? You can start by looking through issues tagged with: -* [`first-timers-only`](https://www.firsttimersonly.com)- issues which should only require a few lines of code, and a test or two. -* `help-wanted` - issues which should be a bit more involved than `first-timers-only` issues. +* [`first-timers-only`](https://framagit.org/framasoft/mobilizon/issues?scope=all&utf8=โœ“&state=opened&label_name[]=๐ŸŒฑ first-timers-only) [https://www.firsttimersonly.com](https://www.firsttimersonly.com)- issues which should only require a few lines of code, and a test or two. +* [`help-wanted`](https://framagit.org/framasoft/mobilizon/issues?label_name[]=๐Ÿ™ help-wanted) - issues which should be a bit more involved than `first-timers-only` issues. #### Local development -Mobilizon can be developed locally. For instructions on how to do this, please see [the documentation](https://framagit.org/framasoft/mobilizon/wikis/install). +Mobilizon can be developed locally. For instructions on how to do this, please see [the documentation](development.html). #### Coding & git practices * We use GitLab's merge requests as our code review tool * We encourage any dev to comment on merge requests and we think of the merge request not as a "please approve my code" but as a space for co-developing. * We develop features on separate branches identified by issue numbers. -* We use merge to `develop` (not rebase) so that commits related to an issue can be retroactively explored. * We don't currently use release branches or tags because we don't have release management at this phase of development. #### How to make changes -* Make your changes on a seperate branch which includes an issue number e.g. `1234-some-new-feature` where 1234 is the issue number where the feature is documented. Make sure the branch is based on `develop`. +* Make your changes on a separate branch which includes an issue number e.g. `1234-some-new-feature` where 1234 is the issue number where the feature is documented. Make sure the branch is based on `develop`. * Do not commit changes to files that are irrelevant to your feature or bugfix. * Use commit messages descriptive of your changes. * Push to the upstream of your new branch. @@ -262,8 +229,8 @@ Mobilizon can be developed locally. For instructions on how to do this, please s #### Merge requests -* Follow the code styleguides (TBD). -* Document new code based on the documentation styleguide (TBD) +* Follow [the code styleguides](styleguide.html). +* Document new code based on [the documentation styleguide](https://hexdocs.pm/elixir/writing-documentation.html) * Each merge request should implement ONE feature or bugfix. If you want to add or fix more than one thing, submit more than one merge request. * Fill in the merge request template below * Include relevant issue number(s) in the merge request title @@ -284,48 +251,48 @@ Mobilizon can be developed locally. For instructions on how to do this, please s #### Issue & Commit Categories -* :ambulance: `critical` : Critical hotfix! -* :lipstick: `enhancement` : General improvements. -* :sparkles: `feature` : New features. -* :bug: `bug` : Confirmed bugs, or reports that are likely to be bugs. -* :raising_hand: `question` : Questions (e.g. how can I do X?) -* :postbox: `feedback` : General feedback. -* :art: `ui` : Visual design. -* :scroll: `copy` : Text in the apps, or translations. -* :information_source: `documentation` : Documentation. -* :racehorse: `performance` : Performance. -* :lock: `security` : Security. -* :electric_plug: `api` : Mobilizon's APIs. -* :alien: `external` : External libraries or API integrations. -* :warning: `exception` : Uncaught exceptions. -* :fire: `crash` : Crash. -* :symbols: `encoding` : Character encoding or data serialization issue. -* :truck: `cleanup` : Removing, moving or refactoring code or files. -* :white_check_mark: `tests` : Testing +* ๐Ÿš‘ `critical` : Critical hotfix! +* ๐Ÿ’„ `enhancement` : General improvements. +* โœจ `feature` : New features. +* ๐Ÿ› `bug` : Confirmed bugs, or reports that are likely to be bugs. +* ๐Ÿ™‹ `question` : Questions (e.g. how can I do X?) +* ๐Ÿ“ฎ `feedback` : General feedback. +* ๐ŸŽจ `ui` : Visual design. +* ๐Ÿ“œ `copy` : Text in the apps, or translations. +* โ„น `documentation` : Documentation. +* ๐ŸŽ `performance` : Performance. +* ๐Ÿ”’ `security` : Security. +* ๐Ÿ”Œ `api` : Mobilizon's APIs. +* ๐Ÿ‘ฝ `external` : External libraries or API integrations. +* โš  `exception` : Uncaught exceptions. +* ๐Ÿ”ฅ `crash` : Crash. +* ๐Ÿ”ฃ `encoding` : Character encoding or data serialization issue. +* ๐Ÿšš `cleanup` : Removing, moving or refactoring code or files. +* โœ… `tests` : Testing #### Issue Status -* :speech_balloon: `discussion` : Discussion to clarify this issue is ongoing. -* :soon: `todo` : This has been discussed and now needs work. -* :repeat: `needs-more-info` : More information needs to be collected about these problems or feature requests (e.g. steps to reproduce). -* :bulb: `idea` : Needs to be discussed further. Could be a feature request which might be good to first implement as a community extension. -* :construction: `in-progress` : Someone is working on this... -* :pray: `help-wanted` : The Mobilizon core team would appreciate help from the community in resolving these issues. -* :seedling: `first-timers-only` : Less complex issues which would be good first issues to work on for users who want to contribute. -* :1234: `needs-reproduction` : Likely bugs, but haven't been reliably reproduced. -* :red_circle: `blocked` : Blocked on other issues. -* :two: `duplicate` : Duplicate of another issue, i.e. has been reported before. -* :no_good: `wontfix` : The Mobilizon core team has decided not to fix these issues (or add these features) for now, because they're working as intended, or some other reason. -* :put_litter_in_its_place: `invalid` : Issues which are not valid (e.g. spam or submitted by error). +* ๐Ÿ’ฌ `discussion` : Discussion to clarify this issue is ongoing. +* ๐Ÿ”œ `todo` : This has been discussed and now needs work. +* ๐Ÿ” `needs-more-info` : More information needs to be collected about these problems or feature requests (e.g. steps to reproduce). +* ๐Ÿ’ก `idea` : Needs to be discussed further. Could be a feature request which might be good to first implement as a community extension. +* ๐Ÿšง `in-progress` : Someone is working on this... +* ๐Ÿ™ `help-wanted` : The Mobilizon core team would appreciate help from the community in resolving these issues. +* ๐ŸŒฑ `first-timers-only` : Less complex issues which would be good first issues to work on for users who want to contribute. +* ๐Ÿ”ข `needs-reproduction` : Likely bugs, but haven't been reliably reproduced. +* ๐Ÿ”ด `blocked` : Blocked on other issues. +* 2๏ธโƒฃ `duplicate` : Duplicate of another issue, i.e. has been reported before. +* ๐Ÿ™… `wontfix` : The Mobilizon core team has decided not to fix these issues (or add these features) for now, because they're working as intended, or some other reason. +* ๐Ÿšฎ `invalid` : Issues which are not valid (e.g. spam or submitted by error). #### Merge Request Status -* :construction: `in-progress` : Still being worked on, more changes will follow. -* :busstop: `needs-review` : Needs code review and approval from maintainers. -* :mag: `under-review` : Being reviewed by maintainers. -* :wrench: `changes-required` : Needs to be updated based on review comments and then reviewed again. -* :eyes: `needs-testing` : Needs manual testing. +* ๐Ÿšง `in-progress` : Still being worked on, more changes will follow. +* ๐Ÿš `needs-review` : Needs code review and approval from maintainers. +* ๐Ÿ” `under-review` : Being reviewed by maintainers. +* ๐Ÿ”ง `changes-required` : Needs to be updated based on review comments and then reviewed again. +* ๐Ÿ‘€ `needs-testing` : Needs manual testing. --- @@ -337,4 +304,4 @@ The following documents have greatly helped us put this together. A big thank yo * [Open Source Guides](https://opensource.guide) * [Holochain's Development Protocols](https://github.com/holochain/holochain-proto/wiki/Development-Protocols) * [Atom's contributing guide](https://github.com/atom/atom/blob/master/CONTRIBUTING.md) -* [Funkwhale's pad on how to Communicate with others](https://hackmd.io/qESHvdHZSWuhLNjeanaVQw?both) \ No newline at end of file +* [Funkwhale's pad on how to Communicate with others](https://hackmd.io/qESHvdHZSWuhLNjeanaVQw?both) diff --git a/README.md b/README.md index 218d215b1..c8b1b7e44 100644 --- a/README.md +++ b/README.md @@ -1,68 +1,61 @@ -# Mobilizon +

+ + Mobilizon + +

-Your federated organization and mobilization platform. Gather people with a convivial, ethical, and emancipating tool. +MobiliZon is your federated organization and mobilization platform. Gather people with a convivial, ethical, and emancipating tool. -## 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 +

+ Developed with โ™ฅ by Framasoft +

-#### Server +

+ + Framasoft logo + +

- * 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 - * 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` +## Introduction - ``` create extension if not exists postgis; ``` +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. - * Run migrations: `mix ecto.migrate`. - * Start Phoenix endpoint with `mix phx.server`. +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*. -Now you can visit [`localhost:4000`](http://localhost:4000) from your browser -and see the website (server *and* client) in action. +## โœจ Features -#### Client +### ๐Ÿ‘ค Identities -If you plan to specifically change the client side (frontend), do the following -once the server is running: +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. - * 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. +### ๐Ÿ“… Events and groups -Just run : -```bash -make start -``` -to start a database container, an API container and the front-end dev container running on localhost. +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. -## Learn more +--- - * Official website: https://joinmobilizon.org/ - * Source: https://framagit.org/framasoft/mobilizon - * Docu wiki: https://framagit.org/framasoft/mobilizon/wikis/home - * Riot/Matrix: https://riot.im/app/#/room/#Mobilizon:matrix.org - * Mastodon: https://framapiaf.org/@mobilizon - * Forum: https://framacolibri.org/c/mobilizon/fr-francais +## Contributing + +We appreciate any contribution to MobiliZon. Check our [CONTRIBUTING](CONTRIBUTING.md) 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 + * ๐Ÿ’ฌ Riot/Matrix: [https://riot.im/app/#/room/#Mobilizon:matrix.org](https://riot.im/app/#/room/#Mobilizon:matrix.org) + * ๐Ÿ—ฃ๏ธ 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` diff --git a/lib/mobilizon_web/resolvers/user.ex b/lib/mobilizon_web/resolvers/user.ex index d746ce81c..974568196 100644 --- a/lib/mobilizon_web/resolvers/user.ex +++ b/lib/mobilizon_web/resolvers/user.ex @@ -5,7 +5,7 @@ defmodule MobilizonWeb.Resolvers.User do alias Mobilizon.Actors.Actor alias Mobilizon.Users.User alias Mobilizon.{Actors, Users} - alias Mobilizon.Users.Service.{ResetPassword, Activation} + alias Mobilizon.Service.Users.{ResetPassword, Activation} import Mobilizon.Users.Guards require Logger diff --git a/lib/mobilizon/users/service/activation.ex b/lib/service/users/activation.ex similarity index 93% rename from lib/mobilizon/users/service/activation.ex rename to lib/service/users/activation.ex index b488de05a..c89d2ec95 100644 --- a/lib/mobilizon/users/service/activation.ex +++ b/lib/service/users/activation.ex @@ -1,10 +1,10 @@ -defmodule Mobilizon.Users.Service.Activation do +defmodule Mobilizon.Service.Users.Activation do @moduledoc false alias Mobilizon.{Mailer, Users} alias Mobilizon.Users.User alias Mobilizon.Email.User, as: UserEmail - alias Mobilizon.Users.Service.Tools + alias Mobilizon.Service.Users.Tools require Logger diff --git a/lib/mobilizon/users/service/reset_password.ex b/lib/service/users/reset_password.ex similarity index 95% rename from lib/mobilizon/users/service/reset_password.ex rename to lib/service/users/reset_password.ex index fd04fdfa2..e34565166 100644 --- a/lib/mobilizon/users/service/reset_password.ex +++ b/lib/service/users/reset_password.ex @@ -1,4 +1,4 @@ -defmodule Mobilizon.Users.Service.ResetPassword do +defmodule Mobilizon.Service.Users.ResetPassword do @moduledoc false require Logger @@ -6,7 +6,7 @@ defmodule Mobilizon.Users.Service.ResetPassword do alias Mobilizon.Users.User alias Mobilizon.{Mailer, Repo, Users} alias Mobilizon.Email.User, as: UserEmail - alias Mobilizon.Users.Service.Tools + alias Mobilizon.Service.Users.Tools @doc """ Check that the provided token is correct and update provided password diff --git a/lib/mobilizon/users/service/tools.ex b/lib/service/users/tools.ex similarity index 95% rename from lib/mobilizon/users/service/tools.ex rename to lib/service/users/tools.ex index 9348e3a59..1dbf5d33a 100644 --- a/lib/mobilizon/users/service/tools.ex +++ b/lib/service/users/tools.ex @@ -1,4 +1,4 @@ -defmodule Mobilizon.Users.Service.Tools do +defmodule Mobilizon.Service.Users.Tools do @moduledoc """ Common functions for actors services """ diff --git a/mix.exs b/mix.exs index 596030d38..f21c5a333 100644 --- a/mix.exs +++ b/mix.exs @@ -1,10 +1,12 @@ defmodule Mobilizon.Mixfile do use Mix.Project + @version "0.0.1-dev" + def project do [ app: :mobilizon, - version: "0.0.1", + version: @version, elixir: "~> 1.4", elixirc_paths: elixirc_paths(Mix.env()), compilers: [:phoenix, :gettext] ++ Mix.compilers(), @@ -25,7 +27,7 @@ defmodule Mobilizon.Mixfile do name: "Mobilizon", source_url: "https://framagit.org/tcit/mobilizon", homepage_url: "https://framagit.org/tcit/mobilizon", - docs: [main: "Mobilizon"] + docs: docs() ] end @@ -93,7 +95,7 @@ defmodule Mobilizon.Mixfile do {:phoenix_live_reload, "~> 1.2", only: :dev}, {:ex_machina, "~> 2.2", only: [:dev, :test]}, {:excoveralls, "~> 0.10", only: :test}, - {:ex_doc, "~> 0.16", only: :dev, runtime: false}, + {:ex_doc, "~> 0.16", only: [:dev, :test], runtime: false}, {:mix_test_watch, "~> 0.5", only: :dev, runtime: false}, {:ex_unit_notifier, "~> 0.1", only: :test}, {:dialyxir, "~> 1.0.0-rc.4", only: [:dev], runtime: false}, @@ -117,4 +119,196 @@ defmodule Mobilizon.Mixfile do test: ["ecto.create --quiet", "ecto.migrate", "test"] ] end + + defp docs() do + [ + source_ref: "v#{@version}", + extra_section: "GUIDES", + main: "introduction", + api_reference: false, + groups_for_modules: groups_for_modules(), + extras: extras(), + groups_for_extras: groups_for_extras(), + nest_modules_by_prefix: [ + Mobilizon, + MobilizonWeb, + Mobilizon.Service.Geospatial, + MobilizonWeb.Resolvers, + MobilizonWeb.Schema, + Mobilizon.Service + ] + ] + end + + defp extras() do + [ + "support/guides/development/development.md", + "support/guides/development/tests.md", + "support/guides/development/styleguide.md", + "support/guides/install/install.md", + "support/guides/install/dependencies.md", + "support/guides/install/docker.md", + "support/guides/introduction.md", + "CONTRIBUTING.md" + ] + end + + defp groups_for_modules() do + [ + Models: [ + Mobilizon.Actors, + Mobilizon.Actors.Actor, + Mobilizon.Actors.ActorOpennessEnum, + Mobilizon.Actors.ActorTypeEnum, + Mobilizon.Actors.MemberRoleEnum, + Mobilizon.Actors.Bot, + Mobilizon.Actors.Follower, + Mobilizon.Actors.Member, + Mobilizon.Addresses, + Mobilizon.Addresses.Address, + Mobilizon.Events, + Mobilizon.Events.Event, + Mobilizon.Events.Comment, + Mobilizon.Events.FeedToken, + Mobilizon.Events.Participant, + Mobilizon.Events.Session, + Mobilizon.Events.Tag, + Mobilizon.Events.TagRelations, + Mobilizon.Events.Track, + Mobilizon.Event.EventCategoryEnum, + Mobilizon.Events.CommentVisibilityEnum, + Mobilizon.Events.EventStatusEnum, + Mobilizon.Events.EventVisibilityEnum, + Mobilizon.Events.JoinOptionsEnum, + Mobilizon.Events.ParticipantRoleEnum, + Mobilizon.Events.Tag.TitleSlug, + Mobilizon.Events.Tag.TitleSlug.Type, + Mobilizon.Events.TagRelation, + Mobilizon.Users, + Mobilizon.Users.User, + Mobilizon.Users.UserRoleEnum, + Mobilizon.Users.Guards, + Mobilizon.Activity, + Mobilizon.Ecto, + Mobilizon.Repo + ], + APIs: [ + MobilizonWeb.API.Comments, + MobilizonWeb.API.Events, + MobilizonWeb.API.Groups, + MobilizonWeb.API.Search, + MobilizonWeb.API.Utils + ], + Web: [ + MobilizonWeb, + MobilizonWeb.PageView, + MobilizonWeb.Router, + MobilizonWeb.Router.Helpers, + MobilizonWeb.AuthErrorHandler, + MobilizonWeb.AuthPipeline, + MobilizonWeb.ChangesetView, + MobilizonWeb.Context, + MobilizonWeb.Endpoint, + MobilizonWeb.ErrorHelpers, + MobilizonWeb.ErrorView, + MobilizonWeb.FallbackController, + MobilizonWeb.FeedController, + MobilizonWeb.Gettext, + MobilizonWeb.Guardian, + MobilizonWeb.Guardian.Plug, + MobilizonWeb.JsonLD.ObjectView, + MobilizonWeb.PageController, + MobilizonWeb.UploadPlug, + MobilizonWeb.Uploaders.Avatar, + MobilizonWeb.Uploaders.Category, + MobilizonWeb.Uploaders.Category.Type + ], + Geospatial: [ + Mobilizon.Service.Geospatial, + Mobilizon.Service.Geospatial.Addok, + Mobilizon.Service.Geospatial.GoogleMaps, + Mobilizon.Service.Geospatial.MapQuest, + Mobilizon.Service.Geospatial.Nominatim, + Mobilizon.Service.Geospatial.Photon, + Mobilizon.Service.Geospatial.Provider + ], + GraphQL: [ + MobilizonWeb.Resolvers.Address, + MobilizonWeb.Resolvers.Comment, + MobilizonWeb.Resolvers.Event, + MobilizonWeb.Resolvers.FeedToken, + MobilizonWeb.Resolvers.Group, + MobilizonWeb.Resolvers.Person, + MobilizonWeb.Resolvers.Search, + MobilizonWeb.Resolvers.Tag, + MobilizonWeb.Resolvers.User, + MobilizonWeb.Schema, + MobilizonWeb.Schema.ActorInterface, + MobilizonWeb.Schema.Actors.FollowerType, + MobilizonWeb.Schema.Actors.GroupType, + MobilizonWeb.Schema.Actors.MemberType, + MobilizonWeb.Schema.Actors.PersonType, + MobilizonWeb.Schema.AddressType, + MobilizonWeb.Schema.CommentType, + MobilizonWeb.Schema.Custom.Point, + MobilizonWeb.Schema.Custom.UUID, + MobilizonWeb.Schema.EventType, + MobilizonWeb.Schema.Events.FeedTokenType, + MobilizonWeb.Schema.Events.ParticipantType, + MobilizonWeb.Schema.SortType, + MobilizonWeb.Schema.TagType, + MobilizonWeb.Schema.UserType, + MobilizonWeb.Schema.Utils + ], + ActivityPub: [ + MobilizonWeb.ActivityPub.ActorView, + MobilizonWeb.ActivityPub.ObjectView, + MobilizonWeb.ActivityPubController, + Mobilizon.Service.ActivityPub, + Mobilizon.Service.ActivityPub.Transmogrifier, + Mobilizon.Service.ActivityPub.Utils, + MobilizonWeb.HTTPSignaturePlug, + MobilizonWeb.WebFingerController, + MobilizonWeb.NodeInfoController, + Mobilizon.Service.HTTPSignatures, + Mobilizon.Service.WebFinger, + Mobilizon.Service.XmlBuilder, + Mobilizon.Service.Federator + ], + Services: [ + Mobilizon.Service.EmailChecker, + Mobilizon.Service.Export.Feed, + Mobilizon.Service.Export.ICalendar, + Mobilizon.Service.Metadata, + Mobilizon.Service.Formatter, + Mobilizon.Service.Users.Tools + ], + Tools: [ + Mobilizon.Application, + Mobilizon.Factory, + Mobilizon.Mailer, + Mobilizon.EmailView, + Mobilizon.Email.User + ] + ] + end + + defp groups_for_extras() do + [ + Introduction: [ + "support/guides/introduction.md", + "CONTRIBUTING.md" + ], + Development: [ + "support/guides/development/development.md", + "support/guides/development/tests.md", + "support/guides/development/styleguide.md" + ], + Production: [ + "support/guides/install/install.md", + "support/guides/install/docker.md", + "support/guides/install/dependencies.md" + ] + ] + end end diff --git a/support/guides/development/development.md b/support/guides/development/development.md new file mode 100644 index 000000000..a375702b7 --- /dev/null +++ b/support/guides/development/development.md @@ -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. diff --git a/support/guides/development/styleguide.md b/support/guides/development/styleguide.md new file mode 100644 index 000000000..8591909ac --- /dev/null +++ b/support/guides/development/styleguide.md @@ -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`. diff --git a/support/guides/development/tests.md b/support/guides/development/tests.md new file mode 100644 index 000000000..ab34f7441 --- /dev/null +++ b/support/guides/development/tests.md @@ -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. diff --git a/support/guides/install/dependencies.md b/support/guides/install/dependencies.md new file mode 100644 index 000000000..9bd2ea74d --- /dev/null +++ b/support/guides/install/dependencies.md @@ -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! diff --git a/support/guides/install/docker.md b/support/guides/install/docker.md new file mode 100644 index 000000000..790d3a9e7 --- /dev/null +++ b/support/guides/install/docker.md @@ -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. diff --git a/support/guides/install/install.md b/support/guides/install/install.md new file mode 100644 index 000000000..f66b2c010 --- /dev/null +++ b/support/guides/install/install.md @@ -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 +``` + diff --git a/support/guides/introduction.md b/support/guides/introduction.md new file mode 100644 index 000000000..47ed700df --- /dev/null +++ b/support/guides/introduction.md @@ -0,0 +1,64 @@ +# Mobilizon + +

+ + Mobilizon + +

+ +MobiliZon is your federated organization and mobilization platform. Gather people with a convivial, ethical, and emancipating tool. + +

+ Developed with โ™ฅ by Framasoft +

+ +

+ + Framasoft logo + +

+ +## 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` diff --git a/support/nginx/mobilizon.vhost b/support/nginx/mobilizon.vhost new file mode 100644 index 000000000..66d34d2f5 --- /dev/null +++ b/support/nginx/mobilizon.vhost @@ -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; + } +} diff --git a/test/mobilizon/users/service/tools.exs b/test/mobilizon/service/users/tools.exs similarity index 94% rename from test/mobilizon/users/service/tools.exs rename to test/mobilizon/service/users/tools.exs index 2de00d07a..6c160bf97 100644 --- a/test/mobilizon/users/service/tools.exs +++ b/test/mobilizon/service/users/tools.exs @@ -1,4 +1,4 @@ -defmodule Mobilizon.Users.Service.ToolsTest do +defmodule Mobilizon.Service.Users.ToolsTest do use Mobilizon.DataCase import Mobilizon.Factory diff --git a/test/mobilizon_web/resolvers/user_resolver_test.exs b/test/mobilizon_web/resolvers/user_resolver_test.exs index 2f2ee6e55..ffd47e4cd 100644 --- a/test/mobilizon_web/resolvers/user_resolver_test.exs +++ b/test/mobilizon_web/resolvers/user_resolver_test.exs @@ -4,7 +4,7 @@ defmodule MobilizonWeb.Resolvers.UserResolverTest do alias Mobilizon.Actors.Actor alias Mobilizon.Users.User alias MobilizonWeb.AbsintheHelpers - alias Mobilizon.Users.Service.ResetPassword + alias Mobilizon.Service.Users.ResetPassword import Mobilizon.Factory use Bamboo.Test