AkurAI Build
Menu

Public repository / 705e1ce035ea4b9fb4c413dd38f550650185b571

AkurAI-Notes / site/frontend/app.html

Latest change b3a7784af2094889f6d5d4630b0cbd6d8ff94452 - release: v0.0.2 by Claude Code

{% include "header" %}
<script type="module" src="/signals.js"></script>
<main class="app-shell">
  <aside class="sidebar" data-scope="{notes:[], notebooks:[], activeNote:null}">
    <nav class="notebook-list">
      <h3>Notebooks</h3>
      <ul id="notebook-list">
        <template data-for="nb in notebooks">
          <li class="notebook-item" data-text="nb.name"></li>
        </template>
      </ul>
    </nav>
  </aside>
  <section class="content" id="notes-content"></section>
</main>
<script type="module">
  async function renderNotes() {
    const el = document.querySelector("[data-scope]");
    if (!el || !el.__signalsScope) return;
    try {
      const [notebooksRes, notesRes] = await Promise.all([
        fetch("/api/notebooks", { credentials: "same-origin" }),
        fetch("/api/notes", { credentials: "same-origin" }),
      ]);
      if (!notebooksRes.ok || !notesRes.ok) throw new Error("API error");
      const notebooks = await notebooksRes.json();
      const notes = await notesRes.json();

      el.__signalsScope.proxy.notebooks = notebooks;

      const content = document.getElementById("notes-content");
      if (notes.length === 0) {
        content.innerHTML = '<p class="empty-state">No notes found</p>';
      } else {
        content.innerHTML = notes.map(n =>
          '<article class="note-card">' +
            '<h3>' + esc(n.title || "Untitled") + '</h3>' +
            '<p class="note-preview">' + esc((n.body || "").substring(0, 200)) + '</p>' +
          '</article>'
        ).join("");
      }
    } catch (e) {
      document.getElementById("notes-content").innerHTML =
        '<p class="empty-state">Could not load data: ' + e.message + '</p>';
    }
  }
  function esc(s) { return s.replace(/[&<>"]/g, function(m) { return ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;'})[m]; }); }
  if (document.readyState === "loading") {
    document.addEventListener("DOMContentLoaded", renderNotes);
  } else {
    renderNotes();
  }
</script>
{% include "footer" %}