diff --git a/lib/philomena_web/controllers/api/json/theme_controller.ex b/lib/philomena_web/controllers/api/json/theme_controller.ex index 34f195f2..d9e2c28f 100644 --- a/lib/philomena_web/controllers/api/json/theme_controller.ex +++ b/lib/philomena_web/controllers/api/json/theme_controller.ex @@ -4,8 +4,6 @@ defmodule PhilomenaWeb.Api.Json.ThemeController do alias PhilomenaWeb.SettingView def index(conn, _params) do - conn - |> put_resp_content_type("application/json") - |> send_resp(200, SettingView.theme_paths_json(conn)) + json(conn, SettingView.theme_paths()) end end diff --git a/lib/philomena_web/templates/setting/edit.html.slime b/lib/philomena_web/templates/setting/edit.html.slime index 0604e383..829c3cd2 100644 --- a/lib/philomena_web/templates/setting/edit.html.slime +++ b/lib/philomena_web/templates/setting/edit.html.slime @@ -88,7 +88,7 @@ h1 Content Settings = error_tag f, :theme_color .fieldlabel: i Color of the theme .fieldlabel: strong Don't forget to save the settings to apply the theme! - .hidden#js-theme-paths data-theme-paths=theme_paths_json(@conn) + .hidden#js-theme-paths data-theme-paths=Jason.encode!(theme_paths()) .field => label f, :scale_large_images => select f, :scale_large_images, scale_options(), class: "input" diff --git a/lib/philomena_web/views/setting_view.ex b/lib/philomena_web/views/setting_view.ex index 601307bb..d6826e0e 100644 --- a/lib/philomena_web/views/setting_view.ex +++ b/lib/philomena_web/views/setting_view.ex @@ -15,12 +15,10 @@ defmodule PhilomenaWeb.SettingView do end) end - def theme_paths_json(conn) do - User.themes() - |> Map.new(fn name -> - {name, static_path(conn, "/css/#{name}.css")} + def theme_paths do + Map.new(User.themes(), fn name -> + {name, static_path(PhilomenaWeb.Endpoint, "/css/#{name}.css")} end) - |> Jason.encode!() end def scale_options do