gitcat
1{{define "content"}}
2{{$repo := .Data.Repo}}
3<header class="repo-head compact">
4 <div class="repo-title">
5 <span class="repo-icon lg" aria-hidden="true">
6 <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M4 5.5A1.5 1.5 0 0 1 5.5 4H9l1.5 2H18a1.5 1.5 0 0 1 1.5 1.5v9A1.5 1.5 0 0 1 18 18H5.5A1.5 1.5 0 0 1 4 16.5z"/></svg>
7 </span>
8 <div><h1>{{$repo.Name}}</h1></div>
9 </div>
10</header>
11{{template "repotabs" (dict "Repo" $repo "Ref" .Data.Ref "Tab" "code" "CanManage" .Data.CanManage "CommitCount" .Data.CommitCount "BranchCount" .Data.BranchCount)}}
12
13<div class="crumb-bar">
14 <a class="crumb" href="/{{$repo.Name}}/tree/{{.Data.Ref}}">{{$repo.Name}}</a><span class="sep">/</span>
15 {{range $i, $c := .Data.Breadcrumbs}}{{if $i}}<span class="sep">/</span>{{end}}{{if eq (add $i 1) (len $.Data.Breadcrumbs)}}<span class="crumb cur">{{$c.Name}}</span>{{else}}<a class="crumb" href="/{{$repo.Name}}/tree/{{$.Data.Ref}}/{{$c.Path}}">{{$c.Name}}</a>{{end}}{{end}}
16 <span class="crumb-actions">
17 <span class="muted">{{.Data.BlobSize}}{{if and (not .Data.IsBinary) .Data.LineCount}} · {{num .Data.LineCount}} 行{{end}}</span>
18 <a class="btn btn-mini" href="/{{$repo.Name}}/raw/{{.Data.Ref}}/{{.Data.Path}}">原始文件</a>
19 </span>
20</div>
21
22{{if .Data.LastCommit}}
23<div class="filebox-head standalone">
24 {{template "avin" (dict "N" .Data.LastCommit.Author "S" 26)}}
25 <span class="fc-author">{{.Data.LastCommit.Author}}</span>
26 <a class="fc-subject" href="/{{$repo.Name}}/commit/{{.Data.LastCommit.SHA}}">{{.Data.LastCommit.Subject}}</a>
27 <span class="muted">{{timeago .Data.LastCommit.When}}</span>
28</div>
29{{end}}
30
31<div class="card fileview">
32 {{if .Data.TooLarge}}
33 <div class="empty small"><p class="muted">文件较大(超过 2 MB),已跳过在线预览以避免占用服务器内存。</p><a class="btn btn-ghost" href="/{{$repo.Name}}/raw/{{.Data.Ref}}/{{.Data.Path}}">下载原始文件</a></div>
34 {{else if .Data.IsImage}}
35 <div class="imgview"><img src="/{{$repo.Name}}/raw/{{.Data.Ref}}/{{.Data.Path}}" alt="{{.Data.FileName}}"></div>
36 {{else if .Data.IsBinary}}
37 <div class="empty small"><p class="muted">这是一个二进制文件,无法直接预览。</p><a class="btn btn-ghost" href="/{{$repo.Name}}/raw/{{.Data.Ref}}/{{.Data.Path}}">下载文件</a></div>
38 {{else}}
39 <div class="codeview">
40 {{range $i, $line := .Data.Lines}}<div class="codeline"><span class="ln">{{add $i 1}}</span><span class="lc">{{$line}}</span></div>{{end}}
41 {{if .Data.TruncatedLines}}<div class="codeline more"><span class="ln">…</span><span class="lc">文件过长,仅显示前 5000 行</span></div>{{end}}
42 </div>
43 {{end}}
44</div>
45{{end}}