[object Object]

← back to Prestige Car Wash

Admin: persistent live-view <-> admin-view toggle

c1fd206c4c7134a53637035132bded7f91ee5530 · 2026-07-27 11:02:00 -0700 · Steve Abrams

Admin page sets a pcw.admin browser flag + shows a 'Live view' pill (-> /). Live customer
pages (via decorate) show a 'Admin view' pill (-> /admin) ONLY when that flag is set, so the
logged-in admin can always flip both ways while real customers never see it.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Files touched

Diff

commit c1fd206c4c7134a53637035132bded7f91ee5530
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Mon Jul 27 11:02:00 2026 -0700

    Admin: persistent live-view <-> admin-view toggle
    
    Admin page sets a pcw.admin browser flag + shows a 'Live view' pill (-> /). Live customer
    pages (via decorate) show a 'Admin view' pill (-> /admin) ONLY when that flag is set, so the
    logged-in admin can always flip both ways while real customers never see it.
    Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---
 public/admin/index.html | 11 +++++++++++
 server.js               |  4 ++++
 2 files changed, 15 insertions(+)

diff --git a/public/admin/index.html b/public/admin/index.html
index de0dd12..c18e271 100644
--- a/public/admin/index.html
+++ b/public/admin/index.html
@@ -663,6 +663,17 @@ function loadDrafts(){
   });
 }
 render();
+// Admin ↔ live-view toggle. Set the browser flag so live pages can show a "back to admin"
+// pill (invisible to customers), and add a persistent "Live view" pill here so the admin can
+// always flip to the public site and back.
+(function(){
+  try{ localStorage.setItem('pcw.admin','1'); }catch(e){}
+  var a=document.createElement('a');
+  a.href='/'; a.textContent='👁 Live view'; a.title='Switch to the live customer site';
+  a.setAttribute('aria-label','Switch to the live customer site');
+  a.style.cssText='position:fixed;left:12px;bottom:12px;z-index:95;background:var(--brand,#28c3ff);color:#001018;font:700 11px/1 system-ui,-apple-system,sans-serif;letter-spacing:.1em;text-transform:uppercase;padding:9px 13px;border-radius:6px;text-decoration:none;box-shadow:0 6px 18px rgba(0,0,0,.45)';
+  document.body.appendChild(a);
+})();
 </script>
 </body>
 </html>
diff --git a/server.js b/server.js
index 602ee86..2e8a286 100644
--- a/server.js
+++ b/server.js
@@ -823,6 +823,10 @@ function decorate(html, pagePath, ld) {
   }
   // Persistent mobile Book/Call bar on every customer page (guard against double-inject).
   if (!/class="mbar"/.test(html)) html = html.replace('</body>', mobileBar(pagePath) + '\n</body>');
+  // Admin ↔ live-view toggle: on customer pages show a "🔧 Admin" pill ONLY if this browser
+  // carries the pcw.admin flag (set when the admin visits /admin). Invisible to real customers;
+  // gives the logged-in admin a one-tap way back to the admin from any live page.
+  html = html.replace('</body>', `<script>(function(){try{if(localStorage.getItem('pcw.admin')!=='1')return;var a=document.createElement('a');a.href='/admin';a.textContent='🔧 Admin view';a.title='Switch to admin view';a.setAttribute('aria-label','Switch to admin view');a.style.cssText='position:fixed;left:12px;bottom:12px;z-index:95;background:#12100e;color:#c6a765;font:700 11px/1 system-ui,-apple-system,sans-serif;letter-spacing:.1em;text-transform:uppercase;padding:9px 13px;border-radius:6px;text-decoration:none;box-shadow:0 6px 18px rgba(0,0,0,.45);border:1px solid rgba(198,167,101,.45)';document.body.appendChild(a);}catch(e){}})();</script>\n</body>`);
   let inject = buildSocialTags(html, pagePath);
   // Perf: preconnect to the font-file origin (pages already preconnect googleapis; the actual
   // WOFF2 files come from gstatic, so this shaves a round-trip on first paint). Dedup-guarded.

← 5ff3476 Activate Google review CTA: set verified place_id (looked up  ·  back to Prestige Car Wash  ·  chore: v0.4.0 (session close) — 11 features shipped, place_i f947bb1 →