explorer.html

96 lines
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
{{template "main.html" .}}

{{define "title"}}{{if explorer.Repo}}{{explorer.Repo.Name}}{{if explorer.Path}} / {{explorer.Path}}{{end}}{{else}}Explorer{{end}} — Congo Dev{{end}}

{{define "content"}}
{{if explorer.Repo}}
<!-- Header -->
<div class="flex items-center gap-3 mb-4">
    <a href="/" class="text-slate-300 hover:text-slate-500 transition-colors">
        <svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M15 19l-7-7 7-7" /></svg>
    </a>
    <div class="flex-1 min-w-0">
        <h1 class="text-lg font-bold text-slate-800 truncate">{{explorer.Repo.Name}}</h1>
        {{if explorer.Repo.Branch}}
        <p class="text-[11px] text-slate-400 font-mono mt-0.5">
            <span class="inline-flex items-center gap-1">
                <svg xmlns="http://www.w3.org/2000/svg" class="w-3 h-3" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M13 10V3L4 14h7v7l9-11h-7z" /></svg>
                {{explorer.Repo.Branch}}
            </span>
        </p>
        {{end}}
    </div>
</div>

<!-- Breadcrumbs -->
<div class="flex items-center gap-1 text-[12px] mb-3 flex-wrap font-mono" hx-boost="true">
    {{range $i, $crumb := explorer.Breadcrumbs}}
        {{if $i}}<span class="text-slate-300">/</span>{{end}}
        {{if eq $i 0}}
        <a href="/repos/{{explorer.Repo.ID}}/files" class="text-indigo-500 hover:text-indigo-700 transition-colors font-semibold">{{$crumb.Name}}</a>
        {{else}}
        <a href="/repos/{{explorer.Repo.ID}}/files/{{$crumb.Path}}" class="text-slate-500 hover:text-indigo-600 transition-colors">{{$crumb.Name}}</a>
        {{end}}
    {{end}}
</div>

{{if explorer.NotFound}}
<!-- Not Found -->
<div class="bg-white rounded-xl border border-slate-200/60 p-8 text-center">
    <p class="text-slate-400 text-sm mb-3">File not found: <code class="text-red-400 bg-red-50 px-1.5 py-0.5 rounded text-[12px]">{{explorer.Path}}</code></p>
    <a href="/repos/{{explorer.Repo.ID}}/files" class="text-indigo-500 hover:text-indigo-600 text-sm" hx-boost="true">Back to root</a>
</div>

{{else if explorer.IsFile}}
<!-- File View -->
<div class="bg-white rounded-xl border border-slate-200/60 overflow-hidden">
    <div class="flex items-center justify-between px-4 py-2.5 border-b border-slate-100">
        <div class="flex items-center gap-2">
            <svg xmlns="http://www.w3.org/2000/svg" class="w-3.5 h-3.5 text-slate-400" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5">
                <path stroke-linecap="round" stroke-linejoin="round" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
            </svg>
            <span class="text-sm font-medium text-slate-700 font-mono">{{explorer.File.Name}}</span>
        </div>
        <span class="text-[10px] text-slate-400 font-mono">{{explorer.File.Lines}} lines</span>
    </div>
    <div class="source-lines overflow-x-auto">
        <div class="line-nums">{{range explorer.File.LineNums}}{{.}}
{{end}}</div>
        <pre><code class="language-{{explorer.File.Lang}}">{{explorer.File.Content}}</code></pre>
    </div>
</div>

{{else}}
<!-- Directory View -->
<div class="bg-white rounded-xl border border-slate-200/60 overflow-hidden" hx-boost="true">
    {{range $entry := explorer.Entries}}
    <a href="/repos/{{explorer.Repo.ID}}/files/{{$entry.Path}}" class="flex items-center justify-between gap-3 px-4 py-2 border-b border-slate-50 last:border-b-0 hover:bg-slate-50/80 transition-colors group">
        <div class="flex items-center gap-2.5 min-w-0">
            {{if $entry.IsDir}}
            <svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4 text-indigo-400 shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5">
                <path stroke-linecap="round" stroke-linejoin="round" d="M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"/>
            </svg>
            {{else}}
            <svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4 text-slate-300 shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5">
                <path stroke-linecap="round" stroke-linejoin="round" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
            </svg>
            {{end}}
            <span class="text-[13px] font-mono truncate {{if $entry.IsDir}}text-slate-700 font-medium{{else}}text-slate-500{{end}}">{{$entry.Name}}</span>
        </div>
        {{if $entry.Size}}<span class="text-[10px] text-slate-300 font-mono shrink-0">{{$entry.Size}}</span>{{end}}
    </a>
    {{end}}
    {{if not explorer.Entries}}
    <div class="px-4 py-8 text-center text-slate-400 text-sm">Empty directory</div>
    {{end}}
</div>
{{end}}

{{else}}
<!-- No Repo -->
<div class="text-center py-16">
    <p class="text-slate-400 mb-3 text-sm">Repository not found</p>
    <a href="/" class="text-indigo-500 hover:text-indigo-600 text-sm">Back to Dashboard</a>
</div>
{{end}}
{{end}}