To start your Phoenix server:
- Use
mise
orasdf
to install the correct versions of Erlang, Elixir and Node.js (check.tool-versions
file) - Run
mix setup
to install and setup dependencies - Start Phoenix endpoint with
mix phx.server
or inside IEx withiex -S mix phx.server
Now you can visit localhost:4000
from your browser.
If you want to seed the database with demo data, run mix seed.demo
. You can safely run it as many times as you want without duplicating the data.
Those demo seeds include test accounts with the following email addresses:
You can log in on the UI with any of the above email addresses, with the password: password.
The demo seeds file can be found here.
Build and run the docker container with:
docker build . -t omedis
docker run \
-e DATABASE_URL=postgresql://postgres:postgres@host.docker.internal/omedis_prod \
-e PHX_HOST=localhost \
-e SECRET_KEY_BASE=w/z9PINQc7cyGXo8B+vQHXxAi0EJ93W+Qg5ywPPUsBKapGI2ijVHvTEku3jgFtgX \
-p 4000:4000 \
omedis
Please use the Pull Request workflow to submit your changes. For a guide on how to create Pull Requests, check out GitHub's tutorial on creating a pull request.
If that seems to be too complicated: Use https://gitbutler.com to create a pull request.
Make sure to execute make check_code
in order to run all the checks before committing the code.
Please create one PR per change. If you have multiple changes, please create multiple PRs. This allows for early feedback and reduces the risk of having to rework large parts of a PR.
Please use clear and descriptive commit messages.
The secret for tokens need to be changed for the production
environment and can be found in config/config.exs
config :omedis, :token_signing_secret, System.get_env("TOKEN_SIGNING_SECRET") || "Lu8xpRC9"
This can also be set as an environment variable TOKEN_SIGNING_SECRET
and override the value in the config.exs
file.
We are using the Ash Framework.
Most times system admin work is done with the web GUI. But sometimes it is handy to do this work in the CLI. Here are some examples.
When developing new features or updating static content in the application, follow the steps below to ensure all user-facing text is translatable using Gettext.
For any static text added to your templates or views, wrap it with the dgettext/2
function to ensure it can be translated based on the user's language preference. The syntax is as follows:
dgettext("Context", "Your New Text Here")
Make sure that every piece of new static text is wrapped in this function to ensure proper localization.
Once you've added new text to the code, extract the translations into the .po files for each language using the following Mix task:
mix gettext.extract --merge
This command will:
Scan your project for any new calls to gettext/1. Update the .po files located under priv/gettext/ directories, adding new entries for the texts you've marked as translatable.
After running the extract command, navigate to the .po files in priv/gettext for each language. The new entries will appear as empty translations like this:
# priv/gettext/<language>/LC_MESSAGES/default.po
msgid "Your New Text Here"
msgstr ""
For each new entry, provide the appropriate translation by updating the msgstr value.
Example for French:
msgid "Your New Text Here"
msgstr "Votre nouveau texte ici"
To add a user , you can use the following code in the IEx console. To create a user you need to provide the following information: email, hashed_password, first_name, last_name , gender and birthdate.
alias Omedis.Accounts.User
User.create(%{email: "wintermeyer@gmail.com" , hashed_password: Bcrypt.hash_pwd_salt("password"),first_name: "Stefan", last_name: "Wintermeyer", gender: "Male", birthdate: "1980-01-01"})
To update the user with the email address example@example.com
you
alias Omedis.Accounts.User
{:ok , user} = User.by_email("example@example.com")
User.update(user, %{first_name: "Stefan" })
To delete the user with the email address example@example.com
you ...
alias Omedis.Accounts.User
{:ok , user} = User.by_email("example@example.com")
User.destroy(user)
To enable auto-disappearing flash messages, set the FLASH_AUTO_DISAPPEAR
environment variable to an integer representing the delay in seconds. E.g.
FLASH_AUTO_DISAPPEAR=3
will make flash messages disappear after 3 seconds.
To disable, set to 0.
The default is 4 seconds.