Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Show locked message in shared link
Uku Tahtdc8d20496cf6
diff --git a/lib/plausible_web/controllers/stats_controller.ex b/lib/plausible_web/controllers/stats_controller.exindex 10058c50d7..7641e20d31 100644--- a/lib/plausible_web/controllers/stats_controller.ex+++ b/lib/plausible_web/controllers/stats_controller.ex@@ -162,22 +162,32 @@ defmodule PlausibleWeb.StatsController doenddefp render_shared_link(conn, shared_link) do- conn- |> assign(:skip_plausible_tracking, true)- |> put_resp_header("x-robots-tag", "noindex")- |> delete_resp_header("x-frame-options")- |> render("stats.html",- site: shared_link.site,- has_goals: Plausible.Sites.has_goals?(shared_link.site),- title: "Plausible · " <> shared_link.site.domain,- offer_email_report: false,- demo: false,- skip_plausible_tracking: true,- shared_link_auth: shared_link.slug,- embedded: conn.params["embed"] == "true",- background: conn.params["background"],- theme: conn.params["theme"]- )+ cond do+ !shared_link.site.locked ->+ conn+ |> assign(:skip_plausible_tracking, true)+ |> put_resp_header("x-robots-tag", "noindex")+ |> delete_resp_header("x-frame-options")+ |> render("stats.html",+ site: shared_link.site,+ has_goals: Plausible.Sites.has_goals?(shared_link.site),+ title: "Plausible · " <> shared_link.site.domain,+ offer_email_report: false,+ demo: false,+ skip_plausible_tracking: true,+ shared_link_auth: shared_link.slug,+ embedded: conn.params["embed"] == "true",+ background: conn.params["background"],+ theme: conn.params["theme"]+ )++ shared_link.site.locked ->+ owner = Plausible.Sites.owner_for(shared_link.site)++ conn+ |> assign(:skip_plausible_tracking, true)+ |> render("site_locked.html", owner: owner, site: shared_link.site)+ endenddefp remove_email_report_banner(conn, site) dodiff --git a/lib/plausible_web/templates/stats/site_locked.html.eex b/lib/plausible_web/templates/stats/site_locked.html.eexindex abb7752761..bbe71587cc 100644--- a/lib/plausible_web/templates/stats/site_locked.html.eex+++ b/lib/plausible_web/templates/stats/site_locked.html.eex@@ -38,9 +38,11 @@This site is currently locked and cannot be accessed. You can check back later or contact the site owner to unlock it.</p></div>- <div class="mt-6 w-full text-center">- <%= link("Back to my sites", to: "/sites", class: "inline-flex items-center px-4 py-2 border border-transparent shadow-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 sm:text-sm") %>- </div>+ <%= if @conn.assigns[:current_user] do %>+ <div class="mt-6 w-full text-center">+ <%= link("Back to my sites", to: "/sites", class: "inline-flex items-center px-4 py-2 border border-transparent shadow-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 sm:text-sm") %>+ </div>+ <% end %><% end %></div></div>diff --git a/lib/plausible_web/templates/stats/waiting_first_pageview.html.eex b/lib/plausible_web/templates/stats/waiting_first_pageview.html.eexindex 01774ae664..91c896633f 100644--- a/lib/plausible_web/templates/stats/waiting_first_pageview.html.eex+++ b/lib/plausible_web/templates/stats/waiting_first_pageview.html.eex@@ -20,12 +20,12 @@<div class="my-44"><div class="block pulsating-circle"></div><p class="text-gray-600 dark:text-gray-400 text-xs absolute left-0 bottom-0 mb-6 w-full text-center leading-normal">- Need to see the snippet again? <%= link("Click here", to: "/#{URI.encode_www_form(@site.domain)}/snippet", class: "text-indigo-600 text-underline")%><br />- Not working? <%= link("Troubleshoot the integration", to: "https://plausible.io/docs/troubleshoot-integration#keep-seeing-a-blinking-green-dot", class: "text-indigo-600 text-underline", rel: "noreferrer") %> with our guide+ Need to see the snippet again? <%= link("Click here", to: "/#{URI.encode_www_form(@site.domain)}/snippet", class: "text-indigo-600 dark:text-indigo-500 text-underline")%><br />+ Not working? <%= link("Troubleshoot the integration", to: "https://plausible.io/docs/troubleshoot-integration#keep-seeing-a-blinking-green-dot", class: "text-indigo-600 dark:text-indigo-500 text-underline", rel: "noreferrer") %> with our guide<%= if Application.get_env(:plausible, :is_selfhost) do %>- first<br /> Still not working? Ask on our <%= link("community-supported forum", to: "https://github.com/plausible/analytics/discussions", class: "text-indigo-600 text-underline" ) %>+ first<br /> Still not working? Ask on our <%= link("community-supported forum", to: "https://github.com/plausible/analytics/discussions", class: "text-indigo-600 dark:text-indigo-500 text-underline" ) %><% else %>- first<br /> Still not working? <%= link("Contact us", to: "https://plausible.io/contact", class: "text-indigo-600 text-underline" ) %> and we will help you with your setup+ first<br /> Still not working? <%= link("Contact us", to: "https://plausible.io/contact", class: "text-indigo-600 dark:text-indigo-500 text-underline" ) %> and we will help you with your setup<% end %></p></div>diff --git a/test/plausible_web/controllers/stats_controller_test.exs b/test/plausible_web/controllers/stats_controller_test.exsindex b7bc91be54..207dea8885 100644--- a/test/plausible_web/controllers/stats_controller_test.exs+++ b/test/plausible_web/controllers/stats_controller_test.exs@@ -193,6 +193,16 @@ defmodule PlausibleWeb.StatsControllerTest doconn = get(conn, "/share/test-site.com/?auth=#{link.slug}")assert Plug.Conn.get_resp_header(conn, "x-frame-options") == []end++ test "shows locked page if page is locked", %{conn: conn} do+ site = insert(:site, domain: "test-site.com", locked: true)+ link = insert(:shared_link, site: site)++ conn = get(conn, "/share/test-site.com/?auth=#{link.slug}")++ assert html_response(conn, 200) =~ "Site locked"+ refute String.contains?(html_response(conn, 200), "Back to my sites")+ endenddescribe "POST /share/:slug/authenticate" do