diff --git a/admin.html b/admin.html index f1e9808..ca6bbb7 100644 --- a/admin.html +++ b/admin.html @@ -425,13 +425,15 @@ // LOGIN // =========================== async function seedPosts() { - if (!confirm('Tämä korvaa KAIKKI nykyiset julkaisut oletussisällöllä (30 julkaisua). Jatketaanko?')) return; + if (!confirm('Tämä korvaa KAIKKI nykyiset julkaisut ja kategoriat oletussisällöllä. Jatketaanko?')) return; + // Seed categories first (needed for subcategories to work) + await apiPost('seed_categories', {}); const data = await apiPost('seed_posts', {}); if (data.ok) { const postsData = await apiGet('posts'); ADMIN.posts = postsData.posts || []; renderPostList(); - showToast('✅ Ladattu ' + data.count + ' julkaisua!'); + showToast('✅ Ladattu ' + data.count + ' julkaisua + kategoriat päivitetty!'); } else { showToast('⚠️ ' + (data.error || 'Virhe')); } diff --git a/api.php b/api.php index 1613bea..3a350f8 100644 --- a/api.php +++ b/api.php @@ -418,6 +418,12 @@ switch ($action) { writeData('posts.json', $posts); ok(['count' => count($posts)]); + case 'seed_categories': + if (!isAdmin()) err('Unauthorized', 403); + $cats = defaultCategories(); + writeData('categories.json', $cats); + ok(['count' => count($cats)]); + case 'admin_login': if (($body['password'] ?? '') === ADMIN_PASSWORD) { $_SESSION['tykkaafi_admin'] = true; diff --git a/index.html b/index.html index 586382e..88e819c 100644 --- a/index.html +++ b/index.html @@ -12,8 +12,7 @@

-
-
- - -
-
- - -
+
+ +
diff --git a/logo.svg b/logo.svg new file mode 100644 index 0000000..e2a7cc2 --- /dev/null +++ b/logo.svg @@ -0,0 +1,17 @@ + + + + + tykkää + + .fi + diff --git a/script.js b/script.js index a3079d3..d1fbf1c 100644 --- a/script.js +++ b/script.js @@ -507,8 +507,9 @@ async function submitPublicPost() { return; } - const emoji = document.getElementById('sub-emoji').value.trim() || '📝'; const category = document.getElementById('sub-category').value; + const cat = APP.categories.find(c => c.id === category); + const emoji = cat?.emoji || '📝'; const author = document.getElementById('sub-author').value.trim() || 'Vieras'; const desc = document.getElementById('sub-desc').value.trim(); const images = [ @@ -551,7 +552,7 @@ async function submitPublicPost() { renderCategoryFilters(); // Reset form fields - ['sub-title','sub-emoji','sub-author','sub-desc','sub-img1','sub-img2','sub-img3', + ['sub-title','sub-author','sub-desc','sub-img1','sub-img2','sub-img3', 'sub-time','sub-servings','sub-ingredients','sub-steps','sub-body'].forEach(id => { const el = document.getElementById(id); if (el) el.value = ''; diff --git a/style.css b/style.css index d726c21..877079e 100644 --- a/style.css +++ b/style.css @@ -51,6 +51,7 @@ header { } .logo-icon { font-size: 2.4rem; } +.logo-svg { height: 52px; width: auto; display: block; } header h1 { font-size: 2.4rem;