Site Builder
Editing:
index.php
writable 0666
<?php /* ---------- BUSINESS META & SINGLE PROMPT WITH NAVIGATION -------------------- */ $ph = $_GET['ph'] ?? ''; $idx = isset($_GET['idx']) ? (int)$_GET['idx'] : 0; // Business JSON $bizPath = $_SERVER['DOCUMENT_ROOT'] . "/ph/{$ph}/business.json"; $biz = is_readable($bizPath) ? json_decode(file_get_contents($bizPath), true) : []; // Metadata $name = $biz['name'] ?? 'Business Name'; $slogan = $biz['slogan'] ?? ''; $addressLine = implode(', ', array_filter([ $biz['address'] ?? '', $biz['city'] ?? '', $biz['state'] ?? '', $biz['zip'] ?? '' ])); $description = $biz['description'] ?? ''; $keywords = implode(', ', array_merge($biz['tags'] ?? [], $biz['location_tags'] ?? [])); // Prompts $promptsPath = $_SERVER['DOCUMENT_ROOT'] . "/ph/{$ph}/prompts.json"; $allPrompts = is_readable($promptsPath) ? json_decode(file_get_contents($promptsPath), true) : []; $total = count($allPrompts); if ($total > 0) { $idx = max(0, min($idx, $total - 1)); $currentText = $allPrompts[$idx]['prompt'] ?? ''; } else { $currentText = ''; } function firstWords(string $text, int $n = 4): string { $clean = preg_replace('/[^\p{L}\p{N}\s]+/u', '', $text); $words = preg_split('/\s+/u', trim($clean)); return implode(' ', array_slice($words, 0, $n)); } $prevLabel = $idx > 0 ? firstWords($allPrompts[$idx - 1]['prompt']) : ''; $nextLabel = $idx < $total - 1 ? firstWords($allPrompts[$idx + 1]['prompt']) : ''; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title><?= htmlspecialchars($name) ?></title> <meta name="description" content="<?= htmlspecialchars($description) ?>"> <meta name="keywords" content="<?= htmlspecialchars($keywords) ?>"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="/css/style.css"> <style> /* Quick button & form polish */ .nav-btn{ background:#5c3bff;color:#fff;padding:.45rem .9rem;border-radius:6px;text-decoration:none;font-weight:600;transition:.2s all; } .nav-btn:hover{background:#4433ff;box-shadow:0 2px 6px rgba(0,0,0,.15);} .Promptinator .token{color:#5c3bff;font-weight:600;cursor:pointer;} dialog::backdrop{background:rgba(0,0,0,.4);} dialog{border:none;border-radius:10px;} input,select,textarea,button{font-family:inherit;font-size:1rem;border:1px solid #ccd;border-radius:6px;padding:.35rem .55rem;} button{background:#5c3bff;color:#fff;cursor:pointer;} button:hover{background:#4433ff;} </style> <link rel="stylesheet" href="/css/Promptinator.css"> </head> <body> <header style="margin-bottom:1.2rem;"> <h1><?= htmlspecialchars($name) ?></h1> <?php if ($addressLine): ?><p><?= htmlspecialchars($addressLine) ?></p><?php endif; ?> <?php if ($slogan): ?><p><em><?= htmlspecialchars($slogan) ?></em></p><?php endif; ?> </header> <nav style="display:flex;justify-content:space-between;margin:1em 0;gap:1rem;"> <?php if ($prevLabel): ?> <a class="nav-btn prev" href="?ph=<?= urlencode($ph) ?>&idx=<?= $idx - 1 ?>">« <?= htmlspecialchars($prevLabel) ?></a> <?php else: ?><span></span><?php endif; ?> <?php if ($nextLabel): ?> <a class="nav-btn next" href="?ph=<?= urlencode($ph) ?>&idx=<?= $idx + 1 ?>"><?= htmlspecialchars($nextLabel) ?> »</a> <?php endif; ?> </nav> <div class="Promptinator" edit="1" think="1" data-prompt="<?= htmlspecialchars($currentText) ?>"> <?= htmlspecialchars($currentText) ?> </div> <script>window.businessData = <?= json_encode($biz, JSON_UNESCAPED_SLASHES) ?>;</script> <!-- Core then Business wrapper --> <script type="module"> import Promptinator from './businessPromptinator.js'; document.addEventListener('DOMContentLoaded', () => { document.querySelectorAll('.Promptinator').forEach(div => { Promptinator.init({ mount: div }); }); }); </script> </body> </html>
Save changes
Create folder
writable 0777
Create
Cancel