Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -161,33 +161,39 @@ def admin_panel():
|
|
| 161 |
<div>
|
| 162 |
<h2 class="text-sm text-zinc-500 mb-4 uppercase">/// New Entry</h2>
|
| 163 |
<form id="blogForm" onsubmit="submitBlog(event)">
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
|
| 187 |
-
<button type="submit" class="btn w-full mt-2">PUBLISH DATA</button>
|
| 188 |
-
</form>
|
| 189 |
-
<div id="msg" class="mt-4 text-xs"></div>
|
| 190 |
-
</div>
|
| 191 |
|
| 192 |
<!-- PREVIEW LIST -->
|
| 193 |
<div>
|
|
@@ -199,6 +205,14 @@ def admin_panel():
|
|
| 199 |
</div>
|
| 200 |
|
| 201 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
// Auth Logic
|
| 203 |
function getAuth() { return localStorage.getItem('admin_key') || ''; }
|
| 204 |
function saveKey() {
|
|
@@ -208,7 +222,7 @@ def admin_panel():
|
|
| 208 |
loadBlogs();
|
| 209 |
}
|
| 210 |
document.getElementById('apiKey').value = getAuth();
|
| 211 |
-
|
| 212 |
// Fetch Blogs
|
| 213 |
async function loadBlogs() {
|
| 214 |
const res = await fetch('/blogs');
|
|
|
|
| 161 |
<div>
|
| 162 |
<h2 class="text-sm text-zinc-500 mb-4 uppercase">/// New Entry</h2>
|
| 163 |
<form id="blogForm" onsubmit="submitBlog(event)">
|
| 164 |
+
<label class="text-xs text-zinc-500">Title</label>
|
| 165 |
+
<input type="text" name="title" required class="input-field">
|
| 166 |
+
|
| 167 |
+
<label class="text-xs text-zinc-500">Image URL</label>
|
| 168 |
+
<input type="url" name="image" required class="input-field">
|
| 169 |
+
|
| 170 |
+
<label class="text-xs text-zinc-500">Link URL</label>
|
| 171 |
+
<input type="url" name="url" required class="input-field">
|
| 172 |
+
|
| 173 |
+
<label class="text-xs text-zinc-500">Summary</label>
|
| 174 |
+
<textarea name="summary" rows="3" required class="input-field"></textarea>
|
| 175 |
+
|
| 176 |
+
<label class="text-xs text-zinc-500">Full HTML Content</label>
|
| 177 |
+
<textarea name="content_html" rows="6" required class="input-field"></textarea>
|
| 178 |
+
|
| 179 |
+
<div class="flex gap-4">
|
| 180 |
+
<div class="w-1/2">
|
| 181 |
+
<label class="text-xs text-zinc-500">Author</label>
|
| 182 |
+
<input type="text" name="author" value="Admin" class="input-field">
|
| 183 |
+
</div>
|
| 184 |
+
<div class="w-1/2">
|
| 185 |
+
<label class="text-xs text-zinc-500">Date (YYYY-MM-DD)</label>
|
| 186 |
+
<input type="date" name="date" class="input-field text-zinc-400">
|
| 187 |
+
</div>
|
| 188 |
+
</div>
|
| 189 |
+
|
| 190 |
+
<button type="submit" class="btn w-full mt-2">PUBLISH DATA</button>
|
| 191 |
+
</form>
|
| 192 |
+
<h2 class="text-xs text-zinc-500 mt-6 mb-2 uppercase">/// Live Preview</h2>
|
| 193 |
+
<div class="border border-zinc-800 bg-zinc-900 p-4 h-64 overflow-auto" id="livePreview">
|
| 194 |
+
<p class="text-zinc-600 text-xs">Start typing HTML content to preview...</p>
|
| 195 |
+
</div>
|
| 196 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
|
| 198 |
<!-- PREVIEW LIST -->
|
| 199 |
<div>
|
|
|
|
| 205 |
</div>
|
| 206 |
|
| 207 |
<script>
|
| 208 |
+
const htmlField = document.querySelector('textarea[name="content_html"]');
|
| 209 |
+
const previewBox = document.getElementById('livePreview');
|
| 210 |
+
|
| 211 |
+
htmlField.addEventListener('input', () => {
|
| 212 |
+
const content = htmlField.value.trim();
|
| 213 |
+
previewBox.innerHTML = content || '<p class="text-zinc-600 text-xs">Start typing HTML content to preview...</p>';
|
| 214 |
+
});
|
| 215 |
+
|
| 216 |
// Auth Logic
|
| 217 |
function getAuth() { return localStorage.getItem('admin_key') || ''; }
|
| 218 |
function saveKey() {
|
|
|
|
| 222 |
loadBlogs();
|
| 223 |
}
|
| 224 |
document.getElementById('apiKey').value = getAuth();
|
| 225 |
+
|
| 226 |
// Fetch Blogs
|
| 227 |
async function loadBlogs() {
|
| 228 |
const res = await fetch('/blogs');
|