feat(theme): restore database appearance linkage and IFRAME_READY
This commit is contained in:
parent
c2e809f44c
commit
408ac9645f
2 changed files with 132 additions and 104 deletions
|
|
@ -12,16 +12,8 @@
|
||||||
<script type="module" src="/src/main.tsx"></script>
|
<script type="module" src="/src/main.tsx"></script>
|
||||||
|
|
||||||
<!-- Theme Auto-Updater injected by autoblogia -->
|
<!-- Theme Auto-Updater injected by autoblogia -->
|
||||||
<script>
|
<script>
|
||||||
<!-- Theme Auto-Updater injected by autoblogia -->
|
function applySettings(settings) {
|
||||||
|
|
||||||
<!-- Theme Auto-Updater injected by autoblogia -->
|
|
||||||
|
|
||||||
<!-- Theme Auto-Updater injected by autoblogia -->
|
|
||||||
|
|
||||||
window.addEventListener('message', (event) => {
|
|
||||||
if (event.data && event.data.type === 'UPDATE_APPEARANCE') {
|
|
||||||
const settings = event.data.settings;
|
|
||||||
if (!settings) return;
|
if (!settings) return;
|
||||||
let css = '';
|
let css = '';
|
||||||
if (settings.primaryColor) {
|
if (settings.primaryColor) {
|
||||||
|
|
@ -53,20 +45,42 @@ window.addEventListener('message', (event) => {
|
||||||
}
|
}
|
||||||
css += "
|
css += "
|
||||||
:root { " +
|
:root { " +
|
||||||
"--font-sans: "" + settings.fontFamily + "", sans-serif !important; " +
|
"--font-sans: '" + settings.fontFamily + "', sans-serif !important; " +
|
||||||
"--font-serif: "" + settings.fontFamily + "", serif !important; " +
|
"--font-serif: '" + settings.fontFamily + "', serif !important; " +
|
||||||
"--font-mono: "" + settings.fontFamily + "", monospace !important; " +
|
"--font-mono: '" + settings.fontFamily + "', monospace !important; " +
|
||||||
"} * { font-family: "" + settings.fontFamily + "", sans-serif !important; }";
|
"} * { font-family: '" + settings.fontFamily + "', sans-serif !important; }";
|
||||||
}
|
}
|
||||||
let styleNode = document.getElementById('dynamic-theme-style');
|
let styleNode = document.getElementById('dynamic-theme-style');
|
||||||
if (!styleNode) { styleNode = document.createElement('style'); styleNode.id = 'dynamic-theme-style'; document.head.appendChild(styleNode); }
|
if (!styleNode) { styleNode = document.createElement('style'); styleNode.id = 'dynamic-theme-style'; document.head.appendChild(styleNode); }
|
||||||
styleNode.innerHTML = css;
|
styleNode.innerHTML = css;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.addEventListener('message', (event) => {
|
||||||
|
if (event.data && event.data.type === 'UPDATE_APPEARANCE') {
|
||||||
|
applySettings(event.data.settings);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
// Ping parent window that we are ready
|
|
||||||
window.parent.postMessage({ type: 'IFRAME_READY' }, '*');
|
window.parent.postMessage({ type: 'IFRAME_READY' }, '*');
|
||||||
|
|
||||||
</body>
|
// Fetch on load
|
||||||
|
try {
|
||||||
|
const host = window.location.hostname;
|
||||||
|
const SUPABASE_URL = 'https://ccfezpxxmwpngqhlsbxz.supabase.co';
|
||||||
|
const SUPABASE_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNjZmV6cHh4bXdwbmdxaGxzYnh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzU2ODk4NTcsImV4cCI6MjA5MTI2NTg1N30.TqXoUsunJoX9xQwOOq3PTugltyrMGn1OrZysO6C9hRM';
|
||||||
|
fetch(SUPABASE_URL + '/rest/v1/sites?select=settings&custom_domain=ilike.*' + host + '*', {
|
||||||
|
headers: {
|
||||||
|
'apikey': SUPABASE_KEY,
|
||||||
|
'Authorization': 'Bearer ' + SUPABASE_KEY
|
||||||
|
}
|
||||||
|
}).then(r => r.json()).then(data => {
|
||||||
|
if (data && data.length > 0 && data[0].settings) {
|
||||||
|
applySettings(data[0].settings);
|
||||||
|
}
|
||||||
|
}).catch(console.error);
|
||||||
|
} catch(e) {}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,16 +12,8 @@
|
||||||
<script type="module" src="/src/main.tsx"></script>
|
<script type="module" src="/src/main.tsx"></script>
|
||||||
|
|
||||||
<!-- Theme Auto-Updater injected by autoblogia -->
|
<!-- Theme Auto-Updater injected by autoblogia -->
|
||||||
<script>
|
<script>
|
||||||
<!-- Theme Auto-Updater injected by autoblogia -->
|
function applySettings(settings) {
|
||||||
|
|
||||||
<!-- Theme Auto-Updater injected by autoblogia -->
|
|
||||||
|
|
||||||
<!-- Theme Auto-Updater injected by autoblogia -->
|
|
||||||
|
|
||||||
window.addEventListener('message', (event) => {
|
|
||||||
if (event.data && event.data.type === 'UPDATE_APPEARANCE') {
|
|
||||||
const settings = event.data.settings;
|
|
||||||
if (!settings) return;
|
if (!settings) return;
|
||||||
let css = '';
|
let css = '';
|
||||||
if (settings.primaryColor) {
|
if (settings.primaryColor) {
|
||||||
|
|
@ -53,20 +45,42 @@ window.addEventListener('message', (event) => {
|
||||||
}
|
}
|
||||||
css += "
|
css += "
|
||||||
:root { " +
|
:root { " +
|
||||||
"--font-sans: "" + settings.fontFamily + "", sans-serif !important; " +
|
"--font-sans: '" + settings.fontFamily + "', sans-serif !important; " +
|
||||||
"--font-serif: "" + settings.fontFamily + "", serif !important; " +
|
"--font-serif: '" + settings.fontFamily + "', serif !important; " +
|
||||||
"--font-mono: "" + settings.fontFamily + "", monospace !important; " +
|
"--font-mono: '" + settings.fontFamily + "', monospace !important; " +
|
||||||
"} * { font-family: "" + settings.fontFamily + "", sans-serif !important; }";
|
"} * { font-family: '" + settings.fontFamily + "', sans-serif !important; }";
|
||||||
}
|
}
|
||||||
let styleNode = document.getElementById('dynamic-theme-style');
|
let styleNode = document.getElementById('dynamic-theme-style');
|
||||||
if (!styleNode) { styleNode = document.createElement('style'); styleNode.id = 'dynamic-theme-style'; document.head.appendChild(styleNode); }
|
if (!styleNode) { styleNode = document.createElement('style'); styleNode.id = 'dynamic-theme-style'; document.head.appendChild(styleNode); }
|
||||||
styleNode.innerHTML = css;
|
styleNode.innerHTML = css;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.addEventListener('message', (event) => {
|
||||||
|
if (event.data && event.data.type === 'UPDATE_APPEARANCE') {
|
||||||
|
applySettings(event.data.settings);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
// Ping parent window that we are ready
|
|
||||||
window.parent.postMessage({ type: 'IFRAME_READY' }, '*');
|
window.parent.postMessage({ type: 'IFRAME_READY' }, '*');
|
||||||
|
|
||||||
</body>
|
// Fetch on load
|
||||||
|
try {
|
||||||
|
const host = window.location.hostname;
|
||||||
|
const SUPABASE_URL = 'https://ccfezpxxmwpngqhlsbxz.supabase.co';
|
||||||
|
const SUPABASE_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNjZmV6cHh4bXdwbmdxaGxzYnh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzU2ODk4NTcsImV4cCI6MjA5MTI2NTg1N30.TqXoUsunJoX9xQwOOq3PTugltyrMGn1OrZysO6C9hRM';
|
||||||
|
fetch(SUPABASE_URL + '/rest/v1/sites?select=settings&custom_domain=ilike.*' + host + '*', {
|
||||||
|
headers: {
|
||||||
|
'apikey': SUPABASE_KEY,
|
||||||
|
'Authorization': 'Bearer ' + SUPABASE_KEY
|
||||||
|
}
|
||||||
|
}).then(r => r.json()).then(data => {
|
||||||
|
if (data && data.length > 0 && data[0].settings) {
|
||||||
|
applySettings(data[0].settings);
|
||||||
|
}
|
||||||
|
}).catch(console.error);
|
||||||
|
} catch(e) {}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue