philomena/lib/philomena_web/views/setting_view.ex

42 lines
909 B
Elixir
Raw Normal View History

2019-11-30 23:40:53 +01:00
defmodule PhilomenaWeb.SettingView do
use PhilomenaWeb, :view
2024-12-17 19:35:47 +01:00
alias Philomena.Users.User
2019-11-30 23:40:53 +01:00
2024-12-17 17:49:05 +01:00
def themes do
2019-11-30 23:40:53 +01:00
[
2024-12-17 17:49:05 +01:00
Dark: "dark",
Light: "light"
2019-11-30 23:40:53 +01:00
]
end
2024-12-17 17:49:05 +01:00
def theme_colors do
2024-12-17 19:35:47 +01:00
Enum.map(User.theme_colors(), fn name ->
2024-12-17 20:07:30 +01:00
{String.capitalize(name), name}
2024-12-17 19:35:47 +01:00
end)
2024-12-17 17:49:05 +01:00
end
2024-12-20 18:54:55 +01:00
def theme_paths do
Map.new(User.themes(), fn name ->
{name, static_path(PhilomenaWeb.Endpoint, "/css/#{name}.css")}
2024-12-17 19:35:47 +01:00
end)
2024-12-17 17:49:05 +01:00
end
2021-09-27 03:54:47 +02:00
def scale_options do
[
[key: "Load full images on image pages", value: "false"],
[key: "Load full images on image pages, sized to fit the page", value: "partscaled"],
[key: "Scale large images down before downloading", value: "true"]
]
end
2019-11-30 23:40:53 +01:00
def local_tab_class(conn) do
case conn.assigns.current_user do
2020-01-11 05:20:19 +01:00
nil -> ""
2019-11-30 23:40:53 +01:00
_user -> "hidden"
end
end
def staff?(%{role: role}), do: role != "user"
def staff?(_), do: false
2019-11-30 23:40:53 +01:00
end