BlueGit

timfa bluegit

Merge branch 'feature/commit-graph-v4' into master

timfa Grok Bot · pushed by timfa

Authored 2026-11-12 · 5 days ago

Hash
4e72aee83b36ef50df50d8191c22a8a5cd00884d
Pipeline
Passed
10 files changed +254 −28
README.md +1 −1
@@ -11,7 +11,7 @@ Het logo is de blauwe ster: [`assets/logo.svg`](assets/logo.svg).
11 11 ## Wat het doet
12 12
13 13 - Repositories van een gebruiker of een groep, met bestanden, commits, branches, tags en releases.
14 - Op de project-overzichtspagina staat een commitgrafiek links van de centrale kolom, als er plek is. Elke commit staat op één regel; de lijnen lopen in verticale lanes met afgeronde 90-graden bochten, en de avatar is de commitknoop. De tekst begint in één kolom, rechts van de meest rechtse lane. De centrale kolom schuift naar rechts om de grafiek ruimte te geven, ook op een scherm van 1280px; de grafiek wordt niet verkleind, te lange committekst krijgt een ellipsis. Past het links niet, dan hangt hij rechts, anders blijft hij verborgen. De lijn van de in de dropdown gekozen branch gloeit. De hoofdbranch gebruikt de BlueGit-blauw; andere branches krijgen een vaste kleur uit hun naam. De grafiek wordt in het geheugen bewaard (LRU) en bij een push ververst, zodat herhaald laden geen git-I/O op schijf doet.
14 - Op de project-overzichtspagina staat een commitgrafiek links van de centrale kolom, als er plek is. Elke commit staat op één regel; de lijnen lopen in verticale lanes met afgeronde 90-graden bochten, en de avatar is de commitknoop. De tekst begint in één kolom, rechts van de meest rechtse lane. Elke avatar staat exact op de lane van die commit. De grafiek wordt niet verkleind; te lange committekst krijgt een ellipsis. Past de grafiek links niet zonder de centrale kolom onbruikbaar te maken (bijvoorbeeld 1280px met sidebar), dan hangt hij rechts, anders blijft hij verborgen. De lijn van de in de dropdown gekozen branch gloeit. De hoofdbranch gebruikt de BlueGit-blauw; andere branches krijgen een vaste kleur uit hun naam. De grafiek wordt in het geheugen bewaard (LRU) en bij een push ververst, zodat herhaald laden geen git-I/O op schijf doet.
15 15 - Merge requests met reviews, squash en het verwijderen van de bronbranch na een merge.
16 16 - Issues, met beschrijvingssjablonen in `.bluegit/issue_templates`. Merge requests gebruiken `.bluegit/merge_request_templates`. `Default.md` vult een lege beschrijving. Dezelfde namen onder `.gitlab/` zijn een terugval.
17 17 - Een ingebouwde CI-runner, Steve. Het bestand is `blue-ci-cd.yml`. Elke job draait in een eigen container. `image: bluegit/base` en de andere aliassen zijn image-presets die Steve lokaal bouwt.
@@ -11,7 +11,7 @@ Het logo is de blauwe ster: [`assets/logo.svg`](assets/logo.svg).
11## Wat het doet
11## Wat het doet
12
12
13- Repositories van een gebruiker of een groep, met bestanden, commits, branches, tags en releases.
13- Repositories van een gebruiker of een groep, met bestanden, commits, branches, tags en releases.
14- Op de project-overzichtspagina staat een commitgrafiek links van de centrale kolom, als er plek is. Elke commit staat op één regel; de lijnen lopen in verticale lanes met afgeronde 90-graden bochten, en de avatar is de commitknoop. De tekst begint in één kolom, rechts van de meest rechtse lane. De centrale kolom schuift naar rechts om de grafiek ruimte te geven, ook op een scherm van 1280px; de grafiek wordt niet verkleind, te lange committekst krijgt een ellipsis. Past het links niet, dan hangt hij rechts, anders blijft hij verborgen. De lijn van de in de dropdown gekozen branch gloeit. De hoofdbranch gebruikt de BlueGit-blauw; andere branches krijgen een vaste kleur uit hun naam. De grafiek wordt in het geheugen bewaard (LRU) en bij een push ververst, zodat herhaald laden geen git-I/O op schijf doet.
14- Op de project-overzichtspagina staat een commitgrafiek links van de centrale kolom, als er plek is. Elke commit staat op één regel; de lijnen lopen in verticale lanes met afgeronde 90-graden bochten, en de avatar is de commitknoop. De tekst begint in één kolom, rechts van de meest rechtse lane. Elke avatar staat exact op de lane van die commit. De grafiek wordt niet verkleind; te lange committekst krijgt een ellipsis. Past de grafiek links niet zonder de centrale kolom onbruikbaar te maken (bijvoorbeeld 1280px met sidebar), dan hangt hij rechts, anders blijft hij verborgen. De lijn van de in de dropdown gekozen branch gloeit. De hoofdbranch gebruikt de BlueGit-blauw; andere branches krijgen een vaste kleur uit hun naam. De grafiek wordt in het geheugen bewaard (LRU) en bij een push ververst, zodat herhaald laden geen git-I/O op schijf doet.
15- Merge requests met reviews, squash en het verwijderen van de bronbranch na een merge.
15- Merge requests met reviews, squash en het verwijderen van de bronbranch na een merge.
16- Issues, met beschrijvingssjablonen in `.bluegit/issue_templates`. Merge requests gebruiken `.bluegit/merge_request_templates`. `Default.md` vult een lege beschrijving. Dezelfde namen onder `.gitlab/` zijn een terugval.
16- Issues, met beschrijvingssjablonen in `.bluegit/issue_templates`. Merge requests gebruiken `.bluegit/merge_request_templates`. `Default.md` vult een lege beschrijving. Dezelfde namen onder `.gitlab/` zijn een terugval.
17- Een ingebouwde CI-runner, Steve. Het bestand is `blue-ci-cd.yml`. Elke job draait in een eigen container. `image: bluegit/base` en de andere aliassen zijn image-presets die Steve lokaal bouwt.
17- Een ingebouwde CI-runner, Steve. Het bestand is `blue-ci-cd.yml`. Elke job draait in een eigen container. `image: bluegit/base` en de andere aliassen zijn image-presets die Steve lokaal bouwt.
docs/ARCHITECTURE.md +1 −1
@@ -95,6 +95,6 @@ Webhooks gaan niet naar een privénetwerk. De classificatie staat in `internal/s
95 95
96 96 ## Commitgrafiek
97 97
98 De project-overzichtspagina toont een commitgrafiek links van de centrale kolom, als die ruimte breed genoeg is. Elke commit staat op één regel. Lijnen lopen in verticale lanes en buigen met afgeronde 90-graden hoeken naar een andere lane. De avatar van de auteur is de commitknoop, op de lane. De committekst staat in één linkse kolom die begint net rechts van de meest rechtse lane. De centrale kolom schuift naar rechts zodat de grafiek meer ruimte krijgt, ook bij een vensterbreedte van 1280px. De lanes en het SVG worden niet geschaald; de tekstkolom begint altijd rechts van de meest rechtse lane en kapt af met een ellipsis. Past de grafiek links niet, dan hangt hij rechts van de kolom; anders blijft hij verborgen. Stylesheets en scripts worden met Cache-Control: no-cache gegeven, zodat een self-update geen oude CSS over de nieuwe tekening legt. De lane van de in de branch-dropdown gekozen branch gloeit (client-side, zonder extra request). De hoofdbranch is altijd `--blue`. Andere branches krijgen een deterministische kleur uit een palet van CSS-variabelen, op basis van de branchnaam.
98 De project-overzichtspagina toont een commitgrafiek links van de centrale kolom, als die ruimte breed genoeg is. Elke commit staat op één regel. Lijnen lopen in verticale lanes en buigen met afgeronde 90-graden hoeken naar een andere lane. De avatar van de auteur is de commitknoop, op de lane. De committekst staat in één linkse kolom die begint net rechts van de meest rechtse lane. Elke avatar staat exact op de lane-x van die commit (inline left in pixels, dezelfde coördinaten als de SVG-lijnen). De lanes en het SVG worden niet geschaald (geen viewBox). De tekstkolom begint altijd rechts van de meest rechtse lane (TextX uit de getekende geometrie) en kapt af met een ellipsis. De grafiek komt alleen links te staan als er naast de grafiek nog een bruikbare hoofdkolom (~720px) overblijft; op 1280px met sidebar is dat te krap, dus hangt hij rechts of blijft hij verborgen. Past de grafiek links niet, dan hangt hij rechts van de kolom; anders blijft hij verborgen. Stylesheets en scripts worden met Cache-Control: no-cache gegeven, zodat een self-update geen oude CSS over de nieuwe tekening legt. De lane van de in de branch-dropdown gekozen branch gloeit (client-side, zonder extra request). De hoofdbranch is altijd `--blue`. Andere branches krijgen een deterministische kleur uit een palet van CSS-variabelen, op basis van de branchnaam.
99 99
100 100 De gelegde grafiek (recente commits over alle branches, inclusief merges en forks) staat in een begrensde LRU-cache in het geheugen, per repository (en hoofdbranch). Een herhaalde pageview doet geen git-I/O. Bij een push wist `refsChanged` de entry en vult `refreshCache` hem op de achtergrond opnieuw. Deze cache schrijft niet naar schijf en is onafhankelijk van de optionele leescache.
@@ -95,6 +95,6 @@ Webhooks gaan niet naar een privénetwerk. De classificatie staat in `internal/s
95
95
96## Commitgrafiek
96## Commitgrafiek
97
97
98De project-overzichtspagina toont een commitgrafiek links van de centrale kolom, als die ruimte breed genoeg is. Elke commit staat op één regel. Lijnen lopen in verticale lanes en buigen met afgeronde 90-graden hoeken naar een andere lane. De avatar van de auteur is de commitknoop, op de lane. De committekst staat in één linkse kolom die begint net rechts van de meest rechtse lane. De centrale kolom schuift naar rechts zodat de grafiek meer ruimte krijgt, ook bij een vensterbreedte van 1280px. De lanes en het SVG worden niet geschaald; de tekstkolom begint altijd rechts van de meest rechtse lane en kapt af met een ellipsis. Past de grafiek links niet, dan hangt hij rechts van de kolom; anders blijft hij verborgen. Stylesheets en scripts worden met Cache-Control: no-cache gegeven, zodat een self-update geen oude CSS over de nieuwe tekening legt. De lane van de in de branch-dropdown gekozen branch gloeit (client-side, zonder extra request). De hoofdbranch is altijd `--blue`. Andere branches krijgen een deterministische kleur uit een palet van CSS-variabelen, op basis van de branchnaam.
98De project-overzichtspagina toont een commitgrafiek links van de centrale kolom, als die ruimte breed genoeg is. Elke commit staat op één regel. Lijnen lopen in verticale lanes en buigen met afgeronde 90-graden hoeken naar een andere lane. De avatar van de auteur is de commitknoop, op de lane. De committekst staat in één linkse kolom die begint net rechts van de meest rechtse lane. Elke avatar staat exact op de lane-x van die commit (inline left in pixels, dezelfde coördinaten als de SVG-lijnen). De lanes en het SVG worden niet geschaald (geen viewBox). De tekstkolom begint altijd rechts van de meest rechtse lane (TextX uit de getekende geometrie) en kapt af met een ellipsis. De grafiek komt alleen links te staan als er naast de grafiek nog een bruikbare hoofdkolom (~720px) overblijft; op 1280px met sidebar is dat te krap, dus hangt hij rechts of blijft hij verborgen. Past de grafiek links niet, dan hangt hij rechts van de kolom; anders blijft hij verborgen. Stylesheets en scripts worden met Cache-Control: no-cache gegeven, zodat een self-update geen oude CSS over de nieuwe tekening legt. De lane van de in de branch-dropdown gekozen branch gloeit (client-side, zonder extra request). De hoofdbranch is altijd `--blue`. Andere branches krijgen een deterministische kleur uit een palet van CSS-variabelen, op basis van de branchnaam.
99
99
100De gelegde grafiek (recente commits over alle branches, inclusief merges en forks) staat in een begrensde LRU-cache in het geheugen, per repository (en hoofdbranch). Een herhaalde pageview doet geen git-I/O. Bij een push wist `refsChanged` de entry en vult `refreshCache` hem op de achtergrond opnieuw. Deze cache schrijft niet naar schijf en is onafhankelijk van de optionele leescache.
100De gelegde grafiek (recente commits over alle branches, inclusief merges en forks) staat in een begrensde LRU-cache in het geheugen, per repository (en hoofdbranch). Een herhaalde pageview doet geen git-I/O. Bij een push wist `refsChanged` de entry en vult `refreshCache` hem op de achtergrond opnieuw. Deze cache schrijft niet naar schijf en is onafhankelijk van de optionele leescache.
internal/gitgraph/graph.go +39 −9
@@ -6,6 +6,7 @@ import (
6 6 "crypto/sha256"
7 7 "encoding/hex"
8 8 "fmt"
9 "math"
9 10 "sort"
10 11 "strings"
11 12 )
@@ -55,14 +56,16 @@ type Label struct {
55 56 // Row is één regel in de gelegde grafiek.
56 57 type Row struct {
57 58 Commit
58 Lane int
59 Color string
60 Class string
61 Branch string // branch die deze commit in de grafiek "bezit"
62 Labels []Label
63 Avatar string
64 Initial string
65 UserURL string
59 Lane int
60 Color string
61 Class string
62 Branch string // branch die deze commit in de grafiek "bezit"
63 Labels []Label
64 Avatar string
65 Initial string
66 UserURL string
67 NodeX float64 // midden van de avatar, in SVG-coördinaten (gelijk aan de lane-x)
68 NodeLeft int // CSS-left van de avatar in de rij (inclusief RefW)
66 69 }
67 70
68 71 // Edge is een lijn van een kind naar een ouder (of het einde van het venster).
@@ -269,11 +272,38 @@ func Layout(commits []Commit, refs []Ref, defaultBranch string) *Graph {
269 272 }
270 273 g.Width = g.Lanes * LaneW
271 274 g.Height = len(g.Rows) * RowH
272 g.TextX = g.Lanes*LaneW + TextPad
275 g.TextX = int(math.Ceil(maxDrawnX(g.Rows, g.Edges))) + TextPad
276 if g.TextX < g.Width+TextPad {
277 g.TextX = g.Width + TextPad
278 }
273 279 g.PanelWidth = RefW + g.TextX + MsgW
280 for i := range g.Rows {
281 g.Rows[i].NodeX = laneX(g.Rows[i].Lane)
282 g.Rows[i].NodeLeft = RefW + int(math.Round(g.Rows[i].NodeX-DotR))
283 }
274 284 return g
275 285 }
276 286
287 // maxDrawnX is de meest rechtse x van knopen (avatar-straal) en lijnen
288 // (halve lijnbreedte), in SVG-coördinaten.
289 func maxDrawnX(rows []Row, edges []Edge) float64 {
290 const halfStroke = 1.0
291 max := 0.0
292 bump := func(x float64) {
293 if x > max {
294 max = x
295 }
296 }
297 for _, r := range rows {
298 bump(laneX(r.Lane) + DotR)
299 }
300 for _, e := range edges {
301 bump(laneX(e.FromLane) + halfStroke)
302 bump(laneX(e.ToLane) + halfStroke)
303 }
304 return max
305 }
306
277 307 func labelsBySHA(refs []Ref, defaultBranch string) map[string][]Label {
278 308 out := map[string][]Label{}
279 309 for _, r := range refs {
@@ -6,6 +6,7 @@ import (
6 "crypto/sha256"
6 "crypto/sha256"
7 "encoding/hex"
7 "encoding/hex"
8 "fmt"
8 "fmt"
9 "math"
9 "sort"
10 "sort"
10 "strings"
11 "strings"
11)
12)
@@ -55,14 +56,16 @@ type Label struct {
55// Row is één regel in de gelegde grafiek.
56// Row is één regel in de gelegde grafiek.
56type Row struct {
57type Row struct {
57 Commit
58 Commit
58 Lane int
59 Lane int
59 Color string
60 Color string
60 Class string
61 Class string
61 Branch string // branch die deze commit in de grafiek "bezit"
62 Branch string // branch die deze commit in de grafiek "bezit"
62 Labels []Label
63 Labels []Label
63 Avatar string
64 Avatar string
64 Initial string
65 Initial string
65 UserURL string
66 UserURL string
67 NodeX float64 // midden van de avatar, in SVG-coördinaten (gelijk aan de lane-x)
68 NodeLeft int // CSS-left van de avatar in de rij (inclusief RefW)
66}
69}
67
70
68// Edge is een lijn van een kind naar een ouder (of het einde van het venster).
71// Edge is een lijn van een kind naar een ouder (of het einde van het venster).
@@ -269,11 +272,38 @@ func Layout(commits []Commit, refs []Ref, defaultBranch string) *Graph {
269 }
272 }
270 g.Width = g.Lanes * LaneW
273 g.Width = g.Lanes * LaneW
271 g.Height = len(g.Rows) * RowH
274 g.Height = len(g.Rows) * RowH
272 g.TextX = g.Lanes*LaneW + TextPad
275 g.TextX = int(math.Ceil(maxDrawnX(g.Rows, g.Edges))) + TextPad
276 if g.TextX < g.Width+TextPad {
277 g.TextX = g.Width + TextPad
278 }
273 g.PanelWidth = RefW + g.TextX + MsgW
279 g.PanelWidth = RefW + g.TextX + MsgW
280 for i := range g.Rows {
281 g.Rows[i].NodeX = laneX(g.Rows[i].Lane)
282 g.Rows[i].NodeLeft = RefW + int(math.Round(g.Rows[i].NodeX-DotR))
283 }
274 return g
284 return g
275}
285}
276
286
287// maxDrawnX is de meest rechtse x van knopen (avatar-straal) en lijnen
288// (halve lijnbreedte), in SVG-coördinaten.
289func maxDrawnX(rows []Row, edges []Edge) float64 {
290 const halfStroke = 1.0
291 max := 0.0
292 bump := func(x float64) {
293 if x > max {
294 max = x
295 }
296 }
297 for _, r := range rows {
298 bump(laneX(r.Lane) + DotR)
299 }
300 for _, e := range edges {
301 bump(laneX(e.FromLane) + halfStroke)
302 bump(laneX(e.ToLane) + halfStroke)
303 }
304 return max
305}
306
277func labelsBySHA(refs []Ref, defaultBranch string) map[string][]Label {
307func labelsBySHA(refs []Ref, defaultBranch string) map[string][]Label {
278 out := map[string][]Label{}
308 out := map[string][]Label{}
279 for _, r := range refs {
309 for _, r := range refs {
internal/gitgraph/graph_test.go +59 −0
@@ -315,3 +315,62 @@ func TestLaneAssignmentStable(t *testing.T) {
315 315 }
316 316 }
317 317 }
318
319 func TestNodeLeftMatchesLane(t *testing.T) {
320 refs := []Ref{
321 {Name: "master", SHA: "m", Kind: "branch"},
322 {Name: "feature", SHA: "f", Kind: "branch"},
323 }
324 g := Layout(commits("m:c,f", "f:b", "c:b", "b:"), refs, "master")
325 if g.Lanes < 2 {
326 t.Fatalf("verwacht meerdere lanes, kreeg %d", g.Lanes)
327 }
328 seenOffMain := false
329 for _, r := range g.Rows {
330 if r.NodeX != laneX(r.Lane) {
331 t.Fatalf("commit %s NodeX=%.1f, wil laneX(%d)=%.1f", r.SHA, r.NodeX, r.Lane, laneX(r.Lane))
332 }
333 wantLeft := RefW + int(r.NodeX-DotR)
334 if r.NodeLeft != wantLeft {
335 t.Fatalf("commit %s NodeLeft=%d, wil %d (lane %d)", r.SHA, r.NodeLeft, wantLeft, r.Lane)
336 }
337 if r.Lane != 0 {
338 seenOffMain = true
339 mainLeft := RefW + int(laneX(0)-DotR)
340 if r.NodeLeft <= mainLeft {
341 t.Fatalf("zijtak %s staat niet rechts van de hoofdlane: left=%d main=%d", r.SHA, r.NodeLeft, mainLeft)
342 }
343 }
344 }
345 if !seenOffMain {
346 t.Fatal("verwacht minstens één commit naast de hoofdlane")
347 }
348 }
349
350 func TestTextXClearsAllGeometry(t *testing.T) {
351 refs := []Ref{
352 {Name: "master", SHA: "m", Kind: "branch"},
353 {Name: "feature", SHA: "e", Kind: "branch"},
354 {Name: "docs", SHA: "d", Kind: "branch"},
355 }
356 g := Layout(commits("d:m", "m:c,e", "e:b", "c:b", "b:a", "a:"), refs, "master")
357 limit := float64(g.TextX - TextPad)
358 for _, r := range g.Rows {
359 if r.NodeX+DotR > limit {
360 t.Fatalf("knoop %s reikt tot %.1f, TextX-pad=%.1f", r.SHA, r.NodeX+DotR, limit)
361 }
362 }
363 for _, e := range g.Edges {
364 for _, ln := range []int{e.FromLane, e.ToLane} {
365 if laneX(ln)+1 > limit {
366 t.Fatalf("lijn op lane %d reikt tot %.1f, TextX-pad=%.1f", ln, laneX(ln)+1, limit)
367 }
368 }
369 }
370 svg := g.SVG()
371 for _, x := range svgPathXs(svg) {
372 if x > limit {
373 t.Fatalf("svg-pad heeft x=%.1f rechts van TextX-pad=%.1f: %s", x, limit, svg)
374 }
375 }
376 }
@@ -315,3 +315,62 @@ func TestLaneAssignmentStable(t *testing.T) {
315 }
315 }
316 }
316 }
317}
317}
318
319func TestNodeLeftMatchesLane(t *testing.T) {
320 refs := []Ref{
321 {Name: "master", SHA: "m", Kind: "branch"},
322 {Name: "feature", SHA: "f", Kind: "branch"},
323 }
324 g := Layout(commits("m:c,f", "f:b", "c:b", "b:"), refs, "master")
325 if g.Lanes < 2 {
326 t.Fatalf("verwacht meerdere lanes, kreeg %d", g.Lanes)
327 }
328 seenOffMain := false
329 for _, r := range g.Rows {
330 if r.NodeX != laneX(r.Lane) {
331 t.Fatalf("commit %s NodeX=%.1f, wil laneX(%d)=%.1f", r.SHA, r.NodeX, r.Lane, laneX(r.Lane))
332 }
333 wantLeft := RefW + int(r.NodeX-DotR)
334 if r.NodeLeft != wantLeft {
335 t.Fatalf("commit %s NodeLeft=%d, wil %d (lane %d)", r.SHA, r.NodeLeft, wantLeft, r.Lane)
336 }
337 if r.Lane != 0 {
338 seenOffMain = true
339 mainLeft := RefW + int(laneX(0)-DotR)
340 if r.NodeLeft <= mainLeft {
341 t.Fatalf("zijtak %s staat niet rechts van de hoofdlane: left=%d main=%d", r.SHA, r.NodeLeft, mainLeft)
342 }
343 }
344 }
345 if !seenOffMain {
346 t.Fatal("verwacht minstens één commit naast de hoofdlane")
347 }
348}
349
350func TestTextXClearsAllGeometry(t *testing.T) {
351 refs := []Ref{
352 {Name: "master", SHA: "m", Kind: "branch"},
353 {Name: "feature", SHA: "e", Kind: "branch"},
354 {Name: "docs", SHA: "d", Kind: "branch"},
355 }
356 g := Layout(commits("d:m", "m:c,e", "e:b", "c:b", "b:a", "a:"), refs, "master")
357 limit := float64(g.TextX - TextPad)
358 for _, r := range g.Rows {
359 if r.NodeX+DotR > limit {
360 t.Fatalf("knoop %s reikt tot %.1f, TextX-pad=%.1f", r.SHA, r.NodeX+DotR, limit)
361 }
362 }
363 for _, e := range g.Edges {
364 for _, ln := range []int{e.FromLane, e.ToLane} {
365 if laneX(ln)+1 > limit {
366 t.Fatalf("lijn op lane %d reikt tot %.1f, TextX-pad=%.1f", ln, laneX(ln)+1, limit)
367 }
368 }
369 }
370 svg := g.SVG()
371 for _, x := range svgPathXs(svg) {
372 if x > limit {
373 t.Fatalf("svg-pad heeft x=%.1f rechts van TextX-pad=%.1f: %s", x, limit, svg)
374 }
375 }
376}
internal/gitgraph/svg.go +3 −1
@@ -16,7 +16,9 @@ func (g *Graph) SVG() string {
16 16 }
17 17 w, h := g.Width, g.Height
18 18 var b strings.Builder
19 b.WriteString(fmt.Sprintf(`<svg class="commitgraph-svg" viewBox="0 0 %d %d" width="%d" height="%d" aria-hidden="true">`, w, h, w, h))
19 // Geen viewBox: 1 CSS-pixel = 1 tekenunit, zodat avatars en lijnen
20 // dezelfde x gebruiken en de grafiek niet geschaald wordt.
21 b.WriteString(fmt.Sprintf(`<svg class="commitgraph-svg" width="%d" height="%d" style="width:%dpx;height:%dpx;left:%dpx" aria-hidden="true">`, w, h, w, h, RefW))
20 22 for _, e := range g.Edges {
21 23 col := safeColor(e.Color)
22 24 cls := ColorClass(e.Color)
@@ -16,7 +16,9 @@ func (g *Graph) SVG() string {
16 }
16 }
17 w, h := g.Width, g.Height
17 w, h := g.Width, g.Height
18 var b strings.Builder
18 var b strings.Builder
19 b.WriteString(fmt.Sprintf(`<svg class="commitgraph-svg" viewBox="0 0 %d %d" width="%d" height="%d" aria-hidden="true">`, w, h, w, h))
19 // Geen viewBox: 1 CSS-pixel = 1 tekenunit, zodat avatars en lijnen
20 // dezelfde x gebruiken en de grafiek niet geschaald wordt.
21 b.WriteString(fmt.Sprintf(`<svg class="commitgraph-svg" width="%d" height="%d" style="width:%dpx;height:%dpx;left:%dpx" aria-hidden="true">`, w, h, w, h, RefW))
20 for _, e := range g.Edges {
22 for _, e := range g.Edges {
21 col := safeColor(e.Color)
23 col := safeColor(e.Color)
22 cls := ColorClass(e.Color)
24 cls := ColorClass(e.Color)
internal/gitgraph/svg_test.go +91 −0
@@ -1,6 +1,8 @@
1 1 package gitgraph
2 2
3 3 import (
4 "regexp"
5 "strconv"
4 6 "strings"
5 7 "testing"
6 8 )
@@ -66,3 +68,92 @@ func TestOrthogonalPathShape(t *testing.T) {
66 68 t.Fatalf("eindigt niet verticaal op het doel: %s", d)
67 69 }
68 70 }
71
72 func TestSVGHasNoViewBoxAndIsOneToOne(t *testing.T) {
73 refs := []Ref{
74 {Name: "master", SHA: "m", Kind: "branch"},
75 {Name: "feature", SHA: "f", Kind: "branch"},
76 }
77 g := Layout(commits("m:c,f", "f:b", "c:b", "b:"), refs, "master")
78 svg := g.SVG()
79 if strings.Contains(svg, "viewBox") {
80 t.Fatalf("viewBox schaalt de tekening, dat mag niet: %s", svg)
81 }
82 want := `style="width:` + itoa(g.Width) + `px;height:` + itoa(g.Height) + `px;left:` + itoa(RefW) + `px"`
83 if !strings.Contains(svg, want) {
84 t.Fatalf("verwacht 1:1 inline-maat %s in %s", want, svg)
85 }
86 }
87
88 func itoa(n int) string { return strconv.Itoa(n) }
89
90 var pathDRe = regexp.MustCompile(`d="([^"]+)"`)
91
92 // svgPathXs leest de x-coördinaten uit de padcommando's van onze SVG
93 // (M x y, V y, H x, Q cx cy, x y).
94 func svgPathXs(svg string) []float64 {
95 var xs []float64
96 for _, m := range pathDRe.FindAllStringSubmatch(svg, -1) {
97 xs = append(xs, pathXs(m[1])...)
98 }
99 return xs
100 }
101
102 func pathXs(d string) []float64 {
103 var xs []float64
104 tokens := strings.FieldsFunc(d, func(r rune) bool {
105 return r == ',' || r == ' ' || r == '\t'
106 })
107 cmd := ""
108 arg := 0
109 for _, tok := range tokens {
110 if tok == "" {
111 continue
112 }
113 if strings.ContainsAny(tok[:1], "MLHVCSQTAZmlhvcsqtaz") {
114 cmd = tok[:1]
115 arg = 0
116 tok = tok[1:]
117 if tok == "" {
118 continue
119 }
120 }
121 n, err := strconv.ParseFloat(tok, 64)
122 if err != nil {
123 continue
124 }
125 switch cmd {
126 case "M", "L", "Q", "T", "S", "C", "A":
127 // even args are x
128 if arg%2 == 0 {
129 xs = append(xs, n)
130 }
131 arg++
132 case "H":
133 xs = append(xs, n)
134 arg++
135 case "V":
136 arg++
137 }
138 }
139 return xs
140 }
141
142 func TestSVGPathXsStayLeftOfText(t *testing.T) {
143 refs := []Ref{
144 {Name: "master", SHA: "m", Kind: "branch"},
145 {Name: "feature", SHA: "e", Kind: "branch"},
146 {Name: "docs", SHA: "d", Kind: "branch"},
147 }
148 g := Layout(commits("d:m", "m:c,e", "e:b", "c:b", "b:a", "a:"), refs, "master")
149 xs := svgPathXs(g.SVG())
150 if len(xs) == 0 {
151 t.Fatal("geen pad-x gevonden")
152 }
153 limit := float64(g.TextX - TextPad)
154 for _, x := range xs {
155 if x > limit {
156 t.Fatalf("pad-x %.1f ligt rechts van TextX-pad %.1f", x, limit)
157 }
158 }
159 }
@@ -1,6 +1,8 @@
1package gitgraph
1package gitgraph
2
2
3import (
3import (
4 "regexp"
5 "strconv"
4 "strings"
6 "strings"
5 "testing"
7 "testing"
6)
8)
@@ -66,3 +68,92 @@ func TestOrthogonalPathShape(t *testing.T) {
66 t.Fatalf("eindigt niet verticaal op het doel: %s", d)
68 t.Fatalf("eindigt niet verticaal op het doel: %s", d)
67 }
69 }
68}
70}
71
72func TestSVGHasNoViewBoxAndIsOneToOne(t *testing.T) {
73 refs := []Ref{
74 {Name: "master", SHA: "m", Kind: "branch"},
75 {Name: "feature", SHA: "f", Kind: "branch"},
76 }
77 g := Layout(commits("m:c,f", "f:b", "c:b", "b:"), refs, "master")
78 svg := g.SVG()
79 if strings.Contains(svg, "viewBox") {
80 t.Fatalf("viewBox schaalt de tekening, dat mag niet: %s", svg)
81 }
82 want := `style="width:` + itoa(g.Width) + `px;height:` + itoa(g.Height) + `px;left:` + itoa(RefW) + `px"`
83 if !strings.Contains(svg, want) {
84 t.Fatalf("verwacht 1:1 inline-maat %s in %s", want, svg)
85 }
86}
87
88func itoa(n int) string { return strconv.Itoa(n) }
89
90var pathDRe = regexp.MustCompile(`d="([^"]+)"`)
91
92// svgPathXs leest de x-coördinaten uit de padcommando's van onze SVG
93// (M x y, V y, H x, Q cx cy, x y).
94func svgPathXs(svg string) []float64 {
95 var xs []float64
96 for _, m := range pathDRe.FindAllStringSubmatch(svg, -1) {
97 xs = append(xs, pathXs(m[1])...)
98 }
99 return xs
100}
101
102func pathXs(d string) []float64 {
103 var xs []float64
104 tokens := strings.FieldsFunc(d, func(r rune) bool {
105 return r == ',' || r == ' ' || r == '\t'
106 })
107 cmd := ""
108 arg := 0
109 for _, tok := range tokens {
110 if tok == "" {
111 continue
112 }
113 if strings.ContainsAny(tok[:1], "MLHVCSQTAZmlhvcsqtaz") {
114 cmd = tok[:1]
115 arg = 0
116 tok = tok[1:]
117 if tok == "" {
118 continue
119 }
120 }
121 n, err := strconv.ParseFloat(tok, 64)
122 if err != nil {
123 continue
124 }
125 switch cmd {
126 case "M", "L", "Q", "T", "S", "C", "A":
127 // even args are x
128 if arg%2 == 0 {
129 xs = append(xs, n)
130 }
131 arg++
132 case "H":
133 xs = append(xs, n)
134 arg++
135 case "V":
136 arg++
137 }
138 }
139 return xs
140}
141
142func TestSVGPathXsStayLeftOfText(t *testing.T) {
143 refs := []Ref{
144 {Name: "master", SHA: "m", Kind: "branch"},
145 {Name: "feature", SHA: "e", Kind: "branch"},
146 {Name: "docs", SHA: "d", Kind: "branch"},
147 }
148 g := Layout(commits("d:m", "m:c,e", "e:b", "c:b", "b:a", "a:"), refs, "master")
149 xs := svgPathXs(g.SVG())
150 if len(xs) == 0 {
151 t.Fatal("geen pad-x gevonden")
152 }
153 limit := float64(g.TextX - TextPad)
154 for _, x := range xs {
155 if x > limit {
156 t.Fatalf("pad-x %.1f ligt rechts van TextX-pad %.1f", x, limit)
157 }
158 }
159}
internal/server/commitgraph.go +2 −0
@@ -17,6 +17,7 @@ type GraphView struct {
17 17 Lanes int
18 18 Width, Height int
19 19 TextX, PanelWidth int
20 RefW int
20 21 SVG template.HTML
21 22 }
22 23
@@ -83,6 +84,7 @@ func presentGraph(ctx context.Context, s *Server, repoID int64, g *gitgraph.Grap
83 84 Height: g.Height,
84 85 TextX: g.TextX,
85 86 PanelWidth: g.PanelWidth,
87 RefW: gitgraph.RefW,
86 88 SVG: template.HTML(g.SVG()),
87 89 }
88 90 }
@@ -17,6 +17,7 @@ type GraphView struct {
17 Lanes int
17 Lanes int
18 Width, Height int
18 Width, Height int
19 TextX, PanelWidth int
19 TextX, PanelWidth int
20 RefW int
20 SVG template.HTML
21 SVG template.HTML
21}
22}
22
23
@@ -83,6 +84,7 @@ func presentGraph(ctx context.Context, s *Server, repoID int64, g *gitgraph.Grap
83 Height: g.Height,
84 Height: g.Height,
84 TextX: g.TextX,
85 TextX: g.TextX,
85 PanelWidth: g.PanelWidth,
86 PanelWidth: g.PanelWidth,
87 RefW: gitgraph.RefW,
86 SVG: template.HTML(g.SVG()),
88 SVG: template.HTML(g.SVG()),
87 }
89 }
88}
90}
internal/server/commitgraph_test.go +37 −2
@@ -51,6 +51,25 @@ func TestOverviewRendersCommitGraph(t *testing.T) {
51 51 if !strings.Contains(page, `class="commitgraph-slot"`) || !strings.Contains(page, "--graph-w:") || !strings.Contains(page, "--graph-lanes-w:") || !strings.Contains(page, "--graph-svg-w:") {
52 52 t.Fatalf("inline paneelmaten ontbreken op de slot:\n%s", page)
53 53 }
54 if !strings.Contains(page, "grid-template-columns:") {
55 t.Fatalf("rijen missen een pixel-grid voor de tekstkolom:\n%s", page)
56 }
57 if !strings.Contains(page, `style="left:`) {
58 t.Fatalf("avatars missen een inline left (moeten op hun lane staan):\n%s", page)
59 }
60 if i := strings.Index(page, `class="commitgraph-svg"`); i >= 0 {
61 end := strings.Index(page[i:], "</svg>")
62 chunk := page[i:]
63 if end >= 0 {
64 chunk = page[i : i+end]
65 }
66 if strings.Contains(chunk, "viewBox") {
67 t.Fatalf("commitgraph-svg mag geen viewBox hebben (schaalt de lanes):\n%s", chunk)
68 }
69 if !strings.Contains(chunk, "style=\"width:") || !strings.Contains(chunk, "left:") {
70 t.Fatalf("commitgraph-svg mist 1:1 inline-maten:\n%s", chunk)
71 }
72 }
54 73 if strings.Contains(page, "ZgotmplZ") {
55 74 t.Fatalf("css-kleur werd weggestreept:\n%s", page)
56 75 }
@@ -262,8 +281,24 @@ func TestGraphCSSDoesNotShrinkLanes(t *testing.T) {
262 281 t.Fatalf("stylesheet mist %q", want)
263 282 }
264 283 }
265 if strings.Contains(s, "@media (min-width: 1860px)") {
266 t.Fatal("oude 1860px-drempel verbergt de grafiek nog op 1280/1920")
284 for _, want := range []string{
285 "grid-column: 1 / -1",
286 "@container maincol (min-width: 1142px)",
287 "@media (min-width: 1400px)",
288 "@media (min-width: 1160px)",
289 } {
290 if !strings.Contains(s, want) {
291 t.Fatalf("stylesheet mist %q", want)
292 }
293 }
294 for _, old := range []string{
295 "@media (min-width: 1860px)",
296 "@media (min-width: 1140px)",
297 "@container maincol (min-width: 900px)",
298 } {
299 if strings.Contains(s, old) {
300 t.Fatalf("oude drempel %q knijpt de hoofdkolom of verbergt de grafiek verkeerd", old)
301 }
267 302 }
268 303 }
269 304
@@ -51,6 +51,25 @@ func TestOverviewRendersCommitGraph(t *testing.T) {
51 if !strings.Contains(page, `class="commitgraph-slot"`) || !strings.Contains(page, "--graph-w:") || !strings.Contains(page, "--graph-lanes-w:") || !strings.Contains(page, "--graph-svg-w:") {
51 if !strings.Contains(page, `class="commitgraph-slot"`) || !strings.Contains(page, "--graph-w:") || !strings.Contains(page, "--graph-lanes-w:") || !strings.Contains(page, "--graph-svg-w:") {
52 t.Fatalf("inline paneelmaten ontbreken op de slot:\n%s", page)
52 t.Fatalf("inline paneelmaten ontbreken op de slot:\n%s", page)
53 }
53 }
54 if !strings.Contains(page, "grid-template-columns:") {
55 t.Fatalf("rijen missen een pixel-grid voor de tekstkolom:\n%s", page)
56 }
57 if !strings.Contains(page, `style="left:`) {
58 t.Fatalf("avatars missen een inline left (moeten op hun lane staan):\n%s", page)
59 }
60 if i := strings.Index(page, `class="commitgraph-svg"`); i >= 0 {
61 end := strings.Index(page[i:], "</svg>")
62 chunk := page[i:]
63 if end >= 0 {
64 chunk = page[i : i+end]
65 }
66 if strings.Contains(chunk, "viewBox") {
67 t.Fatalf("commitgraph-svg mag geen viewBox hebben (schaalt de lanes):\n%s", chunk)
68 }
69 if !strings.Contains(chunk, "style=\"width:") || !strings.Contains(chunk, "left:") {
70 t.Fatalf("commitgraph-svg mist 1:1 inline-maten:\n%s", chunk)
71 }
72 }
54 if strings.Contains(page, "ZgotmplZ") {
73 if strings.Contains(page, "ZgotmplZ") {
55 t.Fatalf("css-kleur werd weggestreept:\n%s", page)
74 t.Fatalf("css-kleur werd weggestreept:\n%s", page)
56 }
75 }
@@ -262,8 +281,24 @@ func TestGraphCSSDoesNotShrinkLanes(t *testing.T) {
262 t.Fatalf("stylesheet mist %q", want)
281 t.Fatalf("stylesheet mist %q", want)
263 }
282 }
264 }
283 }
265 if strings.Contains(s, "@media (min-width: 1860px)") {
284 for _, want := range []string{
266 t.Fatal("oude 1860px-drempel verbergt de grafiek nog op 1280/1920")
285 "grid-column: 1 / -1",
286 "@container maincol (min-width: 1142px)",
287 "@media (min-width: 1400px)",
288 "@media (min-width: 1160px)",
289 } {
290 if !strings.Contains(s, want) {
291 t.Fatalf("stylesheet mist %q", want)
292 }
293 }
294 for _, old := range []string{
295 "@media (min-width: 1860px)",
296 "@media (min-width: 1140px)",
297 "@container maincol (min-width: 900px)",
298 } {
299 if strings.Contains(s, old) {
300 t.Fatalf("oude drempel %q knijpt de hoofdkolom of verbergt de grafiek verkeerd", old)
301 }
267 }
302 }
268}
303}
269
304
internal/server/static/style.css +19 −12
@@ -1348,8 +1348,8 @@ table.md { display: block; max-width: 100%; overflow-x: auto; }
1348 1348 .mdbody { min-width: 0; overflow-wrap: anywhere; }
1349 1349 .mdbody pre { max-width: 100%; overflow-x: auto; }
1350 1350 .mdbody pre code { overflow-wrap: normal; }
1351 .commitwho { overflow-wrap: anywhere; }
1352 1351 @media (max-width: 720px) {
1352 .commitwho { overflow-wrap: anywhere; }
1353 1353 .commitbar { flex-wrap: wrap; row-gap: 0.45rem; }
1354 1354 .commitbar .grow { flex: 1 1 calc(100% - 3rem); }
1355 1355 .commitbar .grow .muted { white-space: normal; word-break: normal; }
@@ -1564,14 +1564,15 @@ form.cancelform { display: inline; }
1564 1564 position: absolute;
1565 1565 top: 0;
1566 1566 left: var(--graph-ref-w);
1567 width: var(--graph-svg-w, auto);
1568 1567 max-width: none;
1569 height: auto;
1568 max-height: none;
1570 1569 pointer-events: none;
1571 1570 z-index: 0;
1571 flex-shrink: 0;
1572 1572 }
1573 1573 .commitgraph-row {
1574 1574 display: grid;
1575 /* Fallback als de inline pixel-grid ontbreekt; de template zet de echte kolommen. */
1575 1576 grid-template-columns: var(--graph-ref-w) var(--graph-lanes-w, calc(var(--lanes, 1) * var(--graph-lane) + 8px)) minmax(0, 1fr);
1576 1577 align-items: center;
1577 1578 height: var(--graph-row);
@@ -1609,7 +1610,12 @@ form.cancelform { display: inline; }
1609 1610 .commitgraph-node.c6, .commitgraph-ref.c6, .commitgraph-svg .c6 { --c: var(--graph-6); color: var(--graph-6); }
1610 1611 .commitgraph-node.c7, .commitgraph-ref.c7, .commitgraph-svg .c7 { --c: var(--graph-7); color: var(--graph-7); }
1611 1612 .commitgraph-node {
1613 /* Deel van de hele rij (niet een extra gridcel), zodat left t.o.v. de rij loopt. */
1612 1614 position: absolute;
1615 grid-column: 1 / -1;
1616 grid-row: 1;
1617 top: calc((var(--graph-row) - var(--graph-node)) / 2);
1618 /* Fallback; de template zet left in pixels op het element zelf. */
1613 1619 left: calc(var(--graph-ref-w) + var(--lane, 0) * var(--graph-lane) + var(--graph-lane) / 2 - var(--graph-node) / 2);
1614 1620 width: var(--graph-node); height: var(--graph-node); border-radius: 50%;
1615 1621 z-index: 1;
@@ -1637,11 +1643,12 @@ form.cancelform { display: inline; }
1637 1643 box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px var(--c, var(--blue));
1638 1644 }
1639 1645 .commitgraph-ref.is-glow { box-shadow: 0 0 0 1px var(--c, var(--blue)); }
1640 /* Toon links als de contentbak de grafiek plus een bruikbare
1641 hoofdkolom (~480px) kan dragen. Op 1280px met sidebar (content
1642 ~1040px) past dat; de hoofdkolom schuift naar rechts en mag
1643 smaller worden. Daaronder: rechts of verborgen. */
1644 @container maincol (min-width: 900px) {
1646 /* Toon links alleen als de grafiek plus een bruikbare hoofdkolom
1647 (~720px, voor last-commit-balk en knoppen) past. Op 1280px met
1648 sidebar is de contentbak ~1040px: te krap voor 406+16+720, dus
1649 rechts of verborgen. Vanaf ~1400px (of ~1160 zonder sidebar)
1650 staat de grafiek links. */
1651 @container maincol (min-width: 1142px) {
1645 1652 .commitgraph-slot {
1646 1653 display: block;
1647 1654 width: var(--graph-w);
@@ -1650,7 +1657,7 @@ form.cancelform { display: inline; }
1650 1657 }
1651 1658 .commitgraph { margin-right: var(--graph-gap); }
1652 1659 }
1653 @media (min-width: 1140px) {
1660 @media (min-width: 1400px) {
1654 1661 .frame.with-side .commitgraph-slot {
1655 1662 display: block;
1656 1663 width: var(--graph-w);
@@ -1659,7 +1666,7 @@ form.cancelform { display: inline; }
1659 1666 }
1660 1667 .frame.with-side .commitgraph { margin-right: var(--graph-gap); }
1661 1668 }
1662 @media (min-width: 900px) {
1669 @media (min-width: 1160px) {
1663 1670 .frame:not(.with-side) .commitgraph-slot {
1664 1671 display: block;
1665 1672 width: var(--graph-w);
@@ -1668,10 +1675,10 @@ form.cancelform { display: inline; }
1668 1675 }
1669 1676 .frame:not(.with-side) .commitgraph { margin-right: var(--graph-gap); }
1670 1677 }
1671 @media (max-width: 899px) {
1678 @media (max-width: 1159px) {
1672 1679 .frame:not(.with-side) .commitgraph-slot:not(.is-right) { display: none; }
1673 1680 }
1674 @media (max-width: 1139px) {
1681 @media (max-width: 1399px) {
1675 1682 .frame.with-side .commitgraph-slot:not(.is-right) { display: none; }
1676 1683 }
1677 1684 .commitgraph-slot.is-right {
@@ -1348,8 +1348,8 @@ table.md { display: block; max-width: 100%; overflow-x: auto; }
1348.mdbody { min-width: 0; overflow-wrap: anywhere; }
1348.mdbody { min-width: 0; overflow-wrap: anywhere; }
1349.mdbody pre { max-width: 100%; overflow-x: auto; }
1349.mdbody pre { max-width: 100%; overflow-x: auto; }
1350.mdbody pre code { overflow-wrap: normal; }
1350.mdbody pre code { overflow-wrap: normal; }
1351.commitwho { overflow-wrap: anywhere; }
1352@media (max-width: 720px) {
1351@media (max-width: 720px) {
1352 .commitwho { overflow-wrap: anywhere; }
1353 .commitbar { flex-wrap: wrap; row-gap: 0.45rem; }
1353 .commitbar { flex-wrap: wrap; row-gap: 0.45rem; }
1354 .commitbar .grow { flex: 1 1 calc(100% - 3rem); }
1354 .commitbar .grow { flex: 1 1 calc(100% - 3rem); }
1355 .commitbar .grow .muted { white-space: normal; word-break: normal; }
1355 .commitbar .grow .muted { white-space: normal; word-break: normal; }
@@ -1564,14 +1564,15 @@ form.cancelform { display: inline; }
1564 position: absolute;
1564 position: absolute;
1565 top: 0;
1565 top: 0;
1566 left: var(--graph-ref-w);
1566 left: var(--graph-ref-w);
1567 width: var(--graph-svg-w, auto);
1568 max-width: none;
1567 max-width: none;
1569 height: auto;
1568 max-height: none;
1570 pointer-events: none;
1569 pointer-events: none;
1571 z-index: 0;
1570 z-index: 0;
1571 flex-shrink: 0;
1572}
1572}
1573.commitgraph-row {
1573.commitgraph-row {
1574 display: grid;
1574 display: grid;
1575 /* Fallback als de inline pixel-grid ontbreekt; de template zet de echte kolommen. */
1575 grid-template-columns: var(--graph-ref-w) var(--graph-lanes-w, calc(var(--lanes, 1) * var(--graph-lane) + 8px)) minmax(0, 1fr);
1576 grid-template-columns: var(--graph-ref-w) var(--graph-lanes-w, calc(var(--lanes, 1) * var(--graph-lane) + 8px)) minmax(0, 1fr);
1576 align-items: center;
1577 align-items: center;
1577 height: var(--graph-row);
1578 height: var(--graph-row);
@@ -1609,7 +1610,12 @@ form.cancelform { display: inline; }
1609.commitgraph-node.c6, .commitgraph-ref.c6, .commitgraph-svg .c6 { --c: var(--graph-6); color: var(--graph-6); }
1610.commitgraph-node.c6, .commitgraph-ref.c6, .commitgraph-svg .c6 { --c: var(--graph-6); color: var(--graph-6); }
1610.commitgraph-node.c7, .commitgraph-ref.c7, .commitgraph-svg .c7 { --c: var(--graph-7); color: var(--graph-7); }
1611.commitgraph-node.c7, .commitgraph-ref.c7, .commitgraph-svg .c7 { --c: var(--graph-7); color: var(--graph-7); }
1611.commitgraph-node {
1612.commitgraph-node {
1613 /* Deel van de hele rij (niet een extra gridcel), zodat left t.o.v. de rij loopt. */
1612 position: absolute;
1614 position: absolute;
1615 grid-column: 1 / -1;
1616 grid-row: 1;
1617 top: calc((var(--graph-row) - var(--graph-node)) / 2);
1618 /* Fallback; de template zet left in pixels op het element zelf. */
1613 left: calc(var(--graph-ref-w) + var(--lane, 0) * var(--graph-lane) + var(--graph-lane) / 2 - var(--graph-node) / 2);
1619 left: calc(var(--graph-ref-w) + var(--lane, 0) * var(--graph-lane) + var(--graph-lane) / 2 - var(--graph-node) / 2);
1614 width: var(--graph-node); height: var(--graph-node); border-radius: 50%;
1620 width: var(--graph-node); height: var(--graph-node); border-radius: 50%;
1615 z-index: 1;
1621 z-index: 1;
@@ -1637,11 +1643,12 @@ form.cancelform { display: inline; }
1637 box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px var(--c, var(--blue));
1643 box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px var(--c, var(--blue));
1638}
1644}
1639.commitgraph-ref.is-glow { box-shadow: 0 0 0 1px var(--c, var(--blue)); }
1645.commitgraph-ref.is-glow { box-shadow: 0 0 0 1px var(--c, var(--blue)); }
1640/* Toon links als de contentbak de grafiek plus een bruikbare
1646/* Toon links alleen als de grafiek plus een bruikbare hoofdkolom
1641 hoofdkolom (~480px) kan dragen. Op 1280px met sidebar (content
1647 (~720px, voor last-commit-balk en knoppen) past. Op 1280px met
1642 ~1040px) past dat; de hoofdkolom schuift naar rechts en mag
1648 sidebar is de contentbak ~1040px: te krap voor 406+16+720, dus
1643 smaller worden. Daaronder: rechts of verborgen. */
1649 rechts of verborgen. Vanaf ~1400px (of ~1160 zonder sidebar)
1644@container maincol (min-width: 900px) {
1650 staat de grafiek links. */
1651@container maincol (min-width: 1142px) {
1645 .commitgraph-slot {
1652 .commitgraph-slot {
1646 display: block;
1653 display: block;
1647 width: var(--graph-w);
1654 width: var(--graph-w);
@@ -1650,7 +1657,7 @@ form.cancelform { display: inline; }
1650 }
1657 }
1651 .commitgraph { margin-right: var(--graph-gap); }
1658 .commitgraph { margin-right: var(--graph-gap); }
1652}
1659}
1653@media (min-width: 1140px) {
1660@media (min-width: 1400px) {
1654 .frame.with-side .commitgraph-slot {
1661 .frame.with-side .commitgraph-slot {
1655 display: block;
1662 display: block;
1656 width: var(--graph-w);
1663 width: var(--graph-w);
@@ -1659,7 +1666,7 @@ form.cancelform { display: inline; }
1659 }
1666 }
1660 .frame.with-side .commitgraph { margin-right: var(--graph-gap); }
1667 .frame.with-side .commitgraph { margin-right: var(--graph-gap); }
1661}
1668}
1662@media (min-width: 900px) {
1669@media (min-width: 1160px) {
1663 .frame:not(.with-side) .commitgraph-slot {
1670 .frame:not(.with-side) .commitgraph-slot {
1664 display: block;
1671 display: block;
1665 width: var(--graph-w);
1672 width: var(--graph-w);
@@ -1668,10 +1675,10 @@ form.cancelform { display: inline; }
1668 }
1675 }
1669 .frame:not(.with-side) .commitgraph { margin-right: var(--graph-gap); }
1676 .frame:not(.with-side) .commitgraph { margin-right: var(--graph-gap); }
1670}
1677}
1671@media (max-width: 899px) {
1678@media (max-width: 1159px) {
1672 .frame:not(.with-side) .commitgraph-slot:not(.is-right) { display: none; }
1679 .frame:not(.with-side) .commitgraph-slot:not(.is-right) { display: none; }
1673}
1680}
1674@media (max-width: 1139px) {
1681@media (max-width: 1399px) {
1675 .frame.with-side .commitgraph-slot:not(.is-right) { display: none; }
1682 .frame.with-side .commitgraph-slot:not(.is-right) { display: none; }
1676}
1683}
1677.commitgraph-slot.is-right {
1684.commitgraph-slot.is-right {
internal/server/templates/commitgraph.html +2 −2
@@ -4,11 +4,11 @@
4 4 {{.Graph.SVG}}
5 5 <ol class="commitgraph-list">
6 6 {{range .Graph.Rows}}
7 <li class="commitgraph-row" style="--lane: {{.Lane}}"{{if .Branch}} data-branch="{{.Branch}}"{{end}}>
7 <li class="commitgraph-row" style="--lane: {{.Lane}}; grid-template-columns: {{$.Graph.RefW}}px {{$.Graph.TextX}}px minmax(0, 1fr)">
8 8 <span class="commitgraph-refs">{{range .Labels}}<span class="commitgraph-ref {{.Kind}}{{if .Default}} is-default{{end}} {{.Class}}"{{if .Ref}} data-branch="{{.Ref}}" title="{{.Ref}}"{{else}} title="{{.Name}}"{{end}}>{{.Name}}</span>{{end}}</span>
9 9 <span class="commitgraph-lanes" aria-hidden="true"></span>
10 10 <a class="commitgraph-msg" href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}" title="{{.Subject}}">{{.Subject}}</a>
11 <a class="commitgraph-node {{.Class}}" href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}" title="{{.Short}}"{{if .Branch}} data-branch="{{.Branch}}"{{end}}>{{if .Avatar}}<img src="{{.Avatar}}" alt="">{{else}}<span>{{.Initial}}</span>{{end}}</a>
11 <a class="commitgraph-node {{.Class}}" href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}" title="{{.Short}}" style="left: {{.NodeLeft}}px"{{if .Branch}} data-branch="{{.Branch}}"{{end}}>{{if .Avatar}}<img src="{{.Avatar}}" alt="">{{else}}<span>{{.Initial}}</span>{{end}}</a>
12 12 </li>
13 13 {{end}}
14 14 </ol>
@@ -4,11 +4,11 @@
4 {{.Graph.SVG}}
4 {{.Graph.SVG}}
5 <ol class="commitgraph-list">
5 <ol class="commitgraph-list">
6 {{range .Graph.Rows}}
6 {{range .Graph.Rows}}
7 <li class="commitgraph-row" style="--lane: {{.Lane}}"{{if .Branch}} data-branch="{{.Branch}}"{{end}}>
7 <li class="commitgraph-row" style="--lane: {{.Lane}}; grid-template-columns: {{$.Graph.RefW}}px {{$.Graph.TextX}}px minmax(0, 1fr)">
8 <span class="commitgraph-refs">{{range .Labels}}<span class="commitgraph-ref {{.Kind}}{{if .Default}} is-default{{end}} {{.Class}}"{{if .Ref}} data-branch="{{.Ref}}" title="{{.Ref}}"{{else}} title="{{.Name}}"{{end}}>{{.Name}}</span>{{end}}</span>
8 <span class="commitgraph-refs">{{range .Labels}}<span class="commitgraph-ref {{.Kind}}{{if .Default}} is-default{{end}} {{.Class}}"{{if .Ref}} data-branch="{{.Ref}}" title="{{.Ref}}"{{else}} title="{{.Name}}"{{end}}>{{.Name}}</span>{{end}}</span>
9 <span class="commitgraph-lanes" aria-hidden="true"></span>
9 <span class="commitgraph-lanes" aria-hidden="true"></span>
10 <a class="commitgraph-msg" href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}" title="{{.Subject}}">{{.Subject}}</a>
10 <a class="commitgraph-msg" href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}" title="{{.Subject}}">{{.Subject}}</a>
11 <a class="commitgraph-node {{.Class}}" href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}" title="{{.Short}}"{{if .Branch}} data-branch="{{.Branch}}"{{end}}>{{if .Avatar}}<img src="{{.Avatar}}" alt="">{{else}}<span>{{.Initial}}</span>{{end}}</a>
11 <a class="commitgraph-node {{.Class}}" href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}" title="{{.Short}}" style="left: {{.NodeLeft}}px"{{if .Branch}} data-branch="{{.Branch}}"{{end}}>{{if .Avatar}}<img src="{{.Avatar}}" alt="">{{else}}<span>{{.Initial}}</span>{{end}}</a>
12 </li>
12 </li>
13 {{end}}
13 {{end}}
14 </ol>
14 </ol>