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
Merge snippet in genral
Uku Taht06e082ab23e6
diff --git a/lib/plausible_web/controllers/site_controller.ex b/lib/plausible_web/controllers/site_controller.exindex 31cdabd57c..7096026066 100644--- a/lib/plausible_web/controllers/site_controller.ex+++ b/lib/plausible_web/controllers/site_controller.ex@@ -92,6 +92,7 @@ defmodule PlausibleWeb.SiteController dodef settings_general(conn, %{"website" => website}) dosite = Sites.get_for_user!(conn.assigns[:current_user].id, website)+ |> Repo.preload(:custom_domain)conn|> assign(:skip_plausible_tracking, true)@@ -168,15 +169,6 @@ defmodule PlausibleWeb.SiteController do|> render("settings_custom_domain.html", site: site, layout: {PlausibleWeb.LayoutView, "site_settings.html"})end- def settings_snippet(conn, %{"website" => website}) do- site = Sites.get_for_user!(conn.assigns[:current_user].id, website)- |> Repo.preload(:custom_domain)-- conn- |> assign(:skip_plausible_tracking, true)- |> render("settings_snippet.html", site: site, layout: {PlausibleWeb.LayoutView, "site_settings.html"})- end-def settings_danger_zone(conn, %{"website" => website}) dosite = Sites.get_for_user!(conn.assigns[:current_user].id, website)diff --git a/lib/plausible_web/router.ex b/lib/plausible_web/router.exindex c7f069545e..ffe9f431ee 100644--- a/lib/plausible_web/router.ex+++ b/lib/plausible_web/router.ex@@ -151,7 +151,6 @@ defmodule PlausibleWeb.Router doget "/:website/settings/search-console", SiteController, :settings_search_consoleget "/:website/settings/email-reports", SiteController, :settings_email_reportsget "/:website/settings/custom-domain", SiteController, :settings_custom_domain- get "/:website/settings/js-snippet", SiteController, :settings_snippetget "/:website/settings/danger-zone", SiteController, :settings_danger_zoneget "/:website/goals/new", SiteController, :new_goalpost "/:website/goals", SiteController, :create_goaldiff --git a/lib/plausible_web/templates/layout/site_settings.html.eex b/lib/plausible_web/templates/layout/site_settings.html.eexindex e4c7430d29..67d66898e0 100644--- a/lib/plausible_web/templates/layout/site_settings.html.eex+++ b/lib/plausible_web/templates/layout/site_settings.html.eex@@ -30,7 +30,6 @@<%= render("_settings_tab.html", this_tab: "search-console", text: "Search Console", site: @site, conn: @conn) %><%= render("_settings_tab.html", this_tab: "email-reports", text: "Email reports", site: @site, conn: @conn) %><%= render("_settings_tab.html", this_tab: "custom-domain", text: "Custom domain", site: @site, conn: @conn) %>- <%= render("_settings_tab.html", this_tab: "js-snippet", text: "JS snippet", site: @site, conn: @conn) %><%= render("_settings_tab.html", this_tab: "danger-zone", text: "Danger zone", site: @site, conn: @conn) %></div></div>diff --git a/lib/plausible_web/templates/site/settings_general.html.eex b/lib/plausible_web/templates/site/settings_general.html.eexindex e0fe9c2f45..32282163de 100644--- a/lib/plausible_web/templates/site/settings_general.html.eex+++ b/lib/plausible_web/templates/site/settings_general.html.eex@@ -10,8 +10,7 @@</header><div class="grid grid-cols-4 gap-6">- <div class="col-span-4 sm:col-span-2">- <%= label f, :domain, class: "block text-sm font-medium leading-5 text-gray-700" %>+ <div class="col-span-4 sm:col-span-2"> <%= label f, :domain, class: "block text-sm font-medium leading-5 text-gray-700" %><%= text_input f, :domain, class: "mt-1 block w-full shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:max-w-xs sm:text-sm border-gray-300 rounded-md", disabled: "disabled" %></div>@@ -28,3 +27,23 @@</div></div><% end %>++<%= form_for @conn, "/", [class: "shadow bg-white sm:rounded-md sm:overflow-hidden py-6 px-4 sm:p-6"], fn f -> %>+ <header class="relative">+ <h2 class="text-lg leading-6 font-medium text-gray-900">Javascript snippet</h2>+ <p class="mt-1 text-sm leading-5 text-gray-500">Include this snippet in the <code><head></code> of your website.</p>++ <%= link(to: "https://docs.plausible.io/plausible-script", target: "_blank") do %>+ <svg class="w-6 h-6 absolute top-0 right-0 text-gray-400" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd"></path></svg>+ <% end %>+ </header>++ <div class="my-4">+ <div class="relative">+ <%= textarea f, :domain, id: "snippet_code", class: "transition overflow-hidden bg-gray-100 appearance-none border border-transparent rounded w-full p-2 pr-6 text-gray-700 leading-normal appearance-none focus:outline-none focus:bg-white focus:border-gray-300 text-xs mt-2 resize-none", value: snippet(@site), rows: 2 %>+ <a onclick="var textarea = document.getElementById('snippet_code'); textarea.focus(); textarea.select(); document.execCommand('copy');" href="javascript:void(0)" class="no-underline text-indigo-500 text-sm hover:underline">+ <svg class="absolute text-indigo-500" style="top: 24px; right: 12px;" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>+ </a>+ </div>+ </div>+<% end %>diff --git a/lib/plausible_web/templates/site/settings_snippet.html.eex b/lib/plausible_web/templates/site/settings_snippet.html.eexdeleted file mode 100644index a69d8e7c1f..0000000000--- a/lib/plausible_web/templates/site/settings_snippet.html.eex+++ /dev/null@@ -1,19 +0,0 @@-<%= form_for @conn, "/", [class: "shadow bg-white sm:rounded-md sm:overflow-hidden py-6 px-4 sm:p-6"], fn f -> %>- <header class="relative">- <h2 class="text-lg leading-6 font-medium text-gray-900">Javascript snippet</h2>- <p class="mt-1 text-sm leading-5 text-gray-500">Include this snippet in the <code><head></code> of your website.</p>-- <%= link(to: "https://docs.plausible.io/plausible-script", target: "_blank") do %>- <svg class="w-6 h-6 absolute top-0 right-0 text-gray-400" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd"></path></svg>- <% end %>- </header>-- <div class="my-4">- <div class="relative">- <%= textarea f, :domain, id: "snippet_code", class: "transition overflow-hidden bg-gray-100 appearance-none border border-transparent rounded w-full p-2 pr-6 text-gray-700 leading-normal appearance-none focus:outline-none focus:bg-white focus:border-gray-300 text-xs mt-2 resize-none", value: snippet(@site), rows: 2 %>- <a onclick="var textarea = document.getElementById('snippet_code'); textarea.focus(); textarea.select(); document.execCommand('copy');" href="javascript:void(0)" class="no-underline text-indigo-500 text-sm hover:underline">- <svg class="absolute text-indigo-500" style="top: 24px; right: 12px;" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>- </a>- </div>- </div>-<% end %>