Bläddra i källkod

added old functionalities to new UI

turos.robert 1 vecka sedan
förälder
incheckning
6d06316a31

+ 2 - 2
cmds/webservice/bin/notes_folder/Carti/Crima-Si-Pedeapsa/notita-2026-03-24-211514.15892.json

@@ -1,6 +1,6 @@
 {
-  "titlu": "Untitled",
+  "titlu": "",
   "continut": "",
-  "director": "Carti/Crima-Si-Pedeapsa",
+  "director": "",
   "Path": "notes_folder/Carti/Crima-Si-Pedeapsa/notita-2026-03-24-211514.15892.json"
 }

+ 0 - 6
cmds/webservice/bin/notes_folder/Scoala/notita-2026-03-08-144007.727634.json

@@ -1,6 +0,0 @@
-{
-  "titlu": "Scoala",
-  "continut": "Trebuie să adaugi faviconul **în interiorul tagului `\u003chead\u003e`**.\r\n\r\nÎn cazul tău, îl pui **după `\u003ctitle\u003e` și înainte de scripturi**.\r\n\r\n### Modificarea corectă a codului tău\r\n\r\n```html\r\n\u003chead\u003e\r\n  \u003cmeta charset=\"UTF-8\"\u003e\r\n  \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"\u003e\r\n  \u003ctitle\u003eMyNote\u003c/title\u003e\r\n\r\n  \u003clink rel=\"icon\" type=\"image/png\" href=\"/favicon.png\"\u003e\r\n\r\n  \u003cscript src=\"https://cdn.tailwindcss.com\"\u003e\u003c/script\u003e\r\n\u003c/head\u003e\r\n```\r\n\r\n---\r\n\r\n### Unde trebuie să fie fișierul\r\n\r\nCel mai simplu este să pui:\r\n\r\n```\r\nfavicon.png\r\n```\r\n\r\nîn **același folder din care serverul tău servește fișiere statice**.\r\n\r\nDe exemplu dacă serverul tău servește:\r\n\r\n```\r\ntemplates/\r\n```\r\n\r\nsau\r\n\r\n```\r\nstatic/\r\n```\r\n\r\natunci structura ar putea fi:\r\n\r\n```\r\nmynotes/\r\n ├─ templates/\r\n │   ├─ index.html\r\n │   ├─ list_notes.tmpl\r\n │\r\n ├─ static/\r\n │   └─ favicon.png\r\n```\r\n\r\nși atunci linkul devine:\r\n\r\n```html\r\n\u003clink rel=\"icon\" type=\"image/png\" href=\"/static/favicon.png\"\u003e\r\n```\r\n\r\n---\r\n\r\n### Problema cea mai comună\r\n\r\nBrowserul **cache-uiește faviconul**.\r\nDacă nu apare:\r\n\r\n* apasă **Ctrl + Shift + R**\r\n* sau deschide pagina în **incognito**.\r\n\r\n---\r\n\r\n### Extra (recomandat pentru proiectul tău)\r\n\r\nAdaugă și:\r\n\r\n```html\r\n\u003clink rel=\"shortcut icon\" href=\"/favicon.png\"\u003e\r\n```\r\n\r\nUnele browsere îl caută așa.\r\n\r\n---\r\n\r\nDacă vrei, îți pot arăta și **cea mai curată metodă de a servi faviconul în Go în 3 linii**, fără să îți strice handlerul `Wildcard`.\r\n",
-  "director": "Scoala",
-  "Path": "notes_folder/Scoala/notita-2026-03-08-144007.727634.json"
-}

+ 0 - 6
cmds/webservice/bin/notes_folder/Scoala/notita-2026-03-21-130225.401224.json

@@ -1,6 +0,0 @@
-{
-  "titlu": "George Scoala",
-  "continut": "adfweyagfdyuwevbadwad",
-  "director": "Scoala",
-  "Path": "notes_folder/Scoala/notita-2026-03-21-130225.401224.json"
-}

+ 0 - 6
cmds/webservice/bin/notes_folder/notes_folder/Carti/Crima-Si-Pedeapsa/notita-2026-03-24-210133.110762.json

@@ -1,6 +0,0 @@
-{
-  "titlu": "Untitled",
-  "continut": "",
-  "director": "notes_folder/Carti/Crima-Si-Pedeapsa",
-  "Path": "notes_folder/notes_folder/Carti/Crima-Si-Pedeapsa/notita-2026-03-24-210133.110762.json"
-}

+ 0 - 6
cmds/webservice/bin/notes_folder/notes_folder/Carti/Crima-Si-Pedeapsa/test/test/notita-2026-03-24-221723.816195.json

@@ -1,6 +0,0 @@
-{
-  "titlu": "Untitled",
-  "continut": "",
-  "director": "notes_folder/Carti/Crima-Si-Pedeapsa/test/test",
-  "Path": "notes_folder/notes_folder/Carti/Crima-Si-Pedeapsa/test/test/notita-2026-03-24-221723.816195.json"
-}

+ 0 - 6
cmds/webservice/bin/notes_folder/notes_folder/Carti/Crima-Si-Pedeapsa/test/test/test/notita-2026-03-24-222006.279655.json

@@ -1,6 +0,0 @@
-{
-  "titlu": "Untitled",
-  "continut": "",
-  "director": "notes_folder/Carti/Crima-Si-Pedeapsa/test/test/test",
-  "Path": "notes_folder/notes_folder/Carti/Crima-Si-Pedeapsa/test/test/test/notita-2026-03-24-222006.279655.json"
-}

+ 0 - 6
cmds/webservice/bin/notes_folder/notes_folder/notita-2026-03-24-220159.897156.json

@@ -1,6 +0,0 @@
-{
-  "titlu": "Untitled",
-  "continut": "",
-  "director": "notes_folder",
-  "Path": "notes_folder/notes_folder/notita-2026-03-24-220159.897156.json"
-}

+ 3 - 3
cmds/webservice/bin/notes_folder/wadwasd/notita-2026-03-19-212505.434651.json

@@ -1,6 +1,6 @@
 {
-  "titlu": "wasdwa",
-  "continut": "dwasdws",
-  "director": "wadwasd",
+  "titlu": "",
+  "continut": "Cucaracha",
+  "director": "",
   "Path": "notes_folder/wadwasd/notita-2026-03-19-212505.434651.json"
 }

+ 167 - 75
cmds/webservice/bin/templates/design.tmpl

@@ -1,5 +1,42 @@
 {{showFile "templates/design/sections/head.tmpl"}}
 <body class="bg-zinc-950 text-zinc-200 h-screen overflow-hidden flex">
+
+{{/* DELETE CONFIRMATION MODAL */}}
+<div id="delete-modal" class="fixed inset-0 z-50 flex items-center justify-center hidden">
+    {{/* Backdrop */}}
+    <div class="absolute inset-0 bg-black/60 backdrop-blur-sm" onclick="hideDeleteModal()"></div>
+    
+    {{/* Modal box */}}
+    <div class="relative z-10 bg-zinc-900 border border-zinc-700 rounded-lg shadow-2xl w-80 p-5 flex flex-col gap-4">
+        <div class="flex items-start gap-3">
+            {{/* Warning icon */}}
+            <div class="shrink-0 text-red-400 mt-0.5">
+                <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24"
+                     fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+                    <path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/>
+                    <line x1="12" y1="9" x2="12" y2="13"/>
+                    <line x1="12" y1="17" x2="12.01" y2="17"/>
+                </svg>
+            </div>
+            <div>
+                <p class="text-sm font-medium text-zinc-100">Confirm Delete</p>
+                <p id="delete-modal-message" class="text-xs text-zinc-400 mt-1"></p>
+            </div>
+        </div>
+
+        <div class="flex justify-end gap-2">
+            <button onclick="hideDeleteModal()"
+                class="px-3 py-1.5 text-xs rounded border border-zinc-700 text-zinc-400 hover:text-zinc-100 hover:bg-zinc-800 transition-colors">
+                Cancel
+            </button>
+            <button id="delete-modal-confirm"
+                class="px-3 py-1.5 text-xs rounded bg-red-500/20 border border-red-500/50 text-red-400 hover:bg-red-500/30 hover:text-red-300 transition-colors">
+                Delete
+            </button>
+        </div>
+    </div>
+</div>
+
 {{showFile "templates/design/sections/nav_small.tmpl"}}
 
 {{template "nav_big.tmpl" .Folders}}
@@ -10,104 +47,159 @@
 
         <div class="flex-1 flex">
             <section class="flex-1 overflow-y-auto custom-scrollbar p-12">
-    <div class="w-full grid grid-cols-2 gap-0 border border-zinc-700">
        
+{{if .Notepath}}
+
+    {{/* NOTE ACTION BAR */}}
+    <div class="w-full mb-4 flex items-center justify-between gap-4 border border-zinc-700 bg-zinc-900/40 px-4 py-3">
+        <div class="min-w-0">
+            <p class="text-xs uppercase tracking-widest text-zinc-500">Opened Note</p>
+            <p class="text-sm text-zinc-200 truncate">{{.Notepath}}</p>
+        </div>
 
+        <div class="flex items-center gap-2 shrink-0">
+            <form id="save-note-form" method="POST" action="/api/update_note">
+                <input type="hidden" name="path" value="{{.Notepath}}">
+                <textarea id="hidden-note-content" name="notita" class="hidden"></textarea>
+
+                <button type="submit"
+                    class="inline-flex items-center gap-2 px-4 py-2 text-sm font-medium rounded border border-emerald-500/40 bg-emerald-500/10 text-emerald-400 hover:bg-emerald-500/20 hover:text-emerald-300 transition-colors">
+                    <svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24"
+                         fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+                        <path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/>
+                        <polyline points="17 21 17 13 7 13 7 21"/>
+                        <polyline points="7 3 7 8 15 8"/>
+                    </svg>
+                    Save Note
+                </button>
+            </form>
+        </div>
+    </div>
+
+    {{/* Editor + Preview */}}
+    <div class="w-full grid grid-cols-2 gap-0 border border-zinc-700">
         <div class="h-[85vh] bg-[#446454]">
             <textarea 
                 id="editor" 
                 placeholder="Start typing..."
                 class="p-6 w-full h-full bg-transparent text-zinc-100 text-[14px] focus:outline-none resize-none custom-scrollbar"
-            ></textarea>
+            >{{.Continut}}</textarea>
         </div>
         <div id="preview" class="border-r border-zinc-700 h-[85vh] bg-[#454644] p-2 text-zinc-100 overflow-y-auto font-sans prose prose-invert prose-zinc max-w-none
-    /* --- Code Blocks (Pre) --- */
-    [&_pre]:bg-zinc-900/80 [&_pre]:p-4 [&_pre]:rounded-lg [&_pre]:border [&_pre]:border-zinc-700 
-    [&_pre]:my-6 [&_pre]:overflow-x-auto [&_pre]:shadow-inner
-    
-    /* --- Inline Code (<code>) --- */
-    [&_code]:font-mono [&_code]:text-indigo-300 [&_code]:bg-zinc-800/50 
-    [&_code]:px-1.5 [&_code]:py-0.5 [&_code]:rounded [&_code]:text-[0.9em]
-    /* Evităm background-ul dublu când codul este în interiorul unui <pre> */
-    [&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:text-zinc-200 [&_pre_code]:text-[0.85em]
-
-    /* --- Stiluri Blockquote --- */
-    [&_blockquote]:border-l-4 [&_blockquote]:border-indigo-500 [&_blockquote]:bg-zinc-800/30 
-    [&_blockquote]:py-2 [&_blockquote]:px-5 [&_blockquote]:my-4 [&_blockquote]:italic [&_blockquote]:text-zinc-300
-    
-    /* --- Stiluri Bold & Italic --- */
-    [&_strong]:text-white [&_strong]:font-bold
-    [&_em]:text-indigo-200 [&_em]:italic
-
-    /* --- Stiluri pentru Tabele --- */
-    [&_table]:w-full [&_table]:my-6 [&_table]:border-collapse [&_table]:border [&_table]:border-zinc-600
-    [&_thead]:bg-zinc-800/50
-    [&_th]:border [&_th]:border-zinc-600 [&_th]:p-3 [&_th]:text-left [&_th]:text-indigo-300 [&_th]:uppercase [&_th]:text-[11px]
-    [&_td]:border [&_td]:border-zinc-600 [&_td]:p-3 [&_td]:text-sm
-    [&_tr:nth-child(even)]:bg-zinc-700/30
-
-    /* --- Stiluri pentru Liste & Headings --- */
-    [&_ul]:list-disc [&_ul]:ml-6 [&_ol]:list-decimal [&_ol]:ml-6
-    [&_h1]:text-3xl [&_h1]:font-bold [&_h1]:border-b [&_h1]:border-zinc-600 [&_h1]:pb-2 [&_h1]:mb-4
-    [&_h2]:text-xl [&_h2]:font-semibold [&_h2]:text-indigo-400 [&_h2]:mt-6 custom-scrollbar">
-            Your preview will appear here...
-        </div>
+/* --- Code Blocks (Pre) --- */
+[&_pre]:bg-zinc-900/80 [&_pre]:p-4 [&_pre]:rounded-lg [&_pre]:border [&_pre]:border-zinc-700 
+[&_pre]:my-6 [&_pre]:overflow-x-auto [&_pre]:shadow-inner
+/* --- Inline Code (<code>) --- */
+[&_code]:font-mono [&_code]:text-indigo-300 [&_code]:bg-zinc-800/50 
+[&_code]:px-1.5 [&_code]:py-0.5 [&_code]:rounded [&_code]:text-[0.9em]
+/* Evităm background-ul dublu când codul este în interiorul unui <pre> */
+[&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:text-zinc-200 [&_pre_code]:text-[0.85em]
+
+/* --- Stiluri Blockquote --- */
+[&_blockquote]:border-l-4 [&_blockquote]:border-indigo-500 [&_blockquote]:bg-zinc-800/30 
+[&_blockquote]:py-2 [&_blockquote]:px-5 [&_blockquote]:my-4 [&_blockquote]:italic [&_blockquote]:text-zinc-300
+/* --- Stiluri Bold & Italic --- */
+[&_strong]:text-white [&_strong]:font-bold
+[&_em]:text-indigo-200 [&_em]:italic
+
+/* --- Stiluri pentru Tabele --- */
+[&_table]:w-full [&_table]:my-6 [&_table]:border-collapse [&_table]:border [&_table]:border-zinc-600
+[&_thead]:bg-zinc-800/50
+[&_th]:border [&_th]:border-zinc-600 [&_th]:p-3 [&_th]:text-left [&_th]:text-indigo-300 [&_th]:uppercase [&_th]:text-[11px]
+[&_td]:border [&_td]:border-zinc-600 [&_td]:p-3 [&_td]:text-sm
+[&_tr:nth-child(even)]:bg-zinc-700/30
+
+/* --- Stiluri pentru Liste & Headings --- */
+[&_ul]:list-disc [&_ul]:ml-6 [&_ol]:list-decimal [&_ol]:ml-6
+[&_h1]:text-3xl [&_h1]:font-bold [&_h1]:border-b [&_h1]:border-zinc-600 [&_h1]:pb-2 [&_h1]:mb-4
+[&_h2]:text-xl [&_h2]:font-semibold [&_h2]:text-indigo-400 [&_h2]:mt-6 custom-scrollbar">
+Your preview will appear here...
+</div>
+    </div>
+{{else}}
+   {{/* EMPTY STATE */}}
+    <div class="flex-1 flex flex-col items-center justify-center gap-4 text-center h-[85vh]">
+        <svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24"
+             fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"
+             class="text-zinc-700">
+            <path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/>
+            <polyline points="14 2 14 8 20 8"/>
+        </svg>
+        <p class="text-zinc-600 text-sm">No note open</p>
+        <p class="text-zinc-700 text-xs">Select a file from the navigator or create a new one</p>
     </div>
+{{end}}
+
 </section>
             
             
         </div>
     </main>
 
+
+
 <script>
     const editor = document.getElementById('editor');
-const preview = document.getElementById('preview');
-
-// Debounce helper
-function debounce(func, delay) {
-    let timeout;
-    return function(...args) {
-        clearTimeout(timeout);
-        timeout = setTimeout(() => func.apply(this, args), delay);
-    };
-}
-
-// The API Call
-const updatePreview = async () => {
-    const content = editor.value;
-    
-    try {
-        const response = await fetch('/live_preview/', {
-            method: 'POST',
-            headers: { 'Content-Type': 'application/json' },
-            body: JSON.stringify({ markdown: content })
-        });
-
-        if (response.ok) {
-            const htmlResult = await response.text();
-            preview.innerHTML = htmlResult; 
-
-            // 1. Aplică etichetele de limbaj (codul de mai devreme)
-            preview.querySelectorAll('pre code').forEach((codeBlock) => {
-                const pre = codeBlock.parentElement;
-                const langClass = Array.from(codeBlock.classList).find(c => c.startsWith('language-'));
-                if (langClass) {
-                    pre.setAttribute('data-language', langClass.replace('language-', ''));
-                }
+    const preview = document.getElementById('preview');
+    const saveForm = document.getElementById('save-note-form');
+    const hiddenNoteContent = document.getElementById('hidden-note-content');
+
+    if (editor && preview){
+        // Debounce helper
+        function debounce(func, delay) {
+            let timeout;
+            return function(...args) {
+                clearTimeout(timeout);
+                timeout = setTimeout(() => func.apply(this, args), delay);
+            };
+        }
 
-                // 2. Declanșează evidențierea sintaxei
-                hljs.highlightElement(codeBlock);
+        // The API Call
+        const updatePreview = async () => {
+            const content = editor.value;
+            
+            try {
+                const response = await fetch('/live_preview/', {
+                    method: 'POST',
+                    headers: { 'Content-Type': 'application/json' },
+                    body: JSON.stringify({ markdown: content })
+                });
+
+                if (response.ok) {
+                    const htmlResult = await response.text();
+                    preview.innerHTML = htmlResult; 
+
+                    preview.querySelectorAll('pre code').forEach((codeBlock) => {
+                        const pre = codeBlock.parentElement;
+                        const langClass = Array.from(codeBlock.classList).find(c => c.startsWith('language-'));
+                        if (langClass) {
+                            pre.setAttribute('data-language', langClass.replace('language-', ''));
+                        }
+                        hljs.highlightElement(codeBlock);
+                    });
+
+                    console.log("Remote Preview & Highlighting Updated!");
+                }
+            } catch (error) {
+                console.error("Error:", error);
+            }
+        };
+
+        // Listen for input
+        editor.addEventListener('input', debounce(updatePreview, 100));
+
+        // sync editor content into hidden form field before save
+        if (saveForm && hiddenNoteContent) {
+            saveForm.addEventListener('submit', function () {
+                hiddenNoteContent.value = editor.value;
             });
+        }
 
-            console.log("Remote Preview & Highlighting Updated!");
+        // initial preview
+        if (editor.value.trim() !== '') {
+            updatePreview();
         }
-    } catch (error) {
-        console.error("Error:", error);
     }
-};
-
-// Listen for input, trigger every 500ms of "pause"
-editor.addEventListener('input', debounce(updatePreview, 100));
 </script>
 
 </body>

+ 75 - 33
cmds/webservice/bin/templates/design/sections/nav_big.tmpl

@@ -9,17 +9,7 @@
             {{template "folder" .}}
         {{end}}
         {{range .Fisiere}}
-            <a href="/notes/?note={{.Path}}"
-               class="flex items-center gap-2 px-2 py-1 text-xs rounded hover:bg-zinc-800 text-zinc-500 hover:text-zinc-300 transition-colors">
-                {{/* File icon */}}
-                <svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24"
-                     fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
-                     class="shrink-0 text-zinc-600">
-                    <path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/>
-                    <polyline points="14 2 14 8 20 8"/>
-                </svg>
-                <span class="truncate">{{.Nume}}</span>
-            </a>
+            {{template "file" .}}
         {{end}}
     </div>
 
@@ -36,7 +26,6 @@
             <button type="submit"
                 class="text-zinc-400 hover:text-zinc-100 hover:bg-zinc-700 rounded p-1 transition-colors border border-zinc-700"
                 title="Create folder">
-                {{/* Plus icon */}}
                 <svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24"
                      fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                     <line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/>
@@ -47,35 +36,63 @@
 </aside>
 
 
+{{/* ================= FILE TEMPLATE ================= */}}
+{{define "file"}}
+<div class="group/file flex items-center justify-between px-2 py-1 text-xs rounded hover:bg-zinc-800 text-zinc-500 hover:text-zinc-300 transition-colors">
+    <a href="/design_view/?note={{.Path}}" class="flex items-center gap-2 min-w-0 flex-1">
+        <svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24"
+             fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
+             class="shrink-0 text-zinc-600">
+            <path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/>
+            <polyline points="14 2 14 8 20 8"/>
+        </svg>
+        <span class="truncate">{{.Nume}}</span>
+    </a>
+
+{{/* DELETE FILE BUTTON */}}
+<form id="delete-file-{{.Path}}" method="POST" action="/api/delete_file">
+    <input type="hidden" name="path" value="{{.Path}}">
+    <button type="button"
+        onclick="event.stopPropagation(); showDeleteModal('Delete {{.Nume}}? This cannot be undone.', 'delete-file-{{.Path}}')"
+        class="opacity-0 group-hover/file:opacity-100 transition-opacity text-zinc-600 hover:text-red-400 rounded p-0.5"
+        title="Delete note">
+        <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24"
+             fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+            <polyline points="3 6 5 6 21 6"/>
+            <path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"/>
+            <path d="M10 11v6M14 11v6"/>
+            <path d="M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/>
+        </svg>
+    </button>
+</form>
+</div>
+{{end}}
+
+
+{{/* ================= FOLDER TEMPLATE ================= */}}
 {{define "folder"}}
 <details class="group" id="folder-{{.Nume}}"
          ontoggle="saveFolderState('folder-{{.Nume}}', this.open)">
 
     <summary class="flex items-center justify-between px-2 py-1 text-xs rounded hover:bg-zinc-800 cursor-pointer list-none text-zinc-400 group-open:text-zinc-200 transition-colors">
         <div class="flex items-center gap-1.5 min-w-0">
-            {{/* Chevron */}}
             <svg xmlns="http://www.w3.org/2000/svg" width="11" height="11" viewBox="0 0 24 24"
                  fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"
                  class="shrink-0 transition-transform duration-150 group-open:rotate-90">
                 <polyline points="9 18 15 12 9 6"/>
             </svg>
-
-            {{/* Folder icon — closed */}}
             <svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24"
                  fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
                  class="shrink-0 text-zinc-500 group-open:hidden">
                 <path d="M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z"/>
             </svg>
-
-            {{/* Folder icon — open */}}
             <svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24"
                  fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
                  class="shrink-0 text-zinc-300 hidden group-open:block">
                 <path d="M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z"/>
                 <line x1="2" y1="10" x2="22" y2="10"/>
             </svg>
-
-            <span class="truncate">{{.Nume}}</span>
+            <span class="truncate">{{.Display}}</span>
         </div>
 
         {{/* ACTION BUTTONS — visible on hover only */}}
@@ -90,7 +107,6 @@
                     onclick="event.stopPropagation()"
                     class="text-zinc-500 hover:text-zinc-100 hover:bg-zinc-700 rounded p-0.5 transition-colors"
                     title="New note">
-                    {{/* File plus icon */}}
                     <svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24"
                          fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                         <path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/>
@@ -106,7 +122,6 @@
                 onclick="event.stopPropagation(); var f = this.closest('details').querySelector('.new-folder-form'); f.style.display = f.style.display === 'none' ? 'flex' : 'none'; f.querySelector('input[type=text]').focus();"
                 class="text-zinc-500 hover:text-zinc-100 hover:bg-zinc-700 rounded p-0.5 transition-colors"
                 title="New folder">
-                {{/* Folder plus icon */}}
                 <svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24"
                      fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                     <path d="M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z"/>
@@ -114,6 +129,24 @@
                     <line x1="9" y1="16" x2="15" y2="16"/>
                 </svg>
             </button>
+
+            {{/* DELETE FOLDER BUTTON */}}
+<form id="delete-dir-{{.Nume}}" method="POST" action="/api/delete_dir">
+    <input type="hidden" name="path" value="{{.Nume}}">
+    <button type="button"
+        onclick="event.stopPropagation(); showDeleteModal('Delete {{.Display}} and everything inside it? This cannot be undone.', 'delete-dir-{{.Nume}}')"
+        class="text-zinc-500 hover:text-red-400 rounded p-0.5 transition-colors"
+        title="Delete folder">
+        <svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24"
+             fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+            <polyline points="3 6 5 6 21 6"/>
+            <path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"/>
+            <path d="M10 11v6M14 11v6"/>
+            <path d="M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/>
+        </svg>
+    </button>
+</form>
+
         </div>
     </summary>
 
@@ -140,16 +173,7 @@
     {{/* CHILDREN */}}
     <div class="ml-3 pl-2 border-l border-zinc-800 space-y-0.5 mt-0.5">
         {{range .Fisiere}}
-            <a href="/notes/?note={{.Path}}"
-               class="flex items-center gap-2 px-2 py-1 text-xs rounded hover:bg-zinc-800 text-zinc-500 hover:text-zinc-300 transition-colors">
-                <svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24"
-                     fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
-                     class="shrink-0 text-zinc-600">
-                    <path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/>
-                    <polyline points="14 2 14 8 20 8"/>
-                </svg>
-                <span class="truncate">{{.Nume}}</span>
-            </a>
+            {{template "file" .}}
         {{end}}
         {{range .Subfoldere}}
             {{template "folder" .}}
@@ -159,6 +183,7 @@
 </details>
 {{end}}
 
+
 <script>
     function saveFolderState(id, isOpen) {
         const states = JSON.parse(localStorage.getItem('folderStates') || '{}');
@@ -173,10 +198,27 @@
             if (id in states) {
                 details.open = states[id];
             } else {
-                details.open = true; // default open on first visit
+                details.open = true;
             }
         });
     }
 
     document.addEventListener('DOMContentLoaded', restoreFolderStates);
-</script>
+function showDeleteModal(message, formId) {
+    document.getElementById('delete-modal-message').textContent = message;
+    document.getElementById('delete-modal-confirm').onclick = function() {
+        document.getElementById(formId).submit();
+    };
+    document.getElementById('delete-modal').classList.remove('hidden');
+}
+
+function hideDeleteModal() {
+    document.getElementById('delete-modal').classList.add('hidden');
+}
+
+// Close on Escape key
+document.addEventListener('keydown', function(e) {
+    if (e.key === 'Escape') hideDeleteModal();
+});
+</script>
+

+ 26 - 8
lib/server/endpoint_funcs.go

@@ -18,7 +18,7 @@ import (
 	"github.com/yuin/goldmark/extension"
 )
 
-func Notes(w http.ResponseWriter, r *http.Request, fisier string) {
+/*func Notes(w http.ResponseWriter, r *http.Request, fisier string) {
 	var buf bytes.Buffer
 	notita := types.Notita{}
 	err := inout.FileToObj(fisier, &notita)
@@ -36,7 +36,7 @@ func Notes(w http.ResponseWriter, r *http.Request, fisier string) {
 	w.Write(resp)
 }
 
-func ListNotes(w http.ResponseWriter, r *http.Request, s *Server) {
+/*func ListNotes(w http.ResponseWriter, r *http.Request, s *Server) {
 
 	if r.Method == "GET" {
 		f := inout.Folder{}
@@ -53,9 +53,9 @@ func ListNotes(w http.ResponseWriter, r *http.Request, s *Server) {
 	}
 	w.WriteHeader(http.StatusMethodNotAllowed)
 	w.Write([]byte("methoda nepermisa"))
-}
+}*/
 
-func EditNotes(w http.ResponseWriter, r *http.Request, filename string) {
+/*func EditNotes(w http.ResponseWriter, r *http.Request, filename string) {
 
 	if r.Method == "GET" {
 		f := types.Notita{}
@@ -70,7 +70,7 @@ func EditNotes(w http.ResponseWriter, r *http.Request, filename string) {
 		return
 	}
 	WriteError(w, fmt.Errorf("method %s not allowed", r.Method))
-}
+}*/
 
 func MDToHTML(w http.ResponseWriter, r *http.Request) {
 	body, err := io.ReadAll(r.Body)
@@ -183,7 +183,19 @@ func API(w http.ResponseWriter, r *http.Request, s *Server) {
 	w.Write(resp)
 }
 
-func Design_viewer(w http.ResponseWriter, r *http.Request, s *Server) {
+func Design_viewer(w http.ResponseWriter, r *http.Request, s *Server, filename string) {
+	var continut string
+	if filename == "" {
+		continut = ""
+	} else {
+		var note types.Notita
+		err := inout.FileToObj(filename, &note)
+		if err != nil {
+			WriteError(w, err)
+			return
+		}
+		continut = note.Continut
+	}
 	f := inout.Folder{}
 	err := inout.GetFolderStructure(s.NotesDir, &f)
 	if err != nil {
@@ -191,9 +203,15 @@ func Design_viewer(w http.ResponseWriter, r *http.Request, s *Server) {
 		return
 	}
 	data := struct {
-		Folders inout.Folder
+		Folders  inout.Folder
+		Continut string
+		Notepath string
+		Titlu    string
 	}{
-		Folders: f,
+		Folders:  f,
+		Continut: continut,
+		Notepath: filename,
+		Titlu:    "lapte",
 	}
 	renderPage(w, []string{
 		"templates/design.tmpl",

+ 4 - 3
lib/server/handlers.go

@@ -73,7 +73,7 @@ func findRoute(path string, routes map[string]string) (string, bool) {
 
 func makeFuncMap() map[string]hfunc {
 	handlers := map[string]hfunc{
-		"VIEW_NOTE": func(w http.ResponseWriter, r *http.Request) {
+		/*"VIEW_NOTE": func(w http.ResponseWriter, r *http.Request) {
 			note := r.URL.Query().Get("note")
 			Notes(w, r, note)
 		},
@@ -88,7 +88,7 @@ func makeFuncMap() map[string]hfunc {
 				srv.Err = err
 			}
 			ListNotes(w, r, &srv)
-		},
+		},*/
 		"API": func(w http.ResponseWriter, r *http.Request) {
 			srv := Server{}
 			err := inout.FileToObj("mynotes_cfg.json", &srv)
@@ -99,12 +99,13 @@ func makeFuncMap() map[string]hfunc {
 		},
 		"MKDOWN_CONVERT": MDToHTML,
 		"DESIGN_VIEW": func(w http.ResponseWriter, r *http.Request) {
+			note := r.URL.Query().Get("note")
 			srv := Server{}
 			err := inout.FileToObj("mynotes_cfg.json", &srv)
 			if err != nil {
 				srv.Err = err
 			}
-			Design_viewer(w, r, &srv)
+			Design_viewer(w, r, &srv, note)
 		},
 	}
 	return handlers