forked from
tangled.org/core
Monorepo for Tangled — https://tangled.org
1{{ define "title" }} commit {{ .Diff.Commit.This }} · {{ .RepoInfo.FullName }} {{ end }}
2
3{{ define "repoContent" }}
4
5{{ $repo := .RepoInfo.FullName }}
6{{ $commit := .Diff.Commit }}
7{{ $stat := .Diff.Stat }}
8{{ $diff := .Diff.Diff }}
9
10<section class="commit">
11 <div id="commit-message">
12 {{ $messageParts := splitN $commit.Message "\n\n" 2 }}
13 <div>
14 <p class="pb-2">{{ index $messageParts 0 }}</p>
15 {{ if gt (len $messageParts) 1 }}
16 <p class="mt-1 cursor-text pb-2 text-sm">{{ nl2br (unwrapText (index $messageParts 1)) }}</p>
17 {{ end }}
18 </div>
19 </div>
20
21 <div class="flex items-center">
22 <p class="text-sm text-gray-500">
23 <a href="mailto:{{ $commit.Author.Email }}" class="no-underline hover:underline text-gray-500">{{ $commit.Author.Name }}</a>
24 <span class="px-1 select-none before:content-['\00B7']"></span>
25 {{ timeFmt $commit.Author.When }}
26 <span class="px-1 select-none before:content-['\00B7']"></span>
27 <span>{{ $stat.FilesChanged }}</span> files <span class="font-mono">(+{{ $stat.Insertions }}, -{{ $stat.Deletions }})</span>
28 <span class="px-1 select-none before:content-['\00B7']"></span>
29 </p>
30
31 <p class="flex items-center text-sm text-gray-500">
32 <a href="/{{ $repo }}/commit/{{ $commit.This }}" class="no-underline hover:underline text-gray-500">{{ slice $commit.This 0 8 }}</a>
33 {{ if $commit.Parent }}
34 <i class="w-3 h-3 mx-1" data-lucide="arrow-left"></i>
35 <a href="/{{ $repo }}/commit/{{ $commit.Parent }}" class="no-underline hover:underline text-gray-500">{{ slice $commit.Parent 0 8 }}</a>
36 {{ end }}
37 </p>
38 </div>
39
40 <div class="diff-stat">
41 <br>
42 <strong class="text-sm uppercase mb-4">Changed files</strong>
43 {{ range $diff }}
44 <ul>
45 {{ if .IsDelete }}
46 <li><a href="#file-{{ .Name.Old }}">{{ .Name.Old }}</a></li>
47 {{ else }}
48 <li><a href="#file-{{ .Name.New }}">{{ .Name.New }}</a></li>
49 {{ end }}
50 </ul>
51 {{ end }}
52 </div>
53</section>
54
55{{end}}
56
57{{ define "repoAfter" }}
58
59{{ $repo := .RepoInfo.FullName }}
60{{ $commit := .Diff.Commit }}
61{{ $stat := .Diff.Stat }}
62{{ $diff := .Diff.Diff }}
63
64 {{ $this := $commit.This }}
65 {{ $parent := $commit.Parent }}
66
67 {{ $last := sub (len $diff) 1 }}
68 {{ range $idx, $hunk := $diff }}
69 {{ with $hunk }}
70 <section class="mt-6 border border-gray-200 w-full mx-auto rounded bg-white drop-shadow-sm">
71 <div id="file-{{ .Name.New }}">
72 <div id="diff-file">
73 <details open>
74 <summary class="list-none cursor-pointer sticky top-0">
75 <div id="diff-file-header" class="rounded cursor-pointer bg-white flex justify-between">
76 <div id="left-side-items" class="p-2 flex gap-2 items-center">
77 {{ $markerstyle := "diff-type p-1 mr-1 font-mono text-sm rounded select-none" }}
78
79 {{ if .IsNew }}
80 <span class="bg-green-100 text-green-700 {{ $markerstyle }}">ADDED</span>
81 {{ else if .IsDelete }}
82 <span class="bg-red-100 text-red-700 {{ $markerstyle }}">DELETED</span>
83 {{ else if .IsCopy }}
84 <span class="bg-gray-100 text-gray-700 {{ $markerstyle }}">COPIED</span>
85 {{ else if .IsRename }}
86 <span class="bg-gray-100 text-gray-700 {{ $markerstyle }}">RENAMED</span>
87 {{ else }}
88 <span class="bg-gray-100 text-gray-700 {{ $markerstyle }}">MODIFIED</span>
89 {{ end }}
90
91 {{ if .IsDelete }}
92 <a href="/{{ $repo }}/blob/{{ $this }}/{{ .Name.Old }}">{{ .Name.Old }}</a>
93 {{ else if (or .IsCopy .IsRename) }}
94 <a href="/{{ $repo }}/blob/{{ $parent }}/{{ .Name.Old }}">{{ .Name.Old }}</a>
95 <i class="w-4 h-4" data-lucide="arrow-right"></i>
96 <a href="/{{ $repo }}/blob/{{ $this }}/{{ .Name.New }}">{{ .Name.New }}</a>
97 {{ else }}
98 <a href="/{{ $repo }}/blob/{{ $this }}/{{ .Name.New }}">{{ .Name.New }}</a>
99 {{ end }}
100 </div>
101
102 {{ $iconstyle := "p-1 mx-1 hover:bg-gray-100 rounded" }}
103 <div id="right-side-items" class="p-2 flex items-center">
104 <a title="top of file" href="#file-{{ .Name.New }}" class="{{ $iconstyle }}"><i class="w-4 h-4" data-lucide="arrow-up-to-line"></i></a>
105 {{ if gt $idx 0 }}
106 {{ $prev := index $diff (sub $idx 1) }}
107 <a title="previous file" href="#file-{{ $prev.Name.New }}" class="{{ $iconstyle }}"><i class="w-4 h-4" data-lucide="arrow-up"></i></a>
108 {{ end }}
109
110 {{ if lt $idx $last }}
111 {{ $next := index $diff (add $idx 1) }}
112 <a title="next file" href="#file-{{ $next.Name.New }}" class="{{ $iconstyle }}"><i class="w-4 h-4" data-lucide="arrow-down"></i></a>
113 {{ end }}
114 </div>
115
116 </div>
117 </summary>
118
119 <div class="transition-all duration-700 ease-in-out">
120 {{ if .IsDelete }}
121 <p class="text-center text-gray-400 p-4">
122 This file has been deleted in this commit.
123 </p>
124 {{ else }}
125 {{ if .IsBinary }}
126 <p class="text-center text-gray-400 p-4">
127 This is a binary file and will not be displayed.
128 </p>
129 {{ else }}
130 <pre class="overflow-auto">
131 {{- range .TextFragments -}}
132 <div class="bg-gray-100 text-gray-500 select-none">{{ .Header }}</div>
133 {{- range .Lines -}}
134 {{- if eq .Op.String "+" -}}
135 <div class="bg-green-100 text-green-700 p-1"><span class="select-none mx-2">{{ .Op.String }}</span><span>{{ .Line }}</span></div>
136 {{- end -}}
137
138 {{- if eq .Op.String "-" -}}
139 <div class="bg-red-100 text-red-700 p-1"><span class="select-none mx-2">{{ .Op.String }}</span><span>{{ .Line }}</span></div>
140 {{- end -}}
141
142 {{- if eq .Op.String " " -}}
143 <div class="bg-white text-gray-500 px"><span class="select-none mx-2">{{ .Op.String }}</span><span>{{ .Line }}</span></div>
144 {{- end -}}
145
146 {{- end -}}
147 {{- end -}}
148 </pre>
149 {{- end -}}
150 {{ end }}
151 </div>
152
153 </details>
154
155 </div>
156 </div>
157 </section>
158 {{ end }}
159 {{ end }}
160
161{{end}}