diff --git a/package.json b/package.json index 3fbfe68..64b5031 100644 --- a/package.json +++ b/package.json @@ -1,31 +1,7 @@ { - "flat": [ - { - "path": "posts/example.md", - "title": "Example Post", - "tags": ["tag1", "tag2"], - "isIndex": false, - "isPinned": true, - "ctime": 1731168000000, - "mtime": 1731168000000, - "ext": ".md", - "excerpt": "This is an example excerpt from the post content..." - }, - { - "path": "section/index.html", - "title": "Section Index", - "tags": [], - "isIndex": true, - "isPinned": false, - "ctime": 1731168000000, - "mtime": 1731168000000, - "ext": ".html", - "excerpt": "Welcome to the section..." - } - ], - "sections": ["posts", "section"], - "tags": ["tag1", "tag2"], - "hierarchies": { - "section": ["subsection"] + "name": "the-fold-within", + "version": "3.0.0", + "dependencies": { + "pdf-parse": "^1.1.1" } } diff --git a/public/app.js b/public/app.js index 23cfa28..cee598a 100755 --- a/public/app.js +++ b/public/app.js @@ -1,10 +1,3 @@ -/** - * app.js – v3.3.4 DIAGNOSTIC RESONANCE - * High-coherence, readable, maintainable. - * No hacks. No surgery. Only truth. - * Now with diagnostic overlays for rupture illumination. - */ - const els = { menuBtn: document.getElementById("menuBtn"), primaryNav: document.getElementById("primaryNav"), @@ -24,25 +17,12 @@ const els = { let indexData = null; let sidebarOpen = false; let currentParent = null; -let indexFiles = null; // Cached index files +let indexFiles = null; // Cached -// ΔTRUTH: Diagnostic overlay for error/clarity banners. -// Rationale: Fixed red banner for immediate visibility; z-index above topbar. -function showDiagnostic(message) { - const banner = document.createElement('div'); - banner.style = 'position: fixed; top: 0; left: 0; width: 100%; background: #ff4d4d; color: white; padding: 10px; z-index: 1001; text-align: center; font-weight: bold;'; - banner.innerHTML = message; - document.body.appendChild(banner); -} - -// === INITIALIZATION === async function init() { try { indexData = await (await fetch("index.json")).json(); - if (indexData.flat.length === 0) { - showDiagnostic('index.json loaded but no content files found. Add .md or .html files to public/ sections and run node tools/generate-index.mjs.'); - } - indexFiles = indexData.flat.filter(f => f.isIndex); + indexFiles = indexData.flat.filter(f => f.isIndex); // Cache populateNav(); populateSections(); populateTags(); @@ -50,14 +30,11 @@ async function init() { renderList(); handleHash(); window.addEventListener("hashchange", handleHash); - console.info('%cThe Fold Within: Harmony sustained.', 'color:#e0b84b'); } catch (e) { - showDiagnostic('Failed to load index.json. Check Network tab for 404 or console for errors. Ensure deployed from public/ directory and index.json is generated.'); - els.viewer.innerHTML = "
Failed to load site data. See diagnostic banner for fixes.
"; + els.viewer.innerHTML = "Failed to load site data.
"; } } -// === NAVIGATION === function populateNav() { els.primaryNav.innerHTML = 'Home'; const navSections = [...new Set( @@ -78,8 +55,11 @@ function populateSections() { els.sectionSelect.appendChild(opt); }); - const defaultSection = indexData.sections.includes("posts") ? "posts" : indexData.sections[0]; - if (defaultSection) els.sectionSelect.value = defaultSection; + if (indexData.sections.includes("posts")) { + els.sectionSelect.value = "posts"; + } else if (indexData.sections.length > 0) { + els.sectionSelect.value = indexData.sections[0]; + } } function populateTags() { @@ -90,7 +70,11 @@ function populateTags() { }); } -// === UI WIRING === +function formatTimestamp(ms) { + const d = new Date(ms); + return `${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,'0')}-${String(d.getDate()).padStart(2,'0')} ${String(d.getHours()).padStart(2,'0')}:${String(d.getMinutes()).padStart(2,'0')}`; +} + function wireUI() { els.menuBtn.addEventListener("click", () => { sidebarOpen = !sidebarOpen; @@ -111,7 +95,6 @@ function wireUI() { [els.tagSelect, els.sortSelect, els.searchMode].forEach(el => el.addEventListener("change", renderList)); els.searchBox.addEventListener("input", renderList); - // Close sidebar on content click (mobile) els.content.addEventListener("click", (e) => { if (window.innerWidth < 1024 && document.body.classList.contains("sidebar-open")) { if (!e.target.closest("#sidebar")) { @@ -122,7 +105,6 @@ function wireUI() { }); } -// === LIST RENDERING === function renderList() { const section = els.sectionSelect.value; const tags = Array.from(els.tagSelect.selectedOptions).map(o => o.value.toLowerCase()); @@ -142,13 +124,10 @@ function renderList() { posts.sort((a, b) => sort === "newest" ? b.mtime - a.mtime : a.mtime - b.mtime); els.postList.innerHTML = posts.length ? "" : "No content yet.
+No content yet.
`; } } else { - if (topSection) loadDefaultForSection(topSection); - else els.viewer.innerHTML = `No content yet.
`; + // No index → show children or fallback + if (topSection) { + els.sectionSelect.value = topSection; + renderList(); + loadDefaultForSection(topSection); + } else { + els.viewer.innerHTML = `No content yet.
`; + } } - } else { + } + // CASE: Direct file + else { const file = indexData.flat.find(f => f.path === rel); if (!file) { els.viewer.innerHTML = "Not found.
"; return; } - file.ext === ".md" ? await renderMarkdown(file.path) : await renderIframe("/" + file.path); + file.ext === ".md" ? await renderMarkdown(file.path) : renderIframe(file.path); } } @@ -237,80 +255,36 @@ async function renderMarkdown(rel) { els.viewer.innerHTML = `