+6
-1
appview/pages/pages.go
+6
-1
appview/pages/pages.go
···
14
14
"path/filepath"
15
15
"strings"
16
16
17
+
"github.com/alecthomas/chroma/v2"
17
18
chromahtml "github.com/alecthomas/chroma/v2/formatters/html"
18
19
"github.com/alecthomas/chroma/v2/lexers"
19
20
"github.com/alecthomas/chroma/v2/styles"
···
364
365
}
365
366
366
367
func (p *Pages) RepoBlob(w io.Writer, params RepoBlobParams) error {
368
+
style := styles.Get("bw")
369
+
b := style.Builder()
370
+
b.Add(chroma.LiteralString, "noitalic")
371
+
style, _ = b.Build()
372
+
367
373
if params.Lines < 5000 {
368
374
c := params.Contents
369
-
style := styles.Get("bw")
370
375
formatter := chromahtml.New(
371
376
chromahtml.InlineCode(true),
372
377
chromahtml.WithLineNumbers(true),
+26
-48
appview/pages/templates/layouts/topbar.html
+26
-48
appview/pages/templates/layouts/topbar.html
···
1
1
{{ define "layouts/topbar" }}
2
-
{{ with .LoggedInUser }}
3
-
<nav
4
-
class="flex items-center justify-center space-x-4 mb-4 py-2 border-b border-l border-r border-black"
5
-
>
6
-
<a
7
-
href="/"
8
-
hx-boost="true"
9
-
class="text-gray-600 hover:text-gray-900 no-underline"
10
-
>timeline</a
11
-
>
12
-
<a
13
-
href="/settings"
14
-
hx-boost="true"
15
-
class="text-gray-600 hover:text-gray-900 no-underline"
16
-
>settings</a
17
-
>
18
-
<a
19
-
href="/knots"
20
-
hx-boost="true"
21
-
class="text-gray-600 hover:text-gray-900 no-underline"
22
-
>knots</a
23
-
>
24
-
<a
25
-
href="/repo/new"
26
-
hx-boost="true"
27
-
class="text-gray-600 hover:text-gray-900 no-underline"
28
-
>add repos</a
29
-
>
30
-
{{ if .Handle }}
31
-
<a
32
-
href="/@{{ .Handle }}"
33
-
hx-boost="true"
34
-
class="text-gray-600 hover:text-gray-900 no-underline"
35
-
>my profile</a
36
-
>
37
-
{{ else }}
38
-
<a
39
-
href="/{{ .Did }}"
40
-
hx-boost="true"
41
-
class="text-gray-600 hover:text-gray-900 no-underline"
42
-
>my profile</a
43
-
>
44
-
{{ end }}
45
-
<button hx-get="/logout" class="btn">logout</a>
46
-
</nav>
47
-
{{ else }}
48
-
<a href="/login" class="btn my-2 no-underline">login</a>
49
-
{{ end }}
2
+
{{ $linkstyle := "text-gray-400 hover:text-gray-900 no-underline" }}
3
+
<nav class="flex justify-between px-6 space-x-4 mb-4 py-2 border-b border-black">
4
+
<div id="left-items">
5
+
<a href="/" hx-boost="true" class="{{ $linkstyle }} flex gap-2">
6
+
<i class="w-6 h-6" data-lucide="tangent"></i>
7
+
tangled.sh
8
+
</a>
9
+
</div>
10
+
<div id="right-items" class="flex gap-2">
11
+
{{ with .LoggedInUser }}
12
+
<a href="/repo/new" hx-boost="true" class="{{ $linkstyle }}">
13
+
<i class="w-6 h-6" data-lucide="plus"></i>
14
+
</a>
15
+
<a href="/{{ didOrHandle .Did .Handle }}" hx-boost="true" class="{{ $linkstyle }}">
16
+
{{ didOrHandle .Did .Handle }}
17
+
</a>
18
+
<a href="/logout"class="{{ $linkstyle }}">
19
+
(logout)
20
+
</a>
21
+
{{ else }}
22
+
<a href="/login" hx-boost="true" class="{{ $linkstyle }}">
23
+
login
24
+
</a>
25
+
{{ end }}
26
+
</div>
27
+
</nav>
50
28
{{ end }}
-1
appview/pages/templates/repo/commit.html
-1
appview/pages/templates/repo/commit.html
···
109
109
<pre class="overflow-auto">
110
110
{{- range .TextFragments -}}
111
111
<div class="bg-gray-100 text-gray-500 select-none">{{ .Header }}</div>
112
-
113
112
{{- range .Lines -}}
114
113
{{- if eq .Op.String "+" -}}
115
114
<div class="bg-green-100 text-green-700"><span class="select-none">{{ .Op.String }}</span><span>{{ .Line }}</span></div>
+4
-2
appview/pages/templates/repo/index.html
+4
-2
appview/pages/templates/repo/index.html
···
13
13
onchange="window.location.href = '/{{ .RepoInfo.FullName }}/tree/' + this.value"
14
14
class="p-1 border border-gray-500 bg-white"
15
15
>
16
-
<optgroup label="branches" class="uppercase bold text-sm">
16
+
<optgroup label="branches" class="bold text-sm">
17
17
{{ range .Branches }}
18
18
<option
19
19
value="{{ .Reference.Name }}"
···
24
24
</option>
25
25
{{ end }}
26
26
</optgroup>
27
-
<optgroup label="tags" class="uppercase bold text-sm">
27
+
<optgroup label="tags" class="bold text-sm">
28
28
{{ range .Tags }}
29
29
<option
30
30
value="{{ .Reference.Name }}"
···
33
33
>
34
34
{{ .Reference.Name }}
35
35
</option>
36
+
{{ else }}
37
+
<option class="py-1" disabled>no tags found</option>
36
38
{{ end }}
37
39
</optgroup>
38
40
</select>
-1
appview/state/middleware.go
-1
appview/state/middleware.go
-4
appview/state/repo.go
-4
appview/state/repo.go
···
53
53
return
54
54
}
55
55
56
-
log.Println(resp.Status, result)
57
-
58
56
user := s.auth.GetUser(r)
59
57
s.pages.RepoIndexPage(w, pages.RepoIndexParams{
60
58
LoggedInUser: user,
···
274
272
log.Println("failed to parse response:", err)
275
273
return
276
274
}
277
-
278
-
log.Println(result)
279
275
280
276
user := s.auth.GetUser(r)
281
277
s.pages.RepoBranches(w, pages.RepoBranchesParams{
+1
-4
knotserver/git/diff.go
+1
-4
knotserver/git/diff.go
···
65
65
ndiff.IsDelete = d.IsDelete
66
66
67
67
for _, tf := range d.TextFragments {
68
-
ndiff.TextFragments = append(ndiff.TextFragments, types.TextFragment{
69
-
Header: tf.Header(),
70
-
Lines: tf.Lines,
71
-
})
68
+
ndiff.TextFragments = append(ndiff.TextFragments, *tf)
72
69
for _, l := range tf.Lines {
73
70
switch l.Op {
74
71
case gitdiff.OpAdd:
+4
-4
types/diff.go
+4
-4
types/diff.go
···
15
15
Old string `json:"old"`
16
16
New string `json:"new"`
17
17
} `json:"name"`
18
-
TextFragments []TextFragment `json:"text_fragments"`
19
-
IsBinary bool `json:"is_binary"`
20
-
IsNew bool `json:"is_new"`
21
-
IsDelete bool `json:"is_delete"`
18
+
TextFragments []gitdiff.TextFragment `json:"text_fragments"`
19
+
IsBinary bool `json:"is_binary"`
20
+
IsNew bool `json:"is_new"`
21
+
IsDelete bool `json:"is_delete"`
22
22
}
23
23
24
24
// A nicer git diff representation.