2019-09-02 14:29:19 +03:00
|
|
|
defmodule PlausibleWeb.LayoutView do
|
|
|
|
use PlausibleWeb, :view
|
2019-09-11 19:04:37 +03:00
|
|
|
|
2020-05-26 16:09:34 +03:00
|
|
|
def admin_email do
|
|
|
|
Application.get_env(:plausible, :admin_email)
|
|
|
|
end
|
|
|
|
|
|
|
|
def base_domain do
|
|
|
|
PlausibleWeb.Endpoint.host()
|
|
|
|
end
|
|
|
|
|
|
|
|
def plausible_url do
|
2020-10-05 15:01:54 +03:00
|
|
|
PlausibleWeb.Endpoint.url()
|
2020-05-26 16:09:34 +03:00
|
|
|
end
|
|
|
|
|
2020-03-31 16:23:46 +03:00
|
|
|
def home_dest(conn) do
|
|
|
|
if conn.assigns[:current_user] do
|
|
|
|
"/sites"
|
|
|
|
else
|
|
|
|
"/"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-06-16 15:00:07 +03:00
|
|
|
def settings_tabs(conn) do
|
2020-11-20 12:57:33 +03:00
|
|
|
[
|
|
|
|
[key: "General", value: "general"],
|
2021-06-16 15:00:07 +03:00
|
|
|
[key: "People", value: "people"],
|
2020-11-20 12:57:33 +03:00
|
|
|
[key: "Visibility", value: "visibility"],
|
|
|
|
[key: "Goals", value: "goals"],
|
|
|
|
[key: "Search Console", value: "search-console"],
|
|
|
|
[key: "Email reports", value: "email-reports"],
|
2021-06-17 10:51:58 +03:00
|
|
|
if !is_selfhost() && conn.assigns[:site].custom_domain do
|
2021-01-15 11:12:00 +03:00
|
|
|
[key: "Custom domain", value: "custom-domain"]
|
|
|
|
else
|
|
|
|
nil
|
|
|
|
end,
|
2021-06-16 15:00:07 +03:00
|
|
|
if conn.assigns[:current_user_role] == :owner do
|
|
|
|
[key: "Danger zone", value: "danger-zone"]
|
|
|
|
else
|
|
|
|
nil
|
|
|
|
end
|
2020-11-20 12:57:33 +03:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
2019-09-11 19:04:37 +03:00
|
|
|
def trial_notificaton(user) do
|
|
|
|
case Plausible.Billing.trial_days_left(user) do
|
|
|
|
days when days > 1 ->
|
|
|
|
"#{days} trial days left"
|
2020-06-08 10:35:13 +03:00
|
|
|
|
2019-09-11 19:04:37 +03:00
|
|
|
days when days == 1 ->
|
|
|
|
"Trial ends tomorrow"
|
2020-06-08 10:35:13 +03:00
|
|
|
|
2019-09-11 19:04:37 +03:00
|
|
|
days when days == 0 ->
|
|
|
|
"Trial ends today"
|
|
|
|
end
|
|
|
|
end
|
2020-11-16 16:38:44 +03:00
|
|
|
|
|
|
|
@doc "http://blog.plataformatec.com.br/2018/05/nested-layouts-with-phoenix/"
|
|
|
|
def render_layout(layout, assigns, do: content) do
|
|
|
|
render(layout, Map.put(assigns, :inner_layout, content))
|
|
|
|
end
|
|
|
|
|
|
|
|
def is_current_tab(conn, tab) do
|
|
|
|
List.last(conn.path_info) == tab
|
|
|
|
end
|
2021-01-15 11:12:00 +03:00
|
|
|
|
|
|
|
defp is_selfhost() do
|
|
|
|
Application.get_env(:plausible, :is_selfhost)
|
|
|
|
end
|
2019-09-02 14:29:19 +03:00
|
|
|
end
|