From f91a3b30ada5603e66377a4abaee0cacf486e826 Mon Sep 17 00:00:00 2001 From: Leandro Pereira Date: Wed, 20 Nov 2024 11:55:37 -0500 Subject: [PATCH] chore: remove route /css_config (#660) --- lib/beacon/router.ex | 3 --- lib/beacon/runtime_css.ex | 10 --------- .../web/controllers/assets_controller.ex | 22 +------------------ 3 files changed, 1 insertion(+), 34 deletions(-) diff --git a/lib/beacon/router.ex b/lib/beacon/router.ex index 50fd83dc..00e9aee8 100644 --- a/lib/beacon/router.ex +++ b/lib/beacon/router.ex @@ -139,9 +139,6 @@ defmodule Beacon.Router do live_session session_name, session_opts do get "/__beacon_media__/:file_name", Beacon.Web.MediaLibraryController, :show, assigns: %{site: opts[:site]} - # TODO: css_config-:md5 caching - get "/__beacon_assets__/css_config", Beacon.Web.AssetsController, :css_config, assigns: %{site: opts[:site]} - get "/__beacon_assets__/css-:md5", Beacon.Web.AssetsController, :css, assigns: %{site: opts[:site]} get "/__beacon_assets__/js-:md5", Beacon.Web.AssetsController, :js, assigns: %{site: opts[:site]} diff --git a/lib/beacon/runtime_css.ex b/lib/beacon/runtime_css.ex index f320082e..55cef33f 100644 --- a/lib/beacon/runtime_css.ex +++ b/lib/beacon/runtime_css.ex @@ -26,16 +26,6 @@ defmodule Beacon.RuntimeCSS do Beacon.Config.fetch!(site).css_compiler.config(site) end - @doc """ - Returns the URL to fetch the CSS config used to generate the site stylesheet. - """ - @spec asset_url(Site.t()) :: String.t() - def asset_url(site) do - %{endpoint: endpoint, router: router} = Beacon.Config.fetch!(site) - prefix = router.__beacon_scoped_prefix_for_site__(site) - endpoint.url() <> Beacon.Router.sanitize_path("#{prefix}/__beacon_assets__/css_config") - end - @doc false def compile(site) when is_atom(site) do Beacon.Config.fetch!(site).css_compiler.compile(site) diff --git a/lib/beacon/web/controllers/assets_controller.ex b/lib/beacon/web/controllers/assets_controller.ex index 0ead4cfa..2d225548 100644 --- a/lib/beacon/web/controllers/assets_controller.ex +++ b/lib/beacon/web/controllers/assets_controller.ex @@ -4,7 +4,7 @@ defmodule Beacon.Web.AssetsController do import Plug.Conn - def init(asset) when asset in [:css_config, :css, :js], do: asset + def init(asset) when asset in [:css, :js], do: asset def call(%{assigns: %{site: site}} = conn, asset) when asset in [:css, :js] do {content, content_type} = content_and_type(site, asset) @@ -22,22 +22,6 @@ defmodule Beacon.Web.AssetsController do |> halt() end - # TODO: encoding (compress) and caching - def call(%{assigns: %{site: site}} = conn, :css_config) do - {content, content_type} = content_and_type(site, :css_config) - - # The static files are served for sites, - # and we need to disable csrf protection because - # serving script files is forbidden by the CSRFProtection plug. - conn = put_private(conn, :plug_skip_csrf_protection, true) - - conn - |> put_resp_header("content-type", content_type) - |> put_resp_header("access-control-allow-origin", "*") - |> send_resp(200, content) - |> halt() - end - defp content_and_type(site, :css) do {Beacon.RuntimeCSS.fetch(site), "text/css"} end @@ -45,8 +29,4 @@ defmodule Beacon.Web.AssetsController do defp content_and_type(_site, :js) do {Beacon.RuntimeJS.fetch(), "text/javascript"} end - - defp content_and_type(site, :css_config) do - {Beacon.RuntimeCSS.config(site), "text/javascript"} - end end