diff --git a/app/templates/gitea_workspace.html b/app/templates/gitea_workspace.html index e3a1afe..9edbe05 100644 --- a/app/templates/gitea_workspace.html +++ b/app/templates/gitea_workspace.html @@ -6,7 +6,7 @@ {% block topbar %} {% set breadcrumb_items = [{"label": "Home", "url": "/workspaces"}, {"label": owner ~ "/" ~ repo, "url": None}] %} {% set page_icon = "🔗" %} -{% set right_actions = '⚙' %} +{% set right_actions = '⚙' %} {% include '_header.html' %} {% endblock %} @@ -310,63 +310,41 @@ function giteaWorkspace() { async loadSidebarTree() { try { var r = await fetch('/api/gitea/projects/' + this.owner + '/' + this.repo + '/tree'); - if (!r.ok) return; + if (!r.ok) { + // If API fails (e.g. no Gitea token), set a message + var container = document.getElementById('sidebar-workspace-items'); + if (container) container.innerHTML = ''; + return; + } var d = await r.json(); var items = d.tree || []; var container = document.getElementById('sidebar-workspace-items'); if (!container) return; + // Ensure workspace section is visible + if (window.appState && window.appState.sectionsOpen && !window.appState.sectionsOpen.workspace) { + window.appState.sectionsOpen.workspace = true; + } container.innerHTML = ''; - var self = this; - items.forEach(function(item) { + // Build tree HTML as string and set once (more performant) + var html = ''; + for (var i = 0; i < items.length; i++) { + var item = items[i]; var icon = item.type === 'folder' ? '📁' : '📄'; - var li = document.createElement('li'); - li.className = 'sidebar-item'; - li.setAttribute('data-gitea-path', item.path); - li.setAttribute('data-gitea-type', item.type === 'folder' ? 'folder' : 'file'); - li.setAttribute('data-gitea-sha', item.sha || ''); - li.style.cssText = 'padding-left:12px;cursor:pointer;display:flex;align-items:center;gap:4px;'; - // Checkbox (hidden by default, visible in multi-select mode) - var cb = document.createElement('input'); - cb.type = 'checkbox'; - cb.className = 'gitea-checkbox'; - cb.style.cssText = 'flex-shrink:0;margin:0;display:none;'; - cb.addEventListener('click', function(ev) { - ev.stopPropagation(); - self.selectItem(item.path, li, ev); - }); - li.appendChild(cb); - // Icon - var iconSpan = document.createElement('span'); - iconSpan.className = 'page-icon'; - iconSpan.textContent = icon; - li.appendChild(iconSpan); - // Name (with double-click rename) - var nameSpan = document.createElement('span'); - nameSpan.className = 'page-name'; - nameSpan.textContent = item.name; - nameSpan.addEventListener('dblclick', function(ev) { - ev.preventDefault(); - ev.stopPropagation(); - self.startInlineRename(nameSpan, item.path, li); - }); - li.appendChild(nameSpan); - container.appendChild(li); - }); + html += ''; + } // Add Private Pages link - var sep = document.createElement('li'); - sep.style.cssText = 'border-top:1px solid var(--border);margin:8px 0;'; - container.appendChild(sep); - var pli = document.createElement('li'); - pli.className = 'sidebar-item'; - pli.style.cssText = 'padding-left:12px;cursor:pointer;'; - pli.innerHTML = '🔒Private Pages'; - pli.addEventListener('click', function(e) { - e.preventDefault(); e.stopPropagation(); - self.showPrivate = true; self.showFile = false; self.showEditor = false; - self.loadPrivatePages(); - }); - container.appendChild(pli); - } catch(e) { console.error('Sidebar tree load failed:', e); } + html += '
  • '; + html += ''; + container.innerHTML = html; + // Re-attach event listeners + this.setupSidebarClicks(); + } catch(e) { + console.error('Gitea sidebar tree load failed:', e); + } }, setupSidebarClicks() { diff --git a/app/templates/page_editor.html b/app/templates/page_editor.html index 893e3f9..5d02c08 100644 --- a/app/templates/page_editor.html +++ b/app/templates/page_editor.html @@ -2,35 +2,11 @@ page_title %}{{ page.title }}{% endblock %} {% block topbar %} {% set page_icon = "📄" %} {% set page_title = page.title %} +{% set right_actions = 'Edited ▾' %} {% include '_header.html' %} {% endblock %} {% block content %}
    - -
    -
    - Edited ▾ - - - - +
    -
    -