diff --git a/lib/modules/legal/legal.ex b/lib/modules/legal/legal.ex index e2169761d..20121c2a1 100644 --- a/lib/modules/legal/legal.ex +++ b/lib/modules/legal/legal.ex @@ -38,7 +38,6 @@ defmodule PhoenixKit.Modules.Legal do alias PhoenixKit.Modules.Legal.PageType alias PhoenixKit.Modules.Legal.TemplateGenerator alias PhoenixKit.Settings - alias PhoenixKit.Utils.Routes @enabled_key "legal_enabled" @module_name "legal" @@ -552,26 +551,12 @@ defmodule PhoenixKit.Modules.Legal do - google_consent_mode: boolean - hide_for_authenticated: boolean - frameworks: list of framework IDs - - cookie_policy_url: string (backward compat, derived from published pages) - - privacy_policy_url: string (backward compat, derived from published pages) - - legal_links: list of %{title: string, url: string} for all published legal pages - - legal_index_url: string + - cookie_policy_url: string + - privacy_policy_url: string """ @spec get_consent_widget_config() :: map() def get_consent_widget_config do - legal_links = get_published_legal_links() - - cookie_policy_url = - case Enum.find(legal_links, &String.ends_with?(&1.url, "/cookie-policy")) do - %{url: url} -> url - nil -> Routes.path("/legal/cookie-policy") - end - - privacy_policy_url = - case Enum.find(legal_links, &String.ends_with?(&1.url, "/privacy-policy")) do - %{url: url} -> url - nil -> Routes.path("/legal/privacy-policy") - end + prefix = PhoenixKit.Config.get_url_prefix() %{ enabled: consent_widget_enabled?(), @@ -582,26 +567,11 @@ defmodule PhoenixKit.Modules.Legal do policy_version: get_auto_policy_version(), google_consent_mode: google_consent_mode_enabled?(), frameworks: get_selected_frameworks(), - cookie_policy_url: cookie_policy_url, - privacy_policy_url: privacy_policy_url, - legal_links: legal_links, - legal_index_url: Routes.path("/legal") + cookie_policy_url: "#{prefix}/legal/cookie-policy", + privacy_policy_url: "#{prefix}/legal/privacy-policy" } end - @doc """ - Returns a list of all published legal pages as link maps. - - Each map has `:title` and `:url` keys. Used by the cookie consent widget - to render dynamic links to all published legal pages. - """ - @spec get_published_legal_links() :: list(%{title: String.t(), url: String.t()}) - def get_published_legal_links do - list_generated_pages() - |> Enum.filter(&(&1.status == "published")) - |> Enum.map(&%{title: &1.title, url: Routes.path("/legal/#{&1.slug}")}) - end - @doc """ Check if there are unpublished legal pages that are required. diff --git a/lib/modules/sitemap/sources/publishing.ex b/lib/modules/sitemap/sources/publishing.ex index 7f6a8fd32..afa5f6b20 100644 --- a/lib/modules/sitemap/sources/publishing.ex +++ b/lib/modules/sitemap/sources/publishing.ex @@ -158,7 +158,7 @@ defmodule PhoenixKit.Modules.Sitemap.Sources.Publishing do UrlEntry.new(%{ loc: url, - lastmod: latest_post_date(slug, language), + lastmod: nil, changefreq: "daily", priority: 0.7, title: name, @@ -384,20 +384,6 @@ defmodule PhoenixKit.Modules.Sitemap.Sources.Publishing do end end - # Latest lastmod among published posts in a group (for group listing pages) - defp latest_post_date(group_slug, language) do - post_language = language || get_default_language() - - Publishing.list_posts(group_slug, post_language) - |> Enum.filter(&published?/1) - |> Enum.reject(&excluded?/1) - |> Enum.map(&get_post_lastmod/1) - |> Enum.reject(&is_nil/1) - |> Enum.max(Date, fn -> nil end) - rescue - _ -> nil - end - defp get_post_lastmod(post) do case post do # Check metadata fields first (PhoenixKit Publishing uses published_at) diff --git a/lib/modules/sitemap/sources/static.ex b/lib/modules/sitemap/sources/static.ex index 45408c3fa..636032418 100644 --- a/lib/modules/sitemap/sources/static.ex +++ b/lib/modules/sitemap/sources/static.ex @@ -199,7 +199,7 @@ defmodule PhoenixKit.Modules.Sitemap.Sources.Static do UrlEntry.new(%{ loc: url, - lastmod: static_lastmod(path), + lastmod: Date.utc_today(), changefreq: Map.get(config, "changefreq", "weekly"), priority: Map.get(config, "priority", 0.5), title: Map.get(config, "title", path), @@ -224,7 +224,7 @@ defmodule PhoenixKit.Modules.Sitemap.Sources.Static do UrlEntry.new(%{ loc: url, - lastmod: static_lastmod(path), + lastmod: Date.utc_today(), changefreq: Map.get(config, "changefreq", "weekly"), priority: Map.get(config, "priority", 0.5), title: Map.get(config, "title", path), @@ -237,25 +237,6 @@ defmodule PhoenixKit.Modules.Sitemap.Sources.Static do end end - # For homepage, use the latest published content date across all publishing groups. - # For other static pages, use today's date as a reasonable approximation. - defp static_lastmod("/") do - alias PhoenixKit.Modules.Sitemap.Sources.Publishing - - if Code.ensure_loaded?(Publishing) and function_exported?(Publishing, :collect, 1) do - Publishing.collect([]) - |> Enum.map(& &1.lastmod) - |> Enum.reject(&is_nil/1) - |> Enum.max(Date, fn -> Date.utc_today() end) - else - Date.utc_today() - end - rescue - _ -> Date.utc_today() - end - - defp static_lastmod(_path), do: Date.utc_today() - # Resolve path from config: explicit path OR via RouteResolver defp resolve_path(%{"path" => path}) when is_binary(path) and path != "" do path diff --git a/lib/phoenix_kit_web/components/core/cookie_consent.ex b/lib/phoenix_kit_web/components/core/cookie_consent.ex index 1e9c5e2eb..ed04a93b4 100644 --- a/lib/phoenix_kit_web/components/core/cookie_consent.ex +++ b/lib/phoenix_kit_web/components/core/cookie_consent.ex @@ -75,13 +75,6 @@ defmodule PhoenixKitWeb.Components.Core.CookieConsent do attr :policy_version, :string, default: "1.0", doc: "Policy version for consent tracking" attr :cookie_policy_url, :string, default: "/legal/cookie-policy" attr :privacy_policy_url, :string, default: "/legal/privacy-policy" - - attr :legal_links, :list, - default: [], - doc: "Dynamic list of %{title, url} for published legal pages" - - attr :legal_index_url, :string, default: "/legal", doc: "URL to legal pages index" - attr :google_consent_mode, :boolean, default: false, doc: "Enable Google Consent Mode v2" attr :class, :string, default: "" @@ -180,7 +173,7 @@ defmodule PhoenixKitWeb.Components.Core.CookieConsent do } .pk-glass { - background: oklch(var(--b1) / 0.98); + background: oklch(var(--b1) / 0.95); backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%); border: 1px solid var(--pk-border); @@ -197,6 +190,25 @@ defmodule PhoenixKitWeb.Components.Core.CookieConsent do transform: translateY(-2px); box-shadow: 0 4px 12px oklch(var(--bc) / 0.1); } + + .pk-toggle-track { + background: var(--pk-border); + transition: background-color 0.2s ease; + } + + .pk-toggle-track.active { + background: var(--pk-primary); + } + + .pk-toggle-thumb { + background: var(--pk-bg); + box-shadow: 0 1px 3px oklch(var(--bc) / 0.2); + transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1); + } + + input:checked + .pk-toggle-track .pk-toggle-thumb { + transform: translateX(20px); + } <%!-- Floating Icon (only for opt-in frameworks) --%> @@ -242,16 +254,17 @@ defmodule PhoenixKitWeb.Components.Core.CookieConsent do

{gettext("We value your privacy")}

-

+

{gettext( "We use cookies to enhance your browsing experience and analyze our traffic." )} {" "} - {gettext("Legal")} + {gettext("Cookie Policy")}

@@ -295,7 +308,7 @@ defmodule PhoenixKitWeb.Components.Core.CookieConsent do > <%!-- Backdrop --%>
@@ -315,7 +328,7 @@ defmodule PhoenixKitWeb.Components.Core.CookieConsent do

{gettext("Privacy Preferences")}

-

+

{gettext("Manage your cookie settings")}

@@ -343,7 +356,7 @@ defmodule PhoenixKitWeb.Components.Core.CookieConsent do <%= for category <- @categories do %>
@@ -361,21 +374,34 @@ defmodule PhoenixKitWeb.Components.Core.CookieConsent do <% end %>
-

+

{category.description}

- <%!-- Toggle --%> - + <%!-- Custom Toggle --%> + <% end %> @@ -385,12 +411,21 @@ defmodule PhoenixKitWeb.Components.Core.CookieConsent do
<%!-- Policy Links --%> -
+ diff --git a/lib/phoenix_kit_web/components/layout_wrapper.ex b/lib/phoenix_kit_web/components/layout_wrapper.ex index e557c0c41..5f77299a7 100644 --- a/lib/phoenix_kit_web/components/layout_wrapper.ex +++ b/lib/phoenix_kit_web/components/layout_wrapper.ex @@ -700,8 +700,6 @@ defmodule PhoenixKitWeb.Components.LayoutWrapper do policy_version={config.policy_version} cookie_policy_url={config.cookie_policy_url} privacy_policy_url={config.privacy_policy_url} - legal_links={config.legal_links} - legal_index_url={config.legal_index_url} google_consent_mode={config.google_consent_mode} /> <% end %>