source.html

65 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
{{template "main.html" .}}

{{define "title"}}Source{{if source.Path}} — {{source.Path}}{{end}}{{end}}
{{define "description"}}Browse Congo's source code. Every file is available here — the framework, CLI, scaffold templates, and this website.{{end}}

{{define "content"}}
<div class="max-w-3xl mx-auto px-6 py-12">
    <!-- Breadcrumbs -->
    <div class="flex items-center gap-1.5 text-xs mb-6 flex-wrap" hx-boost="true">
        {{range $i, $crumb := source.Breadcrumbs}}
            {{if $i}}<span class="text-muted">/</span>{{end}}
            <a href="/source/{{$crumb.Path}}" class="text-muted hover:text-bright transition-colors font-mono">{{$crumb.Name}}</a>
        {{end}}
    </div>

    {{if source.NotFound}}
    <div class="py-12 text-center">
        <p class="text-muted text-sm mb-6">File not found: <code class="text-accent">{{source.Path}}</code></p>
        <a href="/source" class="btn-glow" hx-boost="true">Back to Source</a>
    </div>

    {{else if source.IsFile}}
    <!-- File View -->
    <div class="flex items-center justify-between mb-4">
        <h2 class="text-base font-mono text-bright">{{source.File.Name}}</h2>
        <span class="text-muted text-xs font-mono">{{source.File.Lines}} lines</span>
    </div>
    <div class="code-block source-lines">
        <div class="line-nums font-mono">{{range source.File.LineNums}}{{.}}
{{end}}</div>
        <pre><code class="language-{{source.File.Lang}}">{{source.File.Content}}</code></pre>
    </div>

    {{else}}
    <!-- Directory View -->
    {{if not source.Path}}
    <div class="mb-8">
        <h1 class="text-2xl font-bold tracking-tight mb-2">Source Code</h1>
        <p class="text-body text-sm leading-relaxed max-w-lg">
            Every file that makes up Congo. Run <code class="text-accent">congo source ./my-copy</code> to extract a buildable copy anywhere.
        </p>
    </div>
    {{end}}
    <div class="space-y-0" hx-boost="true">
        {{range $entry := source.Entries}}
        <a href="/source/{{$entry.Path}}" class="table-row items-center justify-between gap-3 py-2 px-2">
            <div class="flex items-center gap-3">
                {{if $entry.IsDir}}
                    <svg class="w-3.5 h-3.5 text-accent shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" 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 class="w-3.5 h-3.5 text-muted shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" 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="font-mono text-sm {{if $entry.IsDir}}text-bright{{else}}text-body{{end}}">{{$entry.Name}}</span>
            </div>
            {{if $entry.Size}}<span class="text-muted text-xs font-mono">{{$entry.Size}}</span>{{end}}
        </a>
        {{end}}
    </div>
    {{end}}
</div>
{{end}}