{# WORKSPACE FILE TREE — one directory's entries (project-scoped). Rendered for a single directory under the selected project's repo_root and returned as an HTMX fragment. The ROOT listing is included by _workspace.html; each folder lazy-loads ITS OWN children (this same fragment) on first expand. Vars: entries : list[workspace.Entry] (dirs-first, then lexicographic; hidden incl.) ws_project_key : the scoped project key (for child hx-get URLs) ws_parent : rel-path of the directory these entries belong to ("" = root) ws_error : set when the directory could not be listed (escape / missing) Behaviour (matches the prototype): - Folder rows toggle open client-side (toggleTreeNode) and lazy-load children. - FILE rows OPEN IN THE CENTER PANE on click (openWsFile → preview, with an Edit toggle). Right column is the tree only; the center is preview + edit. - Every row carries a drag handle (move via drag-drop onto a folder) and a ⋯ button + right-click that opens the context menu (open · rename · move · new file/folder · delete). Hidden dotfiles render dimmed. #} {% if ws_error %} {% elif not entries %}
empty
{% else %} {% for e in entries %} {% set hidden = e.name.startswith('.') %} {%- set ext = e.name.rsplit('.', 1)[1] | lower if '.' in e.name else '' -%} {%- if e.name.endswith('.excalidraw.md') or e.name.endswith('.excalidraw') -%}{% set kind = 'excal' %} {%- elif ext in ('md','markdown') -%}{% set kind = 'md' %} {%- elif ext == 'py' -%}{% set kind = 'py' %} {%- elif ext in ('html','htm') -%}{% set kind = 'html' %} {%- elif ext == 'sql' -%}{% set kind = 'sql' %} {%- elif ext == 'json' -%}{% set kind = 'json' %} {%- elif ext in ('yaml','yml') -%}{% set kind = 'yaml' %} {%- elif ext in ('sh','bash','zsh') -%}{% set kind = 'sh' %} {%- elif ext == 'txt' -%}{% set kind = 'txt' %} {%- else -%}{% set kind = 'file' %}{%- endif -%}
{% if e.is_dir %} {# Folder row: toggles open/closed via JS; lazy-loads its children into the sibling .tchildren on the first open. Draggable + has its own ⋯ menu. #}
{% else %} {# File row: CLICK opens it in the CENTER pane in preview (openWsFile). Draggable (move) + ⋯ menu. Excalidraw and other files all open the same center pane; the pane renders the drawing or text per type. #} {% endif %}
{% endfor %} {% endif %}