Click on a component to add it to the page.
+diff --git a/assets/css/custom.css b/assets/css/custom.css index d72383c..ac77069 100644 --- a/assets/css/custom.css +++ b/assets/css/custom.css @@ -74,4 +74,58 @@ body { /* Footer */ footer { border-top: 1px solid #E5E7EB; /* Gray-200 */ -} \ No newline at end of file +} + +/* Builder Page Styles */ +#sidebar { + position: fixed; + top: 0; + bottom: 0; + left: 0; + z-index: 100; + padding: 48px 0 0; /* Height of navbar */ + box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1); +} + +#component-list .nav-link { + font-weight: 500; + color: #333; +} + +#component-list .nav-link:hover { + color: #007bff; +} + +#canvas { + width: 100%; + min-height: 80vh; + background-color: #fff; + border: 1px solid #ddd; + border-radius: 0.5rem; +} + +.component-wrapper { + position: relative; + border: 1px dashed #ccc; + margin-bottom: 1rem; + padding: 1rem; +} + +.component-controls { + position: absolute; + top: 5px; + right: 5px; + display: none; + z-index: 1030; + background-color: rgba(255, 255, 255, 0.8); + border-radius: 5px; + padding: 2px; +} + +.component-wrapper:hover .component-controls { + display: block; +} + +.component-controls .btn { + margin-left: 5px; +} diff --git a/assets/js/main.js b/assets/js/main.js index e69de29..36ebfed 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -0,0 +1,64 @@ + +document.addEventListener('DOMContentLoaded', function () { + const componentList = document.getElementById('component-list'); + const canvas = document.getElementById('canvas'); + const initialCanvasMessage = canvas.querySelector('div'); + + let componentCounter = 0; + + function clearInitialMessage() { + if (canvas.contains(initialCanvasMessage)) { + canvas.innerHTML = ''; + } + } + + function addComponent(componentName) { + fetch(`components/${componentName}.php`) + .then(response => response.text()) + .then(html => { + clearInitialMessage(); + + componentCounter++; + const componentId = `component-${componentCounter}`; + + const wrapper = document.createElement('div'); + wrapper.classList.add('component-wrapper'); + wrapper.id = componentId; + wrapper.innerHTML = ` +
Click on a component to add it to the page.
+This is a short description of the image.
+This is a short description of the image.
+This is a short description of the image.
+Quickly design and customize responsive mobile-first sites with Bootstrap, the world’s most popular front-end open source toolkit.
+You are logged in as .
+You are logged in as .
diff --git a/db/config.php b/db/config.php index f12ebaf..c9871da 100644 --- a/db/config.php +++ b/db/config.php @@ -5,6 +5,8 @@ define('DB_NAME', 'app_31009'); define('DB_USER', 'app_31009'); define('DB_PASS', '2c66b530-2a65-423a-a106-6760b49ad1a2'); +require_once __DIR__ . '/../utils/logger.php'; + function db() { static $pdo; if (!$pdo) { diff --git a/index.php b/index.php index 4b6d0f0..8d69c4d 100644 --- a/index.php +++ b/index.php @@ -1,247 +1,5 @@ prepare("SELECT content FROM user_content WHERE user_id = ?"); - $stmt->execute([$_SESSION['user_id']]); - $user_content_row = $stmt->fetch(); - - if ($user_content_row) { - $content = json_decode($user_content_row['content'], true); - } else { - // New user, so create default content for them - $default_content_json = file_get_contents('db/content.json'); - $content = json_decode($default_content_json, true); - - $insert_stmt = $pdo->prepare("INSERT INTO user_content (user_id, content) VALUES (?, ?)"); - $insert_stmt->execute([$_SESSION['user_id'], $default_content_json]); - } -} else { - // User is not logged in, show default content - $content = json_decode(file_get_contents('db/content.json'), true); -} - - -// Handle content updates -if ($_SERVER['REQUEST_METHOD'] === 'POST' && $is_logged_in) { - $pdo = db(); - - // Fetch existing content to merge - $stmt = $pdo->prepare("SELECT content FROM user_content WHERE user_id = ?"); - $stmt->execute([$_SESSION['user_id']]); - $current_content_json = $stmt->fetchColumn(); - $current_content = json_decode($current_content_json, true); - - // Update with new values from POST - $current_content['hero_title'] = $_POST['hero_title'] ?? $current_content['hero_title']; - $current_content['hero_subtitle'] = $_POST['hero_subtitle'] ?? $current_content['hero_subtitle']; - $current_content['features_title'] = $_POST['features_title'] ?? $current_content['features_title']; - $current_content['feature_1_title'] = $_POST['feature_1_title'] ?? $current_content['feature_1_title']; - $current_content['feature_1_text'] = $_POST['feature_1_text'] ?? $current_content['feature_1_text']; - $current_content['feature_2_title'] = $_POST['feature_2_title'] ?? $current_content['feature_2_title']; - $current_content['feature_2_text'] = $_POST['feature_2_text'] ?? $current_content['feature_2_text']; - $current_content['feature_3_title'] = $_POST['feature_3_title'] ?? $current_content['feature_3_title']; - $current_content['feature_3_text'] = $_POST['feature_3_text'] ?? $current_content['feature_3_text']; - $current_content['about_title'] = $_POST['about_title'] ?? $current_content['about_title']; - $current_content['about_text'] = $_POST['about_text'] ?? $current_content['about_text']; - - $new_content_json = json_encode($current_content, JSON_PRETTY_PRINT); - - // Update the database - $update_stmt = $pdo->prepare("UPDATE user_content SET content = ? WHERE user_id = ?"); - $update_stmt->execute([$new_content_json, $_SESSION['user_id']]); - - // Redirect to avoid form resubmission - header("Location: " . $_SERVER['PHP_SELF']); - exit; -} - -// Default values -$hero_title = htmlspecialchars($content['hero_title'] ?? 'Build Your Dream Website'); -$hero_subtitle = htmlspecialchars($content['hero_subtitle'] ?? 'Visually design, customize, and publish beautiful, responsive websites. No code required.'); -$features_title = htmlspecialchars($content['features_title'] ?? 'Features'); -$feature_1_title = htmlspecialchars($content['feature_1_title'] ?? 'Visual Editor'); -$feature_1_text = htmlspecialchars($content['feature_1_text'] ?? 'Design and customize your site with a powerful, intuitive drag-and-drop editor.'); -$feature_2_title = htmlspecialchars($content['feature_2_title'] ?? 'Responsive Templates'); -$feature_2_text = htmlspecialchars($content['feature_2_text'] ?? 'Start with professionally designed, mobile-friendly templates that look great on any device.'); -$feature_3_title = htmlspecialchars($content['feature_3_title'] ?? 'One-Click Publishing'); -$feature_3_text = htmlspecialchars($content['feature_3_text'] ?? 'Go live instantly. We handle the hosting, security, and scaling for you.'); -$about_title = htmlspecialchars($content['about_title'] ?? 'About Us'); -$about_text = htmlspecialchars($content['about_text'] ?? 'We believe creating a website should be simple and accessible to everyone. Our mission is to empower creators with tools that are both powerful and easy to use.'); - -?> - - - - - -Please log in or create an account to edit the page content.
-