feat: klap mappen in de bestandsboom in
De boom en de code hebben elk een eigen scrollvlak. Een klik op een open map vouwt hem in, de chevron draait mee, en de open of dichte stand blijft per repository in localStorage. De map van het geopende bestand en de mappen erboven blijven zichtbaar. Co-authored-by: tim <tim@timfalken.com>
@@ -141,6 +141,7 @@ var en = map[string]string{
141
141
"repo.created": "Created on %s",
142
142
"repo.history": "History",
143
143
"repo.files": "Files",
144
"repo.fold": "Collapse or expand folder",
144
145
"repo.binary": "Binary file.",
145
146
"repo.noTags": "No tags yet.",
146
147
"tag.search": "Find a tag",
@@ -141,6 +141,7 @@ var en = map[string]string{141
"repo.created": "Created on %s",141
"repo.created": "Created on %s",142
"repo.history": "History",142
"repo.history": "History",143
"repo.files": "Files",143
"repo.files": "Files",144
"repo.fold": "Collapse or expand folder",144
"repo.binary": "Binary file.",145
"repo.binary": "Binary file.",145
"repo.noTags": "No tags yet.",146
"repo.noTags": "No tags yet.",146
"tag.search": "Find a tag",147
"tag.search": "Find a tag",@@ -146,6 +146,7 @@ var nl = map[string]string{
146
146
"repo.created": "Aangemaakt op %s",
147
147
"repo.history": "Geschiedenis",
148
148
"repo.files": "Bestanden",
149
"repo.fold": "Map in- of uitklappen",
149
150
"repo.binary": "Binair bestand.",
150
151
"repo.noTags": "Nog geen tags.",
151
152
"tag.search": "Zoek een tag",
@@ -767,6 +768,7 @@ var de = map[string]string{
767
768
"repo.created": "Erstellt am %s",
768
769
"repo.history": "Verlauf",
769
770
"repo.files": "Dateien",
771
"repo.fold": "Ordner ein- oder ausklappen",
770
772
"repo.binary": "Binäre Datei.",
771
773
"repo.noTags": "Noch keine Tags.",
772
774
"tag.search": "Tag suchen",
@@ -1388,6 +1390,7 @@ var fr = map[string]string{
1388
1390
"repo.created": "Créé le %s",
1389
1391
"repo.history": "Historique",
1390
1392
"repo.files": "Fichiers",
1393
"repo.fold": "Replier ou déplier le dossier",
1391
1394
"repo.binary": "Fichier binaire.",
1392
1395
"repo.noTags": "Pas encore de tags.",
1393
1396
"tag.search": "Chercher un tag",
@@ -146,6 +146,7 @@ var nl = map[string]string{146
"repo.created": "Aangemaakt op %s",146
"repo.created": "Aangemaakt op %s",147
"repo.history": "Geschiedenis",147
"repo.history": "Geschiedenis",148
"repo.files": "Bestanden",148
"repo.files": "Bestanden",149
"repo.fold": "Map in- of uitklappen",149
"repo.binary": "Binair bestand.",150
"repo.binary": "Binair bestand.",150
"repo.noTags": "Nog geen tags.",151
"repo.noTags": "Nog geen tags.",151
"tag.search": "Zoek een tag",152
"tag.search": "Zoek een tag",@@ -767,6 +768,7 @@ var de = map[string]string{767
"repo.created": "Erstellt am %s",768
"repo.created": "Erstellt am %s",768
"repo.history": "Verlauf",769
"repo.history": "Verlauf",769
"repo.files": "Dateien",770
"repo.files": "Dateien",771
"repo.fold": "Ordner ein- oder ausklappen",770
"repo.binary": "Binäre Datei.",772
"repo.binary": "Binäre Datei.",771
"repo.noTags": "Noch keine Tags.",773
"repo.noTags": "Noch keine Tags.",772
"tag.search": "Tag suchen",774
"tag.search": "Tag suchen",@@ -1388,6 +1390,7 @@ var fr = map[string]string{1388
"repo.created": "Créé le %s",1390
"repo.created": "Créé le %s",1389
"repo.history": "Historique",1391
"repo.history": "Historique",1390
"repo.files": "Fichiers",1392
"repo.files": "Fichiers",1393
"repo.fold": "Replier ou déplier le dossier",1391
"repo.binary": "Fichier binaire.",1394
"repo.binary": "Fichier binaire.",1392
"repo.noTags": "Pas encore de tags.",1395
"repo.noTags": "Pas encore de tags.",1393
"tag.search": "Chercher un tag",1396
"tag.search": "Chercher un tag",@@ -160,13 +160,15 @@ func treeRows(entries []gitrepo.Entry, current string) []FileRow {
160
160
if depth > 8 {
161
161
depth = 8
162
162
}
163
dir := e.Type == "tree"
164
inside := current == e.Name || strings.HasPrefix(current, e.Name+"/")
163
165
active := e.Name == current
164
if e.Type == "tree" && (current == e.Name || strings.HasPrefix(current, e.Name+"/")) {
166
if dir && inside {
165
167
active = true
166
168
}
167
169
out = append(out, FileRow{
168
Name: base, Path: e.Name, Dir: e.Type == "tree", Icon: fileIcon(base, e.Type),
169
Depth: depth, Active: active,
170
Name: base, Path: e.Name, Dir: dir, Icon: fileIcon(base, e.Type),
171
Depth: depth, Active: active, Open: dir && inside,
170
172
})
171
173
}
172
174
return out
@@ -160,13 +160,15 @@ func treeRows(entries []gitrepo.Entry, current string) []FileRow {160
if depth > 8 {160
if depth > 8 {161
depth = 8161
depth = 8162
}162
}163
dir := e.Type == "tree"164
inside := current == e.Name || strings.HasPrefix(current, e.Name+"/")163
active := e.Name == current165
active := e.Name == current164
if e.Type == "tree" && (current == e.Name || strings.HasPrefix(current, e.Name+"/")) {166
if dir && inside {165
active = true167
active = true166
}168
}167
out = append(out, FileRow{169
out = append(out, FileRow{168
Name: base, Path: e.Name, Dir: e.Type == "tree", Icon: fileIcon(base, e.Type),170
Name: base, Path: e.Name, Dir: dir, Icon: fileIcon(base, e.Type),169
Depth: depth, Active: active,171
Depth: depth, Active: active, Open: dir && inside,170
})172
})171
}173
}172
return out174
return out@@ -687,6 +687,9 @@ type FileRow struct {
687
687
Dir bool
688
688
Depth int
689
689
Active bool
690
// Open geldt voor een map die het huidige pad bevat. De browser
691
// onthoudt afwijkingen daarvan per repository.
692
Open bool
690
693
}
691
694
692
695
// CodeLine is één regel broncode.
@@ -687,6 +687,9 @@ type FileRow struct {687
Dir bool687
Dir bool688
Depth int688
Depth int689
Active bool689
Active bool690
// Open geldt voor een map die het huidige pad bevat. De browser691
// onthoudt afwijkingen daarvan per repository.692
Open bool690
}693
}691
694
692
// CodeLine is één regel broncode.695
// CodeLine is één regel broncode.@@ -541,6 +541,10 @@ func TestProjectOverviewAndFiles(t *testing.T) {
541
541
`data-tree-filter`,
542
542
`data-path="src/main.go"`,
543
543
`data-path="crates/sim"`,
544
`data-repo="tim/legacy-cycles"`,
545
`class="filepane"`,
546
`class="twist"`,
547
`aria-expanded="false"`,
544
548
"This directory is empty.",
545
549
} {
546
550
if want == "This directory is empty." {
@@ -553,6 +557,9 @@ func TestProjectOverviewAndFiles(t *testing.T) {
553
557
t.Fatalf("bestanden mist %q\n%s", want, tree)
554
558
}
555
559
}
560
if strings.Contains(tree, `aria-expanded="true"`) || strings.Contains(tree, ` dir open`) {
561
t.Fatalf("root hoort dichtgeklapt:\n%s", tree)
562
}
556
563
557
564
res, err = client.Get(ts.URL + "/tim/legacy-cycles/-/blob/src/main.go")
558
565
if err != nil {
@@ -562,7 +569,13 @@ func TestProjectOverviewAndFiles(t *testing.T) {
562
569
for _, want := range []string{
563
570
`class="on">Files`,
564
571
`class="depth-1 active"`,
572
`class="depth-0 dir open active"`,
573
`data-dir="1"`,
574
`aria-expanded="true"`,
565
575
`data-path="src"`,
576
`data-repo="tim/legacy-cycles"`,
577
`class="filepane"`,
578
`class="chevron"`,
566
579
`<span class="hl-k">func</span>`,
567
580
`<span class="hl-s">"fmt"</span>`,
568
581
`class="ln">1`,
@@ -541,6 +541,10 @@ func TestProjectOverviewAndFiles(t *testing.T) {541
`data-tree-filter`,541
`data-tree-filter`,542
`data-path="src/main.go"`,542
`data-path="src/main.go"`,543
`data-path="crates/sim"`,543
`data-path="crates/sim"`,544
`data-repo="tim/legacy-cycles"`,545
`class="filepane"`,546
`class="twist"`,547
`aria-expanded="false"`,544
"This directory is empty.",548
"This directory is empty.",545
} {549
} {546
if want == "This directory is empty." {550
if want == "This directory is empty." {@@ -553,6 +557,9 @@ func TestProjectOverviewAndFiles(t *testing.T) {553
t.Fatalf("bestanden mist %q\n%s", want, tree)557
t.Fatalf("bestanden mist %q\n%s", want, tree)554
}558
}555
}559
}560
if strings.Contains(tree, `aria-expanded="true"`) || strings.Contains(tree, ` dir open`) {561
t.Fatalf("root hoort dichtgeklapt:\n%s", tree)562
}556
563
557
res, err = client.Get(ts.URL + "/tim/legacy-cycles/-/blob/src/main.go")564
res, err = client.Get(ts.URL + "/tim/legacy-cycles/-/blob/src/main.go")558
if err != nil {565
if err != nil {@@ -562,7 +569,13 @@ func TestProjectOverviewAndFiles(t *testing.T) {562
for _, want := range []string{569
for _, want := range []string{563
`class="on">Files`,570
`class="on">Files`,564
`class="depth-1 active"`,571
`class="depth-1 active"`,572
`class="depth-0 dir open active"`,573
`data-dir="1"`,574
`aria-expanded="true"`,565
`data-path="src"`,575
`data-path="src"`,576
`data-repo="tim/legacy-cycles"`,577
`class="filepane"`,578
`class="chevron"`,566
`<span class="hl-k">func</span>`,579
`<span class="hl-k">func</span>`,567
`<span class="hl-s">"fmt"</span>`,580
`<span class="hl-s">"fmt"</span>`,568
`class="ln">1`,581
`class="ln">1`,@@ -7,37 +7,146 @@
7
7
});
8
8
});
9
9
var filter = document.querySelector("[data-tree-filter]");
10
if (filter) {
11
var items = document.querySelectorAll(".treelist li");
12
filter.addEventListener("input", function () {
13
var q = filter.value.trim().toLowerCase();
10
var list = document.querySelector(".treelist");
11
if (list) {
12
var repo = list.getAttribute("data-repo") || "";
13
var key = "bluegit.tree." + repo;
14
var saved = {};
15
try {
16
var raw = JSON.parse(localStorage.getItem(key) || "{}");
17
if (raw && typeof raw === "object") {
18
saved = raw;
19
}
20
} catch (e) {
21
saved = {};
22
}
23
function parentOf(path) {
24
var i = path.lastIndexOf("/");
25
return i < 0 ? "" : path.slice(0, i);
26
}
27
var force = {};
28
var active = null;
29
list.querySelectorAll("li.active").forEach(function (li) {
30
var path = li.getAttribute("data-path") || "";
31
if (!active || path.length > (active.getAttribute("data-path") || "").length) {
32
active = li;
33
}
34
});
35
if (active) {
36
var activePath = active.getAttribute("data-path") || "";
37
if (active.getAttribute("data-dir") === "1") {
38
force[activePath] = true;
39
}
40
var anc = parentOf(activePath);
41
while (anc) {
42
force[anc] = true;
43
anc = parentOf(anc);
44
}
45
}
46
function isOpen(path, li) {
47
if (force[path]) {
48
return true;
49
}
50
if (Object.prototype.hasOwnProperty.call(saved, path)) {
51
return !!saved[path];
52
}
53
return li.classList.contains("open");
54
}
55
function paint() {
56
var items = list.querySelectorAll("li");
57
var byPath = {};
14
58
var paths = [];
15
59
items.forEach(function (li) {
16
paths.push((li.getAttribute("data-path") || "").toLowerCase());
60
var path = li.getAttribute("data-path") || "";
61
byPath[path] = li;
62
paths.push(path.toLowerCase());
63
if (li.getAttribute("data-dir") === "1") {
64
var open = isOpen(path, li);
65
li.classList.toggle("open", open);
66
var btn = li.querySelector("button.twist");
67
if (btn) {
68
btn.setAttribute("aria-expanded", open ? "true" : "false");
69
}
70
}
17
71
});
72
var q = filter ? filter.value.trim().toLowerCase() : "";
18
73
items.forEach(function (li, i) {
19
if (q === "") {
20
li.hidden = false;
21
return;
22
}
23
var path = paths[i];
24
if (path.indexOf(q) !== -1) {
25
li.hidden = false;
74
var path = li.getAttribute("data-path") || "";
75
var low = paths[i];
76
if (q !== "") {
77
if (low.indexOf(q) !== -1) {
78
li.hidden = false;
79
return;
80
}
81
var prefix = low + "/";
82
var child = false;
83
for (var j = 0; j < paths.length; j++) {
84
if (paths[j].indexOf(prefix) === 0 && paths[j].indexOf(q) !== -1) {
85
child = true;
86
break;
87
}
88
}
89
li.hidden = !child;
26
90
return;
27
91
}
28
var prefix = path + "/";
29
var child = false;
30
for (var j = 0; j < paths.length; j++) {
31
if (paths[j].indexOf(prefix) === 0 && paths[j].indexOf(q) !== -1) {
32
child = true;
92
var hidden = false;
93
var up = parentOf(path);
94
while (up) {
95
var node = byPath[up];
96
if (node && node.getAttribute("data-dir") === "1" && !node.classList.contains("open")) {
97
hidden = true;
33
98
break;
34
99
}
100
up = parentOf(up);
35
101
}
36
li.hidden = !child;
102
li.hidden = hidden;
37
103
});
104
}
105
function remember(path, open) {
106
delete force[path];
107
saved[path] = open;
108
try {
109
localStorage.setItem(key, JSON.stringify(saved));
110
} catch (e) {}
111
paint();
112
}
113
list.addEventListener("click", function (ev) {
114
var li = ev.target.closest("li");
115
if (!li || !list.contains(li) || li.getAttribute("data-dir") !== "1") {
116
return;
117
}
118
var link = ev.target.closest("a");
119
if (link && li.contains(link) && (ev.metaKey || ev.ctrlKey || ev.shiftKey || ev.altKey)) {
120
return;
121
}
122
ev.preventDefault();
123
var path = li.getAttribute("data-path") || "";
124
remember(path, !li.classList.contains("open"));
125
});
126
if (filter) {
127
filter.addEventListener("input", paint);
128
if (new URLSearchParams(window.location.search).get("focus") === "1") {
129
filter.focus();
130
}
131
}
132
paint();
133
var shown = null;
134
list.querySelectorAll("li.active").forEach(function (li) {
135
if (li.hidden) {
136
return;
137
}
138
if (!shown || (li.getAttribute("data-path") || "").length > (shown.getAttribute("data-path") || "").length) {
139
shown = li;
140
}
38
141
});
39
if (new URLSearchParams(window.location.search).get("focus") === "1") {
40
filter.focus();
142
if (shown) {
143
var top = shown.offsetTop;
144
var bottom = top + shown.offsetHeight;
145
if (top < list.scrollTop) {
146
list.scrollTop = top;
147
} else if (bottom > list.scrollTop + list.clientHeight) {
148
list.scrollTop = bottom - list.clientHeight;
149
}
41
150
}
42
151
}
43
152
})();
@@ -7,37 +7,146 @@7
});7
});8
});8
});9
var filter = document.querySelector("[data-tree-filter]");9
var filter = document.querySelector("[data-tree-filter]");10
if (filter) {10
var list = document.querySelector(".treelist");11
var items = document.querySelectorAll(".treelist li");11
if (list) {12
filter.addEventListener("input", function () {12
var repo = list.getAttribute("data-repo") || "";13
var q = filter.value.trim().toLowerCase();13
var key = "bluegit.tree." + repo;14
var saved = {};15
try {16
var raw = JSON.parse(localStorage.getItem(key) || "{}");17
if (raw && typeof raw === "object") {18
saved = raw;19
}20
} catch (e) {21
saved = {};22
}23
function parentOf(path) {24
var i = path.lastIndexOf("/");25
return i < 0 ? "" : path.slice(0, i);26
}27
var force = {};28
var active = null;29
list.querySelectorAll("li.active").forEach(function (li) {30
var path = li.getAttribute("data-path") || "";31
if (!active || path.length > (active.getAttribute("data-path") || "").length) {32
active = li;33
}34
});35
if (active) {36
var activePath = active.getAttribute("data-path") || "";37
if (active.getAttribute("data-dir") === "1") {38
force[activePath] = true;39
}40
var anc = parentOf(activePath);41
while (anc) {42
force[anc] = true;43
anc = parentOf(anc);44
}45
}46
function isOpen(path, li) {47
if (force[path]) {48
return true;49
}50
if (Object.prototype.hasOwnProperty.call(saved, path)) {51
return !!saved[path];52
}53
return li.classList.contains("open");54
}55
function paint() {56
var items = list.querySelectorAll("li");57
var byPath = {};14
var paths = [];58
var paths = [];15
items.forEach(function (li) {59
items.forEach(function (li) {16
paths.push((li.getAttribute("data-path") || "").toLowerCase());60
var path = li.getAttribute("data-path") || "";61
byPath[path] = li;62
paths.push(path.toLowerCase());63
if (li.getAttribute("data-dir") === "1") {64
var open = isOpen(path, li);65
li.classList.toggle("open", open);66
var btn = li.querySelector("button.twist");67
if (btn) {68
btn.setAttribute("aria-expanded", open ? "true" : "false");69
}70
}17
});71
});72
var q = filter ? filter.value.trim().toLowerCase() : "";18
items.forEach(function (li, i) {73
items.forEach(function (li, i) {19
if (q === "") {74
var path = li.getAttribute("data-path") || "";20
li.hidden = false;75
var low = paths[i];21
return;76
if (q !== "") {22
}77
if (low.indexOf(q) !== -1) {23
var path = paths[i];78
li.hidden = false;24
if (path.indexOf(q) !== -1) {79
return;25
li.hidden = false;80
}81
var prefix = low + "/";82
var child = false;83
for (var j = 0; j < paths.length; j++) {84
if (paths[j].indexOf(prefix) === 0 && paths[j].indexOf(q) !== -1) {85
child = true;86
break;87
}88
}89
li.hidden = !child;26
return;90
return;27
}91
}28
var prefix = path + "/";92
var hidden = false;29
var child = false;93
var up = parentOf(path);30
for (var j = 0; j < paths.length; j++) {94
while (up) {31
if (paths[j].indexOf(prefix) === 0 && paths[j].indexOf(q) !== -1) {95
var node = byPath[up];32
child = true;96
if (node && node.getAttribute("data-dir") === "1" && !node.classList.contains("open")) {97
hidden = true;33
break;98
break;34
}99
}100
up = parentOf(up);35
}101
}36
li.hidden = !child;102
li.hidden = hidden;37
});103
});104
}105
function remember(path, open) {106
delete force[path];107
saved[path] = open;108
try {109
localStorage.setItem(key, JSON.stringify(saved));110
} catch (e) {}111
paint();112
}113
list.addEventListener("click", function (ev) {114
var li = ev.target.closest("li");115
if (!li || !list.contains(li) || li.getAttribute("data-dir") !== "1") {116
return;117
}118
var link = ev.target.closest("a");119
if (link && li.contains(link) && (ev.metaKey || ev.ctrlKey || ev.shiftKey || ev.altKey)) {120
return;121
}122
ev.preventDefault();123
var path = li.getAttribute("data-path") || "";124
remember(path, !li.classList.contains("open"));125
});126
if (filter) {127
filter.addEventListener("input", paint);128
if (new URLSearchParams(window.location.search).get("focus") === "1") {129
filter.focus();130
}131
}132
paint();133
var shown = null;134
list.querySelectorAll("li.active").forEach(function (li) {135
if (li.hidden) {136
return;137
}138
if (!shown || (li.getAttribute("data-path") || "").length > (shown.getAttribute("data-path") || "").length) {139
shown = li;140
}38
});141
});39
if (new URLSearchParams(window.location.search).get("focus") === "1") {142
if (shown) {40
filter.focus();143
var top = shown.offsetTop;144
var bottom = top + shown.offsetHeight;145
if (top < list.scrollTop) {146
list.scrollTop = top;147
} else if (bottom > list.scrollTop + list.clientHeight) {148
list.scrollTop = bottom - list.clientHeight;149
}41
}150
}42
}151
}43
})();152
})();@@ -277,20 +277,46 @@ table.md th, table.md td { border: 1px solid var(--line); padding: 0.4rem 0.6rem
277
277
.counts { list-style: none; padding: 0; margin: 0.6rem 0; }
278
278
.counts li { padding: 0.28rem 0; }
279
279
.counts a { text-decoration: none; }
280
.fileview { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 1rem; align-items: start; }
281
.treebox h2 { margin: 0 0 0.5rem; font-size: 1.15rem; }
282
.treelist { list-style: none; padding: 0; margin: 0.5rem 0 0; }
283
.treelist li { padding: 0.18rem 0.3rem; border-radius: 6px; white-space: nowrap; }
284
.treelist li a { color: inherit; text-decoration: none; }
280
.fileview {
281
display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 1rem; align-items: stretch;
282
/* topbalk, padding van main, kruimels en paginatitel */
283
height: calc(100vh - var(--top-h) - 8.25rem); min-height: 18rem;
284
}
285
.treebox { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
286
.treebox h2 { margin: 0 0 0.5rem; font-size: 1.15rem; flex: none; }
287
.treebox > input { flex: none; }
288
.treelist {
289
list-style: none; padding: 0; margin: 0.5rem 0 0; position: relative;
290
flex: 1 1 auto; min-height: 0; overflow: auto;
291
}
292
.treelist li { display: flex; align-items: center; gap: 0.15rem; padding: 0.18rem 0.3rem; border-radius: 6px; white-space: nowrap; }
293
.treelist li[hidden] { display: none !important; }
294
.treelist li a { color: inherit; text-decoration: none; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
285
295
.treelist li.active { background: #ddf4ff; }
296
.treelist .ficon { flex: none; }
297
.treelist button.twist, .treelist .twistpad {
298
width: 1rem; height: 1rem; flex: none;
299
}
300
.treelist button.twist {
301
background: transparent; color: var(--muted); border: 0; box-shadow: none;
302
min-height: 0; padding: 0; border-radius: 3px;
303
}
304
.treelist button.twist:hover { background: var(--blue-soft); color: var(--ink); }
305
.treelist button.twist:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
306
.treelist .chevron { width: 0.7rem; height: 0.7rem; display: block; transition: transform 120ms ease; }
307
.treelist li.open > button.twist .chevron { transform: rotate(90deg); }
286
308
.treelist li.depth-1 { padding-left: 0.9rem; }
287
309
.treelist li.depth-2 { padding-left: 1.6rem; }
288
310
.treelist li.depth-3 { padding-left: 2.3rem; }
289
311
.treelist li.depth-4 { padding-left: 3rem; }
290
312
.treelist li.depth-5 { padding-left: 3.7rem; }
291
313
.treelist li.depth-6, .treelist li.depth-7, .treelist li.depth-8 { padding-left: 4.4rem; }
314
.filecol { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
315
.filecol > .toolbar { flex: none; margin-top: 0; }
316
.filepane { flex: 1 1 auto; min-height: 0; overflow: auto; }
292
317
.filename { display: flex; align-items: center; gap: 0.35rem; margin: 0.2rem 0 0.6rem; }
293
318
.codebox { margin-top: 0.8rem; overflow: auto; }
319
.fileview .codebox { overflow: visible; }
294
320
table.code { border-collapse: collapse; width: 100%; }
295
321
table.code td { border: 0; padding: 0 0.7rem; vertical-align: top; font-family: ui-monospace, monospace; font-size: 0.86rem; line-height: 1.45; }
296
322
table.code td.ln { color: #8c959f; text-align: right; width: 1%; user-select: none; background: #f6f8fa; }
@@ -919,6 +945,10 @@ form.wh .grid-2 label { margin-top: 0; }
919
945
@media (max-width: 800px) {
920
946
.proj, .fileview, .joblayout { grid-template-columns: minmax(0, 1fr); }
921
947
.proj > *, .fileview > *, .toolbar, .commitbar, .hscroll { min-width: 0; max-width: 100%; }
948
.fileview { height: auto; min-height: 0; }
949
.fileview .treelist { max-height: 40vh; flex: none; }
950
.fileview .filepane { overflow: visible; }
951
.fileview .codebox { overflow: auto; }
922
952
.heat-foot { flex-direction: column; align-items: flex-start; }
923
953
.heat-legend, .heat-foot .muted { justify-content: flex-start; text-align: left; }
924
954
.repolist > li { flex-wrap: wrap; }
@@ -277,20 +277,46 @@ table.md th, table.md td { border: 1px solid var(--line); padding: 0.4rem 0.6rem277
.counts { list-style: none; padding: 0; margin: 0.6rem 0; }277
.counts { list-style: none; padding: 0; margin: 0.6rem 0; }278
.counts li { padding: 0.28rem 0; }278
.counts li { padding: 0.28rem 0; }279
.counts a { text-decoration: none; }279
.counts a { text-decoration: none; }280
.fileview { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 1rem; align-items: start; }280
.fileview {281
.treebox h2 { margin: 0 0 0.5rem; font-size: 1.15rem; }281
display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 1rem; align-items: stretch;282
.treelist { list-style: none; padding: 0; margin: 0.5rem 0 0; }282
/* topbalk, padding van main, kruimels en paginatitel */283
.treelist li { padding: 0.18rem 0.3rem; border-radius: 6px; white-space: nowrap; }283
height: calc(100vh - var(--top-h) - 8.25rem); min-height: 18rem;284
.treelist li a { color: inherit; text-decoration: none; }284
}285
.treebox { display: flex; flex-direction: column; min-width: 0; min-height: 0; }286
.treebox h2 { margin: 0 0 0.5rem; font-size: 1.15rem; flex: none; }287
.treebox > input { flex: none; }288
.treelist {289
list-style: none; padding: 0; margin: 0.5rem 0 0; position: relative;290
flex: 1 1 auto; min-height: 0; overflow: auto;291
}292
.treelist li { display: flex; align-items: center; gap: 0.15rem; padding: 0.18rem 0.3rem; border-radius: 6px; white-space: nowrap; }293
.treelist li[hidden] { display: none !important; }294
.treelist li a { color: inherit; text-decoration: none; min-width: 0; overflow: hidden; text-overflow: ellipsis; }285
.treelist li.active { background: #ddf4ff; }295
.treelist li.active { background: #ddf4ff; }296
.treelist .ficon { flex: none; }297
.treelist button.twist, .treelist .twistpad {298
width: 1rem; height: 1rem; flex: none;299
}300
.treelist button.twist {301
background: transparent; color: var(--muted); border: 0; box-shadow: none;302
min-height: 0; padding: 0; border-radius: 3px;303
}304
.treelist button.twist:hover { background: var(--blue-soft); color: var(--ink); }305
.treelist button.twist:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }306
.treelist .chevron { width: 0.7rem; height: 0.7rem; display: block; transition: transform 120ms ease; }307
.treelist li.open > button.twist .chevron { transform: rotate(90deg); }286
.treelist li.depth-1 { padding-left: 0.9rem; }308
.treelist li.depth-1 { padding-left: 0.9rem; }287
.treelist li.depth-2 { padding-left: 1.6rem; }309
.treelist li.depth-2 { padding-left: 1.6rem; }288
.treelist li.depth-3 { padding-left: 2.3rem; }310
.treelist li.depth-3 { padding-left: 2.3rem; }289
.treelist li.depth-4 { padding-left: 3rem; }311
.treelist li.depth-4 { padding-left: 3rem; }290
.treelist li.depth-5 { padding-left: 3.7rem; }312
.treelist li.depth-5 { padding-left: 3.7rem; }291
.treelist li.depth-6, .treelist li.depth-7, .treelist li.depth-8 { padding-left: 4.4rem; }313
.treelist li.depth-6, .treelist li.depth-7, .treelist li.depth-8 { padding-left: 4.4rem; }314
.filecol { display: flex; flex-direction: column; min-width: 0; min-height: 0; }315
.filecol > .toolbar { flex: none; margin-top: 0; }316
.filepane { flex: 1 1 auto; min-height: 0; overflow: auto; }292
.filename { display: flex; align-items: center; gap: 0.35rem; margin: 0.2rem 0 0.6rem; }317
.filename { display: flex; align-items: center; gap: 0.35rem; margin: 0.2rem 0 0.6rem; }293
.codebox { margin-top: 0.8rem; overflow: auto; }318
.codebox { margin-top: 0.8rem; overflow: auto; }319
.fileview .codebox { overflow: visible; }294
table.code { border-collapse: collapse; width: 100%; }320
table.code { border-collapse: collapse; width: 100%; }295
table.code td { border: 0; padding: 0 0.7rem; vertical-align: top; font-family: ui-monospace, monospace; font-size: 0.86rem; line-height: 1.45; }321
table.code td { border: 0; padding: 0 0.7rem; vertical-align: top; font-family: ui-monospace, monospace; font-size: 0.86rem; line-height: 1.45; }296
table.code td.ln { color: #8c959f; text-align: right; width: 1%; user-select: none; background: #f6f8fa; }322
table.code td.ln { color: #8c959f; text-align: right; width: 1%; user-select: none; background: #f6f8fa; }@@ -919,6 +945,10 @@ form.wh .grid-2 label { margin-top: 0; }919
@media (max-width: 800px) {945
@media (max-width: 800px) {920
.proj, .fileview, .joblayout { grid-template-columns: minmax(0, 1fr); }946
.proj, .fileview, .joblayout { grid-template-columns: minmax(0, 1fr); }921
.proj > *, .fileview > *, .toolbar, .commitbar, .hscroll { min-width: 0; max-width: 100%; }947
.proj > *, .fileview > *, .toolbar, .commitbar, .hscroll { min-width: 0; max-width: 100%; }948
.fileview { height: auto; min-height: 0; }949
.fileview .treelist { max-height: 40vh; flex: none; }950
.fileview .filepane { overflow: visible; }951
.fileview .codebox { overflow: auto; }922
.heat-foot { flex-direction: column; align-items: flex-start; }952
.heat-foot { flex-direction: column; align-items: flex-start; }923
.heat-legend, .heat-foot .muted { justify-content: flex-start; text-align: left; }953
.heat-legend, .heat-foot .muted { justify-content: flex-start; text-align: left; }924
.repolist > li { flex-wrap: wrap; }954
.repolist > li { flex-wrap: wrap; }@@ -463,16 +463,17 @@
463
463
<aside class="treebox">
464
464
<h2>{{t "repo.files"}}</h2>
465
465
<input type="search" placeholder="{{t "group.search"}}" aria-label="{{t "group.search"}}" data-tree-filter>
466
<ul class="treelist">
466
<ul class="treelist" data-repo="{{.Repo.FullPath}}">
467
467
{{range .Tree}}
468
<li class="depth-{{.Depth}}{{if .Active}} active{{end}}" data-path="{{.Path}}">
468
<li class="depth-{{.Depth}}{{if .Dir}} dir{{end}}{{if .Open}} open{{end}}{{if .Active}} active{{end}}" data-path="{{.Path}}"{{if .Dir}} data-dir="1"{{end}}>
469
{{if .Dir}}<button type="button" class="twist" aria-expanded="{{if .Open}}true{{else}}false{{end}}" aria-label="{{t "repo.fold"}}"><svg class="chevron" viewBox="0 0 16 16" aria-hidden="true"><path d="M6 3.5 11 8 6 12.5" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg></button>{{else}}<span class="twistpad" aria-hidden="true"></span>{{end}}
469
470
{{template "ficon" .Icon}}
470
471
{{if .Dir}}<a href="/{{$.Repo.FullPath}}/-/tree/{{.Path}}?rev={{$.Rev}}">{{.Name}}</a>{{else}}<a href="/{{$.Repo.FullPath}}/-/blob/{{.Path}}?rev={{$.Rev}}">{{.Name}}</a>{{end}}
471
472
</li>
472
473
{{end}}
473
474
</ul>
474
475
</aside>
475
<div>
476
<div class="filecol">
476
477
<div class="toolbar">
477
478
<div class="left">
478
479
{{template "branchpick" .}}
@@ -484,6 +485,7 @@
484
485
</div>
485
486
<div class="right">{{template "codemenu" .}}</div>
486
487
</div>
488
<div class="filepane">
487
489
{{if .BlobPath}}
488
490
<h2 class="filename">{{template "ficon" (iconOf .FileName)}} {{.FileName}}</h2>
489
491
{{template "commitbar" .}}
@@ -498,6 +500,7 @@
498
500
{{else}}
499
501
{{template "filetable" .}}
500
502
{{end}}
503
</div>
501
504
</div>
502
505
</div>
503
506
<script src="/assets/repo.js"></script>
@@ -463,16 +463,17 @@463
<aside class="treebox">463
<aside class="treebox">464
<h2>{{t "repo.files"}}</h2>464
<h2>{{t "repo.files"}}</h2>465
<input type="search" placeholder="{{t "group.search"}}" aria-label="{{t "group.search"}}" data-tree-filter>465
<input type="search" placeholder="{{t "group.search"}}" aria-label="{{t "group.search"}}" data-tree-filter>466
<ul class="treelist">466
<ul class="treelist" data-repo="{{.Repo.FullPath}}">467
{{range .Tree}}467
{{range .Tree}}468
<li class="depth-{{.Depth}}{{if .Active}} active{{end}}" data-path="{{.Path}}">468
<li class="depth-{{.Depth}}{{if .Dir}} dir{{end}}{{if .Open}} open{{end}}{{if .Active}} active{{end}}" data-path="{{.Path}}"{{if .Dir}} data-dir="1"{{end}}>469
{{if .Dir}}<button type="button" class="twist" aria-expanded="{{if .Open}}true{{else}}false{{end}}" aria-label="{{t "repo.fold"}}"><svg class="chevron" viewBox="0 0 16 16" aria-hidden="true"><path d="M6 3.5 11 8 6 12.5" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg></button>{{else}}<span class="twistpad" aria-hidden="true"></span>{{end}}469
{{template "ficon" .Icon}}470
{{template "ficon" .Icon}}470
{{if .Dir}}<a href="/{{$.Repo.FullPath}}/-/tree/{{.Path}}?rev={{$.Rev}}">{{.Name}}</a>{{else}}<a href="/{{$.Repo.FullPath}}/-/blob/{{.Path}}?rev={{$.Rev}}">{{.Name}}</a>{{end}}471
{{if .Dir}}<a href="/{{$.Repo.FullPath}}/-/tree/{{.Path}}?rev={{$.Rev}}">{{.Name}}</a>{{else}}<a href="/{{$.Repo.FullPath}}/-/blob/{{.Path}}?rev={{$.Rev}}">{{.Name}}</a>{{end}}471
</li>472
</li>472
{{end}}473
{{end}}473
</ul>474
</ul>474
</aside>475
</aside>475
<div>476
<div class="filecol">476
<div class="toolbar">477
<div class="toolbar">477
<div class="left">478
<div class="left">478
{{template "branchpick" .}}479
{{template "branchpick" .}}@@ -484,6 +485,7 @@484
</div>485
</div>485
<div class="right">{{template "codemenu" .}}</div>486
<div class="right">{{template "codemenu" .}}</div>486
</div>487
</div>488
<div class="filepane">487
{{if .BlobPath}}489
{{if .BlobPath}}488
<h2 class="filename">{{template "ficon" (iconOf .FileName)}} {{.FileName}}</h2>490
<h2 class="filename">{{template "ficon" (iconOf .FileName)}} {{.FileName}}</h2>489
{{template "commitbar" .}}491
{{template "commitbar" .}}@@ -498,6 +500,7 @@498
{{else}}500
{{else}}499
{{template "filetable" .}}501
{{template "filetable" .}}500
{{end}}502
{{end}}503
</div>501
</div>504
</div>502
</div>505
</div>503
<script src="/assets/repo.js"></script>506
<script src="/assets/repo.js"></script>@@ -0,0 +1,60 @@
1
package server
2
3
import (
4
"testing"
5
6
"gitlab.com/Timfa/bluegit/internal/gitrepo"
7
)
8
9
func TestTreeRowsOpen(t *testing.T) {
10
entries := []gitrepo.Entry{
11
{Type: "tree", Name: "src"},
12
{Type: "tree", Name: "src/pkg"},
13
{Type: "blob", Name: "src/main.go"},
14
{Type: "blob", Name: "src/pkg/util.go"},
15
{Type: "tree", Name: "docs"},
16
{Type: "blob", Name: "docs/a.md"},
17
}
18
rows := treeRows(entries, "src/main.go")
19
by := map[string]FileRow{}
20
for _, r := range rows {
21
by[r.Path] = r
22
}
23
if !by["src"].Dir || !by["src"].Open || !by["src"].Active || by["src"].Depth != 0 {
24
t.Fatalf("src: %+v", by["src"])
25
}
26
if by["src/pkg"].Open || by["src/pkg"].Active || !by["src/pkg"].Dir {
27
t.Fatalf("src/pkg: %+v", by["src/pkg"])
28
}
29
if by["src/main.go"].Dir || by["src/main.go"].Open || !by["src/main.go"].Active || by["src/main.go"].Depth != 1 {
30
t.Fatalf("main: %+v", by["src/main.go"])
31
}
32
if by["docs"].Open || by["docs"].Active || !by["docs"].Dir {
33
t.Fatalf("docs: %+v", by["docs"])
34
}
35
if by["docs/a.md"].Active || by["docs/a.md"].Open {
36
t.Fatalf("a.md: %+v", by["docs/a.md"])
37
}
38
39
nested := treeRows(entries, "src/pkg/util.go")
40
open := map[string]bool{}
41
for _, r := range nested {
42
open[r.Path] = r.Open
43
if r.Path == "src/pkg/util.go" && (r.Dir || !r.Active || r.Open) {
44
t.Fatalf("util: %+v", r)
45
}
46
}
47
if !open["src"] || !open["src/pkg"] || open["docs"] {
48
t.Fatalf("voorouders: %v", open)
49
}
50
51
folder := treeRows(entries, "docs")
52
for _, r := range folder {
53
if r.Path == "docs" && (!r.Open || !r.Active) {
54
t.Fatalf("docs als huidige map: %+v", r)
55
}
56
if r.Path == "src" && r.Open {
57
t.Fatalf("src hoort dicht: %+v", r)
58
}
59
}
60
}
@@ -0,0 +1,60 @@1
package server2
3
import (4
"testing"5
6
"gitlab.com/Timfa/bluegit/internal/gitrepo"7
)8
9
func TestTreeRowsOpen(t *testing.T) {10
entries := []gitrepo.Entry{11
{Type: "tree", Name: "src"},12
{Type: "tree", Name: "src/pkg"},13
{Type: "blob", Name: "src/main.go"},14
{Type: "blob", Name: "src/pkg/util.go"},15
{Type: "tree", Name: "docs"},16
{Type: "blob", Name: "docs/a.md"},17
}18
rows := treeRows(entries, "src/main.go")19
by := map[string]FileRow{}20
for _, r := range rows {21
by[r.Path] = r22
}23
if !by["src"].Dir || !by["src"].Open || !by["src"].Active || by["src"].Depth != 0 {24
t.Fatalf("src: %+v", by["src"])25
}26
if by["src/pkg"].Open || by["src/pkg"].Active || !by["src/pkg"].Dir {27
t.Fatalf("src/pkg: %+v", by["src/pkg"])28
}29
if by["src/main.go"].Dir || by["src/main.go"].Open || !by["src/main.go"].Active || by["src/main.go"].Depth != 1 {30
t.Fatalf("main: %+v", by["src/main.go"])31
}32
if by["docs"].Open || by["docs"].Active || !by["docs"].Dir {33
t.Fatalf("docs: %+v", by["docs"])34
}35
if by["docs/a.md"].Active || by["docs/a.md"].Open {36
t.Fatalf("a.md: %+v", by["docs/a.md"])37
}38
39
nested := treeRows(entries, "src/pkg/util.go")40
open := map[string]bool{}41
for _, r := range nested {42
open[r.Path] = r.Open43
if r.Path == "src/pkg/util.go" && (r.Dir || !r.Active || r.Open) {44
t.Fatalf("util: %+v", r)45
}46
}47
if !open["src"] || !open["src/pkg"] || open["docs"] {48
t.Fatalf("voorouders: %v", open)49
}50
51
folder := treeRows(entries, "docs")52
for _, r := range folder {53
if r.Path == "docs" && (!r.Open || !r.Active) {54
t.Fatalf("docs als huidige map: %+v", r)55
}56
if r.Path == "src" && r.Open {57
t.Fatalf("src hoort dicht: %+v", r)58
}59
}60
}