Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customizable about & privacy link #123

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added configurable privacy link
  • Loading branch information
Tobias Fiebig committed Jan 23, 2025
commit 14f7984f2f0b286eab6408f397c73cb1cef411b9
1 change: 1 addition & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ BASE_URL=http://localhost:4000
# SAME_SITE_COOKIE=Lax
# SECURE_COOKIE=false
# ABOUT_URL=https://claper.co/
# PRIVACY_URL=https://claper.co/privacy

DATABASE_URL=postgres://claper:claper@db:5432/claper
SECRET_KEY_BASE=0LZiQBLw4WvqPlz4cz8RsHJlxNiSqM9B48y4ChyJ5v1oA0L/TPIqRjQNdPZN3iEG # Generate with `mix phx.gen.secret`
Expand Down
12 changes: 12 additions & 0 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ if System.get_env("MIX_ENV") == "prod" or Application.get_env(:claper, :server,
end
end

privacy_url = get_var_from_path_or_env(config_dir, "PRIVACY_URL", nil)

if privacy_url do
privacy_url = URI.parse(privacy_url)
if System.get_env("MIX_ENV") == "prod" or Application.get_env(:claper, :server, false) do
if privacy_url.scheme not in ["http", "https"] do
raise "PRIVACY_URL must start with `http` or `https`. Currently configured as `#{System.get_env("PRIVACY_URL")}`"
end
end
end

max_file_size = get_int_from_path_or_env(config_dir, "MAX_FILE_SIZE_MB", 15)

enable_account_creation =
Expand Down Expand Up @@ -170,6 +181,7 @@ config :claper, ClaperWeb.Endpoint,
secret_key_base: secret_key_base,
same_site_cookie: same_site_cookie,
about_url: about_url,
privacy_url: privacy_url,
secure_cookie: secure_cookie

config :claper,
Expand Down
1 change: 1 addition & 0 deletions lib/claper_web/live/event_live/join.ex
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ defmodule ClaperWeb.EventLive.Join do
socket
|> assign(:page_title, gettext("Join"))
|> assign(:about_url, Application.get_env(:claper, ClaperWeb.Endpoint)[:about_url])
|> assign(:privacy_url, Application.get_env(:claper, ClaperWeb.Endpoint)[:privacy_url])
|> assign(:event, nil)
end
end
10 changes: 10 additions & 0 deletions lib/claper_web/live/event_live/join.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
class="absolute h-24 bg-white w-full top-0 md:hidden px-5 py-3 flex flex-col items-center justify-center space-y-2"
@click.away="open = false"
>
<%= if @privacy_url do %>
<a href={@privacy_url} class="text-sm font-semibold text-black">
<%= gettext("Privacy") %>
</a>
<% end %>
<a href={@about_url} class="text-sm font-semibold text-black">
<%= gettext("About") %>
</a>
Expand All @@ -43,6 +48,11 @@
<img src="/images/icons/menu-outline.svg" class="h-9" />
</button>
<div class="hidden md:block">
<%= if @privacy_url do %>
<a href={@privacy_url} class="text-sm text-white font-semibold mr-3">
<%= gettext("Privacy") %>
</a>
<% end %>
<a href={@about_url} class="text-sm text-white font-semibold mr-3">
<%= gettext("About") %>
</a>
Expand Down
Loading