Module: Abqari::ThemeBootstrap

Defined in:
lib/abqari/theme_bootstrap.rb

Overview

Tiny inline <script> injected into on every page. It reads the user's stored theme preference from localStorage and sets a data-theme attribute on before the document renders — so dark/light mode snaps in immediately, no flash of unstyled content.

Kept as a stable single-line string so its SHA256 hash is stable across builds. The hash is added to the CSP's script-src directive so the strict 'self'-only policy still allows this one inline script.

Constant Summary collapse

SCRIPT =
"(function(){var t=localStorage.getItem('theme');if(t)document.documentElement.setAttribute('data-theme',t)})()"
SHA256 =
"sha256-#{Base64.strict_encode64(Digest::SHA256.digest(SCRIPT))}"