nav_big.tmpl 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <aside class="w-64 border-r border-zinc-800 bg-zinc-900/50 flex flex-col">
  2. <div class="p-4 flex justify-between items-center border-b border-zinc-800">
  3. <span class="text-xs font-bold uppercase tracking-widest text-zinc-500">Main Vault</span>
  4. <span class="text-[10px] px-1.5 py-0.5 rounded bg-zinc-800 text-zinc-400 border border-zinc-700">v2.4</span>
  5. </div>
  6. <div class="flex-1 overflow-y-auto custom-scrollbar p-2 space-y-0.5">
  7. {{range .Subfoldere}}
  8. {{template "folder" .}}
  9. {{end}}
  10. {{range .Fisiere}}
  11. <a href="/notes/?note={{.Path}}"
  12. 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">
  13. {{/* File icon */}}
  14. <svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24"
  15. fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
  16. class="shrink-0 text-zinc-600">
  17. <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"/>
  18. <polyline points="14 2 14 8 20 8"/>
  19. </svg>
  20. <span class="truncate">{{.Nume}}</span>
  21. </a>
  22. {{end}}
  23. </div>
  24. {{/* BOTTOM: NEW ROOT FOLDER */}}
  25. <div class="p-2 border-t border-zinc-800">
  26. <form method="POST" action="/api/create_dir" class="flex gap-1 items-center">
  27. <input type="hidden" name="director" value="">
  28. <input
  29. type="text"
  30. name="subdirector"
  31. placeholder="New folder..."
  32. class="flex-1 bg-zinc-800 text-zinc-300 text-xs rounded px-2 py-1 outline-none border border-zinc-700 focus:border-zinc-500 placeholder-zinc-600"
  33. >
  34. <button type="submit"
  35. class="text-zinc-400 hover:text-zinc-100 hover:bg-zinc-700 rounded p-1 transition-colors border border-zinc-700"
  36. title="Create folder">
  37. {{/* Plus icon */}}
  38. <svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24"
  39. fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  40. <line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/>
  41. </svg>
  42. </button>
  43. </form>
  44. </div>
  45. </aside>
  46. {{define "folder"}}
  47. <details class="group" id="folder-{{.Nume}}"
  48. ontoggle="saveFolderState('folder-{{.Nume}}', this.open)">
  49. <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">
  50. <div class="flex items-center gap-1.5 min-w-0">
  51. {{/* Chevron */}}
  52. <svg xmlns="http://www.w3.org/2000/svg" width="11" height="11" viewBox="0 0 24 24"
  53. fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"
  54. class="shrink-0 transition-transform duration-150 group-open:rotate-90">
  55. <polyline points="9 18 15 12 9 6"/>
  56. </svg>
  57. {{/* Folder icon — closed */}}
  58. <svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24"
  59. fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
  60. class="shrink-0 text-zinc-500 group-open:hidden">
  61. <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"/>
  62. </svg>
  63. {{/* Folder icon — open */}}
  64. <svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24"
  65. fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
  66. class="shrink-0 text-zinc-300 hidden group-open:block">
  67. <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"/>
  68. <line x1="2" y1="10" x2="22" y2="10"/>
  69. </svg>
  70. <span class="truncate">{{.Nume}}</span>
  71. </div>
  72. {{/* ACTION BUTTONS — visible on hover only */}}
  73. <div class="flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity shrink-0">
  74. {{/* New note button */}}
  75. <form method="POST" action="/api/save_note">
  76. <input type="hidden" name="director" value="{{.Nume}}">
  77. <input type="hidden" name="titlu" value="Untitled">
  78. <input type="hidden" name="notita" value="">
  79. <button type="submit"
  80. onclick="event.stopPropagation()"
  81. class="text-zinc-500 hover:text-zinc-100 hover:bg-zinc-700 rounded p-0.5 transition-colors"
  82. title="New note">
  83. {{/* File plus icon */}}
  84. <svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24"
  85. fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  86. <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"/>
  87. <polyline points="14 2 14 8 20 8"/>
  88. <line x1="12" y1="18" x2="12" y2="12"/>
  89. <line x1="9" y1="15" x2="15" y2="15"/>
  90. </svg>
  91. </button>
  92. </form>
  93. {{/* New subfolder button */}}
  94. <button
  95. 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();"
  96. class="text-zinc-500 hover:text-zinc-100 hover:bg-zinc-700 rounded p-0.5 transition-colors"
  97. title="New folder">
  98. {{/* Folder plus icon */}}
  99. <svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24"
  100. fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  101. <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"/>
  102. <line x1="12" y1="13" x2="12" y2="19"/>
  103. <line x1="9" y1="16" x2="15" y2="16"/>
  104. </svg>
  105. </button>
  106. </div>
  107. </summary>
  108. {{/* INLINE FOLDER NAME INPUT */}}
  109. <form method="POST" action="/api/create_dir"
  110. class="new-folder-form gap-1 px-2 py-1 items-center"
  111. style="display:none;">
  112. <input type="hidden" name="director" value="{{.Nume}}">
  113. <input
  114. type="text"
  115. name="subdirector"
  116. placeholder="Folder name..."
  117. class="flex-1 bg-zinc-800 text-zinc-300 text-xs rounded px-2 py-1 outline-none border border-zinc-700 focus:border-zinc-500 placeholder-zinc-600"
  118. >
  119. <button type="submit"
  120. class="text-zinc-400 hover:text-zinc-100 hover:bg-zinc-700 rounded p-1 transition-colors border border-zinc-700">
  121. <svg xmlns="http://www.w3.org/2000/svg" width="11" height="11" viewBox="0 0 24 24"
  122. fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
  123. <polyline points="20 6 9 17 4 12"/>
  124. </svg>
  125. </button>
  126. </form>
  127. {{/* CHILDREN */}}
  128. <div class="ml-3 pl-2 border-l border-zinc-800 space-y-0.5 mt-0.5">
  129. {{range .Fisiere}}
  130. <a href="/notes/?note={{.Path}}"
  131. 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">
  132. <svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24"
  133. fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
  134. class="shrink-0 text-zinc-600">
  135. <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"/>
  136. <polyline points="14 2 14 8 20 8"/>
  137. </svg>
  138. <span class="truncate">{{.Nume}}</span>
  139. </a>
  140. {{end}}
  141. {{range .Subfoldere}}
  142. {{template "folder" .}}
  143. {{end}}
  144. </div>
  145. </details>
  146. {{end}}
  147. <script>
  148. function saveFolderState(id, isOpen) {
  149. const states = JSON.parse(localStorage.getItem('folderStates') || '{}');
  150. states[id] = isOpen;
  151. localStorage.setItem('folderStates', JSON.stringify(states));
  152. }
  153. function restoreFolderStates() {
  154. const states = JSON.parse(localStorage.getItem('folderStates') || '{}');
  155. document.querySelectorAll('details[id^="folder-"]').forEach(details => {
  156. const id = details.id;
  157. if (id in states) {
  158. details.open = states[id];
  159. } else {
  160. details.open = true; // default open on first visit
  161. }
  162. });
  163. }
  164. document.addEventListener('DOMContentLoaded', restoreFolderStates);
  165. </script>