BlueGit

timfa bluegit

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

timfa Grok Bot · pushed by timfa

Authored 2026-11-12 · 5 days ago

Hash
f09b72031bde8c14d3e535eb65836abfd1216a87
Pipeline
Passed
9 files changed +284 −79
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. 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.
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 in de SVG op de lane van die commit (niet via inline CSS: de CSP staat geen style-attributen toe). De grafiek wordt niet verkleind; te lange committekst krijgt een ellipsis. Past de grafiek links niet zonder de centrale kolom onbruikbaar te maken (bijvoorbeeld 1024px of 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. 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.
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 in de SVG op de lane van die commit (niet via inline CSS: de CSP staat geen style-attributen toe). De grafiek wordt niet verkleind; te lange committekst krijgt een ellipsis. Past de grafiek links niet zonder de centrale kolom onbruikbaar te maken (bijvoorbeeld 1024px of 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. 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.
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 in de SVG op de lane-x van die commit (`<image>` met `clipPath`, of een cirkel plus initiaal), in hetzelfde coördinatenstelsel als de lijnen. Er worden geen inline style-attributen gebruikt: `Content-Security-Policy` heeft `style-src 'self'` zonder `'unsafe-inline'`, dus paneelmaten komen uit stylesheet-klassen `.lanes-1` t/m `.lanes-40`. De lanes en het SVG worden niet geschaald (geen viewBox). De tekstkolom begint altijd rechts van de meest rechtse lane 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 1024px of 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. 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.
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 in de SVG op de lane-x van die commit (`<image>` met `clipPath`, of een cirkel plus initiaal), in hetzelfde coördinatenstelsel als de lijnen. Er worden geen inline style-attributen gebruikt: `Content-Security-Policy` heeft `style-src 'self'` zonder `'unsafe-inline'`, dus paneelmaten komen uit stylesheet-klassen `.lanes-1` t/m `.lanes-40`. De lanes en het SVG worden niet geschaald (geen viewBox). De tekstkolom begint altijd rechts van de meest rechtse lane 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 1024px of 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 +17 −2
@@ -81,8 +81,9 @@ type Graph struct {
81 81 Lanes int
82 82 Width int // breedte van het SVG-lanedeel
83 83 Height int
84 TextX int // x waarop de tekstkolom begint, rechts van de laatste lane
85 PanelWidth int // refs + lanes + tekst, in pixels
84 TextX int // x waarop de tekstkolom begint, rechts van de laatste lane
85 PanelWidth int // refs + lanes + tekst, in pixels
86 CommitBase string // optioneel, /owner/repo/-/commit/ voor knoplinks in de SVG
86 87 }
87 88
88 89 // Color is de CSS-kleur van een branch. De hoofdbranch is altijd --blue.
@@ -147,6 +148,20 @@ type laneState struct {
147 148
148 149 // Layout wijst lanes toe en legt lijnen voor merges en forks.
149 150 // commits staat nieuwste eerst. Ontbrekende ouders lopen tot de onderkant.
151
152 // PanelMetrics zijn de paneelmaten voor N lanes, dezelfde formule als Layout.
153 // De stylesheet gebruikt deze waarden in de klassen .lanes-1 t/m .lanes-N,
154 // zodat er geen inline style-attributen nodig zijn (CSP style-src 'self').
155 func PanelMetrics(lanes int) (svgW, textX, panelW int) {
156 if lanes < 1 {
157 lanes = 1
158 }
159 svgW = lanes * LaneW
160 textX = svgW + TextPad
161 panelW = RefW + textX + MsgW
162 return
163 }
164
150 165 func Layout(commits []Commit, refs []Ref, defaultBranch string) *Graph {
151 166 g := &Graph{}
152 167 if len(commits) == 0 {
@@ -81,8 +81,9 @@ type Graph struct {
81 Lanes int
81 Lanes int
82 Width int // breedte van het SVG-lanedeel
82 Width int // breedte van het SVG-lanedeel
83 Height int
83 Height int
84 TextX int // x waarop de tekstkolom begint, rechts van de laatste lane
84 TextX int // x waarop de tekstkolom begint, rechts van de laatste lane
85 PanelWidth int // refs + lanes + tekst, in pixels
85 PanelWidth int // refs + lanes + tekst, in pixels
86 CommitBase string // optioneel, /owner/repo/-/commit/ voor knoplinks in de SVG
86}
87}
87
88
88// Color is de CSS-kleur van een branch. De hoofdbranch is altijd --blue.
89// Color is de CSS-kleur van een branch. De hoofdbranch is altijd --blue.
@@ -147,6 +148,20 @@ type laneState struct {
147
148
148// Layout wijst lanes toe en legt lijnen voor merges en forks.
149// Layout wijst lanes toe en legt lijnen voor merges en forks.
149// commits staat nieuwste eerst. Ontbrekende ouders lopen tot de onderkant.
150// commits staat nieuwste eerst. Ontbrekende ouders lopen tot de onderkant.
151
152// PanelMetrics zijn de paneelmaten voor N lanes, dezelfde formule als Layout.
153// De stylesheet gebruikt deze waarden in de klassen .lanes-1 t/m .lanes-N,
154// zodat er geen inline style-attributen nodig zijn (CSP style-src 'self').
155func PanelMetrics(lanes int) (svgW, textX, panelW int) {
156 if lanes < 1 {
157 lanes = 1
158 }
159 svgW = lanes * LaneW
160 textX = svgW + TextPad
161 panelW = RefW + textX + MsgW
162 return
163}
164
150func Layout(commits []Commit, refs []Ref, defaultBranch string) *Graph {
165func Layout(commits []Commit, refs []Ref, defaultBranch string) *Graph {
151 g := &Graph{}
166 g := &Graph{}
152 if len(commits) == 0 {
167 if len(commits) == 0 {
internal/gitgraph/svg.go +64 −6
@@ -7,18 +7,16 @@ import (
7 7 "strings"
8 8 )
9 9
10 // SVG tekent de lanelijnen met afgeronde 90-graden bochten.
11 // Alleen getallen en paletkleuren, veilig als HTML. De knopen zelf
12 // zijn de avatars in de HTML, niet de SVG.
10 // SVG tekent lanelijnen en commitknopen (avatars) in één coördinatenstelsel.
11 // Geen style-attributen: CSP style-src is 'self' zonder unsafe-inline.
12 // 1 CSS-pixel = 1 tekenunit (geen viewBox), zodat knopen op de lane-x blijven.
13 13 func (g *Graph) SVG() string {
14 14 if g == nil || len(g.Rows) == 0 || g.Lanes < 1 {
15 15 return ""
16 16 }
17 17 w, h := g.Width, g.Height
18 18 var b strings.Builder
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))
19 b.WriteString(fmt.Sprintf(`<svg class="commitgraph-svg" width="%d" height="%d" aria-hidden="true">`, w, h))
22 20 for _, e := range g.Edges {
23 21 col := safeColor(e.Color)
24 22 cls := ColorClass(e.Color)
@@ -34,10 +32,70 @@ func (g *Graph) SVG() string {
34 32 }
35 33 b.WriteString(`/>`)
36 34 }
35 writeSVGNodes(&b, g.Rows, g.CommitBase)
37 36 b.WriteString(`</svg>`)
38 37 return b.String()
39 38 }
40 39
40 func writeSVGNodes(b *strings.Builder, rows []Row, commitBase string) {
41 var clips strings.Builder
42 for i, r := range rows {
43 if r.Avatar == "" {
44 continue
45 }
46 x, y := laneX(r.Lane), rowY(i)
47 fmt.Fprintf(&clips, `<clipPath id="cg-a-%d"><circle cx="%.1f" cy="%.1f" r="%.0f"/></clipPath>`, i, x, y, DotR)
48 }
49 if clips.Len() > 0 {
50 b.WriteString(`<defs>`)
51 b.WriteString(clips.String())
52 b.WriteString(`</defs>`)
53 }
54 for i, r := range rows {
55 x, y := laneX(r.Lane), rowY(i)
56 b.WriteString(`<a class="commitgraph-node`)
57 if r.Class != "" {
58 fmt.Fprintf(b, ` %s`, html.EscapeString(r.Class))
59 }
60 b.WriteByte('"')
61 if commitBase != "" && r.SHA != "" {
62 fmt.Fprintf(b, ` href="%s"`, html.EscapeString(commitBase+r.SHA))
63 }
64 if r.Short != "" {
65 fmt.Fprintf(b, ` title="%s"`, html.EscapeString(r.Short))
66 }
67 if r.Branch != "" {
68 fmt.Fprintf(b, ` data-branch="%s"`, html.EscapeString(r.Branch))
69 }
70 b.WriteByte('>')
71 col := safeColor(r.Color)
72 cls := ColorClass(r.Color)
73 fmt.Fprintf(b, `<circle cx="%.1f" cy="%.1f" r="%.0f" fill="%s"`, x, y, DotR, col)
74 if cls != "" {
75 fmt.Fprintf(b, ` class="%s"`, cls)
76 }
77 b.WriteString(`/>`)
78 if r.Avatar != "" {
79 fmt.Fprintf(b, `<image href="%s" x="%.1f" y="%.1f" width="%.0f" height="%.0f" clip-path="url(#cg-a-%d)" preserveAspectRatio="xMidYMid slice"/>`,
80 html.EscapeString(r.Avatar), x-DotR, y-DotR, DotR*2, DotR*2, i)
81 } else if init := nodeInitial(r.Initial); init != "" {
82 fmt.Fprintf(b, `<text x="%.1f" y="%.1f" text-anchor="middle" dominant-baseline="central" fill="#fff" font-size="9" font-weight="700">%s</text>`, x, y, init)
83 }
84 b.WriteString(`</a>`)
85 }
86 }
87
88 func nodeInitial(s string) string {
89 s = strings.TrimSpace(s)
90 if s == "" {
91 return ""
92 }
93 for _, r := range s {
94 return html.EscapeString(string(r))
95 }
96 return ""
97 }
98
41 99 // orthogonalPath gaat verticaal, dan horizontaal, dan weer verticaal,
42 100 // met afgeronde 90-graden bochten. Bij dezelfde lane is het een rechte lijn.
43 101 func orthogonalPath(x1, y1, x2, y2, r float64) string {
@@ -7,18 +7,16 @@ import (
7 "strings"
7 "strings"
8)
8)
9
9
10// SVG tekent de lanelijnen met afgeronde 90-graden bochten.
10// SVG tekent lanelijnen en commitknopen (avatars) in één coördinatenstelsel.
11// Alleen getallen en paletkleuren, veilig als HTML. De knopen zelf
11// Geen style-attributen: CSP style-src is 'self' zonder unsafe-inline.
12// zijn de avatars in de HTML, niet de SVG.
12// 1 CSS-pixel = 1 tekenunit (geen viewBox), zodat knopen op de lane-x blijven.
13func (g *Graph) SVG() string {
13func (g *Graph) SVG() string {
14 if g == nil || len(g.Rows) == 0 || g.Lanes < 1 {
14 if g == nil || len(g.Rows) == 0 || g.Lanes < 1 {
15 return ""
15 return ""
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 // Geen viewBox: 1 CSS-pixel = 1 tekenunit, zodat avatars en lijnen
19 b.WriteString(fmt.Sprintf(`<svg class="commitgraph-svg" width="%d" height="%d" aria-hidden="true">`, w, h))
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))
22 for _, e := range g.Edges {
20 for _, e := range g.Edges {
23 col := safeColor(e.Color)
21 col := safeColor(e.Color)
24 cls := ColorClass(e.Color)
22 cls := ColorClass(e.Color)
@@ -34,10 +32,70 @@ func (g *Graph) SVG() string {
34 }
32 }
35 b.WriteString(`/>`)
33 b.WriteString(`/>`)
36 }
34 }
35 writeSVGNodes(&b, g.Rows, g.CommitBase)
37 b.WriteString(`</svg>`)
36 b.WriteString(`</svg>`)
38 return b.String()
37 return b.String()
39}
38}
40
39
40func writeSVGNodes(b *strings.Builder, rows []Row, commitBase string) {
41 var clips strings.Builder
42 for i, r := range rows {
43 if r.Avatar == "" {
44 continue
45 }
46 x, y := laneX(r.Lane), rowY(i)
47 fmt.Fprintf(&clips, `<clipPath id="cg-a-%d"><circle cx="%.1f" cy="%.1f" r="%.0f"/></clipPath>`, i, x, y, DotR)
48 }
49 if clips.Len() > 0 {
50 b.WriteString(`<defs>`)
51 b.WriteString(clips.String())
52 b.WriteString(`</defs>`)
53 }
54 for i, r := range rows {
55 x, y := laneX(r.Lane), rowY(i)
56 b.WriteString(`<a class="commitgraph-node`)
57 if r.Class != "" {
58 fmt.Fprintf(b, ` %s`, html.EscapeString(r.Class))
59 }
60 b.WriteByte('"')
61 if commitBase != "" && r.SHA != "" {
62 fmt.Fprintf(b, ` href="%s"`, html.EscapeString(commitBase+r.SHA))
63 }
64 if r.Short != "" {
65 fmt.Fprintf(b, ` title="%s"`, html.EscapeString(r.Short))
66 }
67 if r.Branch != "" {
68 fmt.Fprintf(b, ` data-branch="%s"`, html.EscapeString(r.Branch))
69 }
70 b.WriteByte('>')
71 col := safeColor(r.Color)
72 cls := ColorClass(r.Color)
73 fmt.Fprintf(b, `<circle cx="%.1f" cy="%.1f" r="%.0f" fill="%s"`, x, y, DotR, col)
74 if cls != "" {
75 fmt.Fprintf(b, ` class="%s"`, cls)
76 }
77 b.WriteString(`/>`)
78 if r.Avatar != "" {
79 fmt.Fprintf(b, `<image href="%s" x="%.1f" y="%.1f" width="%.0f" height="%.0f" clip-path="url(#cg-a-%d)" preserveAspectRatio="xMidYMid slice"/>`,
80 html.EscapeString(r.Avatar), x-DotR, y-DotR, DotR*2, DotR*2, i)
81 } else if init := nodeInitial(r.Initial); init != "" {
82 fmt.Fprintf(b, `<text x="%.1f" y="%.1f" text-anchor="middle" dominant-baseline="central" fill="#fff" font-size="9" font-weight="700">%s</text>`, x, y, init)
83 }
84 b.WriteString(`</a>`)
85 }
86}
87
88func nodeInitial(s string) string {
89 s = strings.TrimSpace(s)
90 if s == "" {
91 return ""
92 }
93 for _, r := range s {
94 return html.EscapeString(string(r))
95 }
96 return ""
97}
98
41// orthogonalPath gaat verticaal, dan horizontaal, dan weer verticaal,
99// orthogonalPath gaat verticaal, dan horizontaal, dan weer verticaal,
42// met afgeronde 90-graden bochten. Bij dezelfde lane is het een rechte lijn.
100// met afgeronde 90-graden bochten. Bij dezelfde lane is het een rechte lijn.
43func orthogonalPath(x1, y1, x2, y2, r float64) string {
101func orthogonalPath(x1, y1, x2, y2, r float64) string {
internal/gitgraph/svg_test.go +63 −4
@@ -32,8 +32,14 @@ func TestSVGUsesRoundedOrthogonalBends(t *testing.T) {
32 32 if !strings.Contains(svg, " H ") {
33 33 t.Fatalf("verwacht horizontale stukken in %s", svg)
34 34 }
35 if strings.Contains(svg, "<circle") {
36 t.Fatalf("knopen horen avatars te zijn, geen svg-cirkels: %s", svg)
35 if strings.Contains(svg, ` style=`) || strings.Contains(svg, " style=") {
36 t.Fatalf("svg mag geen style-attribuut hebben (CSP style-src 'self'): %s", svg)
37 }
38 if !strings.Contains(svg, `<a class="commitgraph-node`) {
39 t.Fatalf("verwacht svg-knopen (a.commitgraph-node): %s", svg)
40 }
41 if !strings.Contains(svg, "<circle") {
42 t.Fatalf("verwacht een cirkel per commitknoop: %s", svg)
37 43 }
38 44 if !strings.Contains(svg, `data-branch="master"`) {
39 45 t.Fatalf("gloed-attribuut voor master ontbreekt: %s", svg)
@@ -79,9 +85,12 @@ func TestSVGHasNoViewBoxAndIsOneToOne(t *testing.T) {
79 85 if strings.Contains(svg, "viewBox") {
80 86 t.Fatalf("viewBox schaalt de tekening, dat mag niet: %s", svg)
81 87 }
82 want := `style="width:` + itoa(g.Width) + `px;height:` + itoa(g.Height) + `px;left:` + itoa(RefW) + `px"`
88 if strings.Contains(svg, "style=") {
89 t.Fatalf("geen style-attribuut (CSP): %s", svg)
90 }
91 want := `width="` + itoa(g.Width) + `" height="` + itoa(g.Height) + `"`
83 92 if !strings.Contains(svg, want) {
84 t.Fatalf("verwacht 1:1 inline-maat %s in %s", want, svg)
93 t.Fatalf("verwacht 1:1 attributen %s in %s", want, svg)
85 94 }
86 95 }
87 96
@@ -157,3 +166,53 @@ func TestSVGPathXsStayLeftOfText(t *testing.T) {
157 166 }
158 167 }
159 168 }
169
170 func TestSVGNodesSitOnLanes(t *testing.T) {
171 refs := []Ref{
172 {Name: "master", SHA: "m", Kind: "branch"},
173 {Name: "feature", SHA: "f", Kind: "branch"},
174 }
175 g := Layout(commits("m:c,f", "f:b", "c:b", "b:"), refs, "master")
176 g.Rows[0].Initial = "M"
177 for i := range g.Rows {
178 if g.Rows[i].SHA == "f" {
179 g.Rows[i].Avatar = "https://auth.timfalken.com/avatar/1?v=1"
180 g.Rows[i].Initial = "F"
181 }
182 }
183 g.CommitBase = "/tim/grafiek/-/commit/"
184 svg := g.SVG()
185 if strings.Contains(svg, "style=") {
186 t.Fatalf("style-attribuut in svg: %s", svg)
187 }
188 if !strings.Contains(svg, `href="https://auth.timfalken.com/avatar/1?v=1"`) {
189 t.Fatalf("avatar-image ontbreekt: %s", svg)
190 }
191 if !strings.Contains(svg, `clip-path="url(#cg-a-`) {
192 t.Fatalf("clipPath voor ronde avatar ontbreekt: %s", svg)
193 }
194 if !strings.Contains(svg, `href="/tim/grafiek/-/commit/m"`) {
195 t.Fatalf("commitlink ontbreekt: %s", svg)
196 }
197 seenOffMain := false
198 for i, r := range g.Rows {
199 cx := laneX(r.Lane)
200 want := sprintfCx(cx)
201 if !strings.Contains(svg, want) {
202 t.Fatalf("rij %d lane %d: knoop-cx %s ontbreekt in %s", i, r.Lane, want, svg)
203 }
204 if r.Lane != 0 {
205 seenOffMain = true
206 if cx <= laneX(0) {
207 t.Fatalf("zijtak %s staat niet rechts van de hoofdlane", r.SHA)
208 }
209 }
210 }
211 if !seenOffMain {
212 t.Fatal("verwacht een zijtak-knoop rechts van de hoofdlane")
213 }
214 }
215
216 func sprintfCx(x float64) string {
217 return `cx="` + strconv.FormatFloat(x, 'f', 1, 64) + `"`
218 }
@@ -32,8 +32,14 @@ func TestSVGUsesRoundedOrthogonalBends(t *testing.T) {
32 if !strings.Contains(svg, " H ") {
32 if !strings.Contains(svg, " H ") {
33 t.Fatalf("verwacht horizontale stukken in %s", svg)
33 t.Fatalf("verwacht horizontale stukken in %s", svg)
34 }
34 }
35 if strings.Contains(svg, "<circle") {
35 if strings.Contains(svg, ` style=`) || strings.Contains(svg, " style=") {
36 t.Fatalf("knopen horen avatars te zijn, geen svg-cirkels: %s", svg)
36 t.Fatalf("svg mag geen style-attribuut hebben (CSP style-src 'self'): %s", svg)
37 }
38 if !strings.Contains(svg, `<a class="commitgraph-node`) {
39 t.Fatalf("verwacht svg-knopen (a.commitgraph-node): %s", svg)
40 }
41 if !strings.Contains(svg, "<circle") {
42 t.Fatalf("verwacht een cirkel per commitknoop: %s", svg)
37 }
43 }
38 if !strings.Contains(svg, `data-branch="master"`) {
44 if !strings.Contains(svg, `data-branch="master"`) {
39 t.Fatalf("gloed-attribuut voor master ontbreekt: %s", svg)
45 t.Fatalf("gloed-attribuut voor master ontbreekt: %s", svg)
@@ -79,9 +85,12 @@ func TestSVGHasNoViewBoxAndIsOneToOne(t *testing.T) {
79 if strings.Contains(svg, "viewBox") {
85 if strings.Contains(svg, "viewBox") {
80 t.Fatalf("viewBox schaalt de tekening, dat mag niet: %s", svg)
86 t.Fatalf("viewBox schaalt de tekening, dat mag niet: %s", svg)
81 }
87 }
82 want := `style="width:` + itoa(g.Width) + `px;height:` + itoa(g.Height) + `px;left:` + itoa(RefW) + `px"`
88 if strings.Contains(svg, "style=") {
89 t.Fatalf("geen style-attribuut (CSP): %s", svg)
90 }
91 want := `width="` + itoa(g.Width) + `" height="` + itoa(g.Height) + `"`
83 if !strings.Contains(svg, want) {
92 if !strings.Contains(svg, want) {
84 t.Fatalf("verwacht 1:1 inline-maat %s in %s", want, svg)
93 t.Fatalf("verwacht 1:1 attributen %s in %s", want, svg)
85 }
94 }
86}
95}
87
96
@@ -157,3 +166,53 @@ func TestSVGPathXsStayLeftOfText(t *testing.T) {
157 }
166 }
158 }
167 }
159}
168}
169
170func TestSVGNodesSitOnLanes(t *testing.T) {
171 refs := []Ref{
172 {Name: "master", SHA: "m", Kind: "branch"},
173 {Name: "feature", SHA: "f", Kind: "branch"},
174 }
175 g := Layout(commits("m:c,f", "f:b", "c:b", "b:"), refs, "master")
176 g.Rows[0].Initial = "M"
177 for i := range g.Rows {
178 if g.Rows[i].SHA == "f" {
179 g.Rows[i].Avatar = "https://auth.timfalken.com/avatar/1?v=1"
180 g.Rows[i].Initial = "F"
181 }
182 }
183 g.CommitBase = "/tim/grafiek/-/commit/"
184 svg := g.SVG()
185 if strings.Contains(svg, "style=") {
186 t.Fatalf("style-attribuut in svg: %s", svg)
187 }
188 if !strings.Contains(svg, `href="https://auth.timfalken.com/avatar/1?v=1"`) {
189 t.Fatalf("avatar-image ontbreekt: %s", svg)
190 }
191 if !strings.Contains(svg, `clip-path="url(#cg-a-`) {
192 t.Fatalf("clipPath voor ronde avatar ontbreekt: %s", svg)
193 }
194 if !strings.Contains(svg, `href="/tim/grafiek/-/commit/m"`) {
195 t.Fatalf("commitlink ontbreekt: %s", svg)
196 }
197 seenOffMain := false
198 for i, r := range g.Rows {
199 cx := laneX(r.Lane)
200 want := sprintfCx(cx)
201 if !strings.Contains(svg, want) {
202 t.Fatalf("rij %d lane %d: knoop-cx %s ontbreekt in %s", i, r.Lane, want, svg)
203 }
204 if r.Lane != 0 {
205 seenOffMain = true
206 if cx <= laneX(0) {
207 t.Fatalf("zijtak %s staat niet rechts van de hoofdlane", r.SHA)
208 }
209 }
210 }
211 if !seenOffMain {
212 t.Fatal("verwacht een zijtak-knoop rechts van de hoofdlane")
213 }
214}
215
216func sprintfCx(x float64) string {
217 return `cx="` + strconv.FormatFloat(x, 'f', 1, 64) + `"`
218}
internal/server/commitgraph.go +11 −4
@@ -33,7 +33,7 @@ func (s *Server) fillGraph(r *http.Request, v *View, repo store.Repo) {
33 33 if err != nil || g == nil || len(g.Rows) == 0 {
34 34 return
35 35 }
36 v.Graph = presentGraph(r.Context(), s, repo.ID, g, i18n.Parse(v.Lang))
36 v.Graph = presentGraph(r.Context(), s, repo, g, i18n.Parse(v.Lang))
37 37 }
38 38
39 39 func (s *Server) repoGraph(ctx context.Context, repo store.Repo) (*gitgraph.Graph, error) {
@@ -47,7 +47,7 @@ func (s *Server) repoGraph(ctx context.Context, repo store.Repo) (*gitgraph.Grap
47 47 })
48 48 }
49 49
50 func presentGraph(ctx context.Context, s *Server, repoID int64, g *gitgraph.Graph, lang i18n.Lang) *GraphView {
50 func presentGraph(ctx context.Context, s *Server, repo store.Repo, g *gitgraph.Graph, lang i18n.Lang) *GraphView {
51 51 rows := make([]gitgraph.Row, len(g.Rows))
52 52 copy(rows, g.Rows)
53 53 if s != nil {
@@ -58,7 +58,7 @@ func presentGraph(ctx context.Context, s *Server, repoID int64, g *gitgraph.Grap
58 58 Unix: r.Unix, Subject: r.Subject,
59 59 })
60 60 }
61 people := s.presentCommits(ctx, repoID, in, lang)
61 people := s.presentCommits(ctx, repo.ID, in, lang)
62 62 for i := range rows {
63 63 if i >= len(people) {
64 64 break
@@ -77,6 +77,13 @@ func presentGraph(ctx context.Context, s *Server, repoID int64, g *gitgraph.Grap
77 77 rows[i].Initial = initialOf(rows[i].Author)
78 78 }
79 79 }
80 // Kopie met avatars: de cache bewaart de kale layout, de SVG
81 // krijgt hier de knopen (image/clipPath) op de lane-x.
82 draw := *g
83 draw.Rows = rows
84 if repo.OwnerPath != "" && repo.Name != "" {
85 draw.CommitBase = "/" + repo.FullPath() + "/-/commit/"
86 }
80 87 return &GraphView{
81 88 Rows: rows,
82 89 Lanes: g.Lanes,
@@ -85,7 +92,7 @@ func presentGraph(ctx context.Context, s *Server, repoID int64, g *gitgraph.Grap
85 92 TextX: g.TextX,
86 93 PanelWidth: g.PanelWidth,
87 94 RefW: gitgraph.RefW,
88 SVG: template.HTML(g.SVG()),
95 SVG: template.HTML(draw.SVG()),
89 96 }
90 97 }
91 98
@@ -33,7 +33,7 @@ func (s *Server) fillGraph(r *http.Request, v *View, repo store.Repo) {
33 if err != nil || g == nil || len(g.Rows) == 0 {
33 if err != nil || g == nil || len(g.Rows) == 0 {
34 return
34 return
35 }
35 }
36 v.Graph = presentGraph(r.Context(), s, repo.ID, g, i18n.Parse(v.Lang))
36 v.Graph = presentGraph(r.Context(), s, repo, g, i18n.Parse(v.Lang))
37}
37}
38
38
39func (s *Server) repoGraph(ctx context.Context, repo store.Repo) (*gitgraph.Graph, error) {
39func (s *Server) repoGraph(ctx context.Context, repo store.Repo) (*gitgraph.Graph, error) {
@@ -47,7 +47,7 @@ func (s *Server) repoGraph(ctx context.Context, repo store.Repo) (*gitgraph.Grap
47 })
47 })
48}
48}
49
49
50func presentGraph(ctx context.Context, s *Server, repoID int64, g *gitgraph.Graph, lang i18n.Lang) *GraphView {
50func presentGraph(ctx context.Context, s *Server, repo store.Repo, g *gitgraph.Graph, lang i18n.Lang) *GraphView {
51 rows := make([]gitgraph.Row, len(g.Rows))
51 rows := make([]gitgraph.Row, len(g.Rows))
52 copy(rows, g.Rows)
52 copy(rows, g.Rows)
53 if s != nil {
53 if s != nil {
@@ -58,7 +58,7 @@ func presentGraph(ctx context.Context, s *Server, repoID int64, g *gitgraph.Grap
58 Unix: r.Unix, Subject: r.Subject,
58 Unix: r.Unix, Subject: r.Subject,
59 })
59 })
60 }
60 }
61 people := s.presentCommits(ctx, repoID, in, lang)
61 people := s.presentCommits(ctx, repo.ID, in, lang)
62 for i := range rows {
62 for i := range rows {
63 if i >= len(people) {
63 if i >= len(people) {
64 break
64 break
@@ -77,6 +77,13 @@ func presentGraph(ctx context.Context, s *Server, repoID int64, g *gitgraph.Grap
77 rows[i].Initial = initialOf(rows[i].Author)
77 rows[i].Initial = initialOf(rows[i].Author)
78 }
78 }
79 }
79 }
80 // Kopie met avatars: de cache bewaart de kale layout, de SVG
81 // krijgt hier de knopen (image/clipPath) op de lane-x.
82 draw := *g
83 draw.Rows = rows
84 if repo.OwnerPath != "" && repo.Name != "" {
85 draw.CommitBase = "/" + repo.FullPath() + "/-/commit/"
86 }
80 return &GraphView{
87 return &GraphView{
81 Rows: rows,
88 Rows: rows,
82 Lanes: g.Lanes,
89 Lanes: g.Lanes,
@@ -85,7 +92,7 @@ func presentGraph(ctx context.Context, s *Server, repoID int64, g *gitgraph.Grap
85 TextX: g.TextX,
92 TextX: g.TextX,
86 PanelWidth: g.PanelWidth,
93 PanelWidth: g.PanelWidth,
87 RefW: gitgraph.RefW,
94 RefW: gitgraph.RefW,
88 SVG: template.HTML(g.SVG()),
95 SVG: template.HTML(draw.SVG()),
89 }
96 }
90}
97}
91
98
internal/server/commitgraph_test.go +58 −28
@@ -39,35 +39,26 @@ func TestOverviewRendersCommitGraph(t *testing.T) {
39 39 if !strings.Contains(page, " Q ") || !strings.Contains(page, " H ") {
40 40 t.Fatalf("verwacht afgeronde 90-graden bochten in de svg:\n%s", page)
41 41 }
42 if i := strings.Index(page, `class="commitgraph-svg"`); i >= 0 {
43 end := strings.Index(page[i:], "</svg>")
44 if end >= 0 && strings.Contains(page[i:i+end], "<circle") {
45 t.Fatalf("svg mag geen cirkels meer tekenen, de avatar is de knoop")
46 }
47 }
48 42 if !strings.Contains(page, `data-branch="master"`) {
49 43 t.Fatalf("gloed-attribuut ontbreekt:\n%s", page)
50 44 }
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)
53 }
54 if !strings.Contains(page, "grid-template-columns:") {
55 t.Fatalf("rijen missen een pixel-grid voor de tekstkolom:\n%s", page)
45 if !strings.Contains(page, `class="commitgraph-slot lanes-`) {
46 t.Fatalf("slot mist lanes-N klasse (CSP-veilige paneelmaten):\n%s", page)
56 47 }
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>")
48 if i := strings.Index(page, `class="commitgraph-slot`); i >= 0 {
49 end := strings.Index(page[i:], `</div>`)
62 50 chunk := page[i:]
63 51 if end >= 0 {
64 52 chunk = page[i : i+end]
65 53 }
54 if strings.Contains(chunk, "style=") {
55 t.Fatalf("commitgrafiek mag geen style-attribuut hebben (CSP style-src 'self'):\n%s", chunk)
56 }
66 57 if strings.Contains(chunk, "viewBox") {
67 t.Fatalf("commitgraph-svg mag geen viewBox hebben (schaalt de lanes):\n%s", chunk)
58 t.Fatalf("commitgraph-svg mag geen viewBox hebben:\n%s", chunk)
68 59 }
69 if !strings.Contains(chunk, "style=\"width:") || !strings.Contains(chunk, "left:") {
70 t.Fatalf("commitgraph-svg mist 1:1 inline-maten:\n%s", chunk)
60 if !strings.Contains(chunk, `<a class="commitgraph-node`) || !strings.Contains(chunk, "<circle") {
61 t.Fatalf("avatars horen in de SVG op de lane-x te staan:\n%s", chunk)
71 62 }
72 63 }
73 64 if strings.Contains(page, "ZgotmplZ") {
@@ -256,8 +247,11 @@ func TestSVGColorsAreSafe(t *testing.T) {
256 247 if !strings.Contains(svg, "stroke=\"var(--") {
257 248 t.Fatalf("verwacht stroke in %s", svg)
258 249 }
259 if strings.Contains(svg, "<circle") {
260 t.Fatalf("geen cirkels in svg: %s", svg)
250 if strings.Contains(svg, "style=") {
251 t.Fatalf("geen style-attribuut in svg: %s", svg)
252 }
253 if !strings.Contains(svg, "<circle") {
254 t.Fatalf("verwacht knoop-cirkels in svg: %s", svg)
261 255 }
262 256 if !strings.Contains(svg, " Q ") {
263 257 t.Fatalf("verwacht afgeronde bochten in %s", svg)
@@ -276,21 +270,21 @@ func TestGraphCSSDoesNotShrinkLanes(t *testing.T) {
276 270 "minmax(0, 1fr)",
277 271 "text-overflow: ellipsis",
278 272 "--graph-lanes-w",
279 } {
280 if !strings.Contains(s, want) {
281 t.Fatalf("stylesheet mist %q", want)
282 }
283 }
284 for _, want := range []string{
285 "grid-column: 1 / -1",
273 ".commitgraph-slot.lanes-1 {",
274 ".commitgraph-slot.lanes-5 { --lanes: 5; --graph-svg-w: 140px; --graph-lanes-w: 148px; --graph-w: 406px; }",
286 275 "@container maincol (min-width: 1142px)",
287 276 "@media (min-width: 1400px)",
288 277 "@media (min-width: 1160px)",
278 ".commitgraph-slot:not(.is-right) { display: none !important; }",
289 279 } {
290 280 if !strings.Contains(s, want) {
291 281 t.Fatalf("stylesheet mist %q", want)
292 282 }
293 283 }
284 svgW, textX, panelW := gitgraph.PanelMetrics(5)
285 if svgW != 140 || textX != 148 || panelW != 406 {
286 t.Fatalf("PanelMetrics(5)=%d,%d,%d, wil 140,148,406", svgW, textX, panelW)
287 }
294 288 for _, old := range []string{
295 289 "@media (min-width: 1860px)",
296 290 "@media (min-width: 1140px)",
@@ -315,3 +309,39 @@ func TestAssetCSSAndJSAreNotCached(t *testing.T) {
315 309 }
316 310 _ = js.Body.Close()
317 311 }
312
313 func TestOverviewGraphFollowsCSP(t *testing.T) {
314 ts, client, _ := graphTestRepo(t)
315 res := mustGet(t, client, ts.URL+"/tim/grafiek")
316 csp := res.Header.Get("Content-Security-Policy")
317 if !strings.Contains(csp, "style-src 'self'") {
318 t.Fatalf("CSP mist style-src 'self': %q", csp)
319 }
320 // style-src mag geen unsafe-inline hebben; anders zouden we
321 // per ongeluk weer op attributen leunen die een strikt beleid blokkeert.
322 if i := strings.Index(csp, "style-src"); i >= 0 {
323 part := csp[i:]
324 if j := strings.Index(part, ";"); j >= 0 {
325 part = part[:j]
326 }
327 if strings.Contains(part, "unsafe-inline") {
328 t.Fatalf("style-src staat unsafe-inline toe, dat maskeert deze bug: %q", csp)
329 }
330 }
331 page := read(t, res)
332 start := strings.Index(page, `class="commitgraph-slot`)
333 if start < 0 {
334 t.Fatal("geen commitgraph-slot")
335 }
336 end := strings.Index(page[start:], "</aside>")
337 if end < 0 {
338 end = len(page) - start
339 }
340 chunk := page[start : start+end]
341 if strings.Contains(chunk, "style=") {
342 t.Fatalf("grafiek-HTML heeft een style-attribuut, CSP negeert die: %s", chunk)
343 }
344 if !strings.Contains(chunk, `<a class="commitgraph-node`) {
345 t.Fatal("svg-knopen ontbreken")
346 }
347 }
@@ -39,35 +39,26 @@ func TestOverviewRendersCommitGraph(t *testing.T) {
39 if !strings.Contains(page, " Q ") || !strings.Contains(page, " H ") {
39 if !strings.Contains(page, " Q ") || !strings.Contains(page, " H ") {
40 t.Fatalf("verwacht afgeronde 90-graden bochten in de svg:\n%s", page)
40 t.Fatalf("verwacht afgeronde 90-graden bochten in de svg:\n%s", page)
41 }
41 }
42 if i := strings.Index(page, `class="commitgraph-svg"`); i >= 0 {
43 end := strings.Index(page[i:], "</svg>")
44 if end >= 0 && strings.Contains(page[i:i+end], "<circle") {
45 t.Fatalf("svg mag geen cirkels meer tekenen, de avatar is de knoop")
46 }
47 }
48 if !strings.Contains(page, `data-branch="master"`) {
42 if !strings.Contains(page, `data-branch="master"`) {
49 t.Fatalf("gloed-attribuut ontbreekt:\n%s", page)
43 t.Fatalf("gloed-attribuut ontbreekt:\n%s", page)
50 }
44 }
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:") {
45 if !strings.Contains(page, `class="commitgraph-slot lanes-`) {
52 t.Fatalf("inline paneelmaten ontbreken op de slot:\n%s", page)
46 t.Fatalf("slot mist lanes-N klasse (CSP-veilige paneelmaten):\n%s", page)
53 }
54 if !strings.Contains(page, "grid-template-columns:") {
55 t.Fatalf("rijen missen een pixel-grid voor de tekstkolom:\n%s", page)
56 }
47 }
57 if !strings.Contains(page, `style="left:`) {
48 if i := strings.Index(page, `class="commitgraph-slot`); i >= 0 {
58 t.Fatalf("avatars missen een inline left (moeten op hun lane staan):\n%s", page)
49 end := strings.Index(page[i:], `</div>`)
59 }
60 if i := strings.Index(page, `class="commitgraph-svg"`); i >= 0 {
61 end := strings.Index(page[i:], "</svg>")
62 chunk := page[i:]
50 chunk := page[i:]
63 if end >= 0 {
51 if end >= 0 {
64 chunk = page[i : i+end]
52 chunk = page[i : i+end]
65 }
53 }
54 if strings.Contains(chunk, "style=") {
55 t.Fatalf("commitgrafiek mag geen style-attribuut hebben (CSP style-src 'self'):\n%s", chunk)
56 }
66 if strings.Contains(chunk, "viewBox") {
57 if strings.Contains(chunk, "viewBox") {
67 t.Fatalf("commitgraph-svg mag geen viewBox hebben (schaalt de lanes):\n%s", chunk)
58 t.Fatalf("commitgraph-svg mag geen viewBox hebben:\n%s", chunk)
68 }
59 }
69 if !strings.Contains(chunk, "style=\"width:") || !strings.Contains(chunk, "left:") {
60 if !strings.Contains(chunk, `<a class="commitgraph-node`) || !strings.Contains(chunk, "<circle") {
70 t.Fatalf("commitgraph-svg mist 1:1 inline-maten:\n%s", chunk)
61 t.Fatalf("avatars horen in de SVG op de lane-x te staan:\n%s", chunk)
71 }
62 }
72 }
63 }
73 if strings.Contains(page, "ZgotmplZ") {
64 if strings.Contains(page, "ZgotmplZ") {
@@ -256,8 +247,11 @@ func TestSVGColorsAreSafe(t *testing.T) {
256 if !strings.Contains(svg, "stroke=\"var(--") {
247 if !strings.Contains(svg, "stroke=\"var(--") {
257 t.Fatalf("verwacht stroke in %s", svg)
248 t.Fatalf("verwacht stroke in %s", svg)
258 }
249 }
259 if strings.Contains(svg, "<circle") {
250 if strings.Contains(svg, "style=") {
260 t.Fatalf("geen cirkels in svg: %s", svg)
251 t.Fatalf("geen style-attribuut in svg: %s", svg)
252 }
253 if !strings.Contains(svg, "<circle") {
254 t.Fatalf("verwacht knoop-cirkels in svg: %s", svg)
261 }
255 }
262 if !strings.Contains(svg, " Q ") {
256 if !strings.Contains(svg, " Q ") {
263 t.Fatalf("verwacht afgeronde bochten in %s", svg)
257 t.Fatalf("verwacht afgeronde bochten in %s", svg)
@@ -276,21 +270,21 @@ func TestGraphCSSDoesNotShrinkLanes(t *testing.T) {
276 "minmax(0, 1fr)",
270 "minmax(0, 1fr)",
277 "text-overflow: ellipsis",
271 "text-overflow: ellipsis",
278 "--graph-lanes-w",
272 "--graph-lanes-w",
279 } {
273 ".commitgraph-slot.lanes-1 {",
280 if !strings.Contains(s, want) {
274 ".commitgraph-slot.lanes-5 { --lanes: 5; --graph-svg-w: 140px; --graph-lanes-w: 148px; --graph-w: 406px; }",
281 t.Fatalf("stylesheet mist %q", want)
282 }
283 }
284 for _, want := range []string{
285 "grid-column: 1 / -1",
286 "@container maincol (min-width: 1142px)",
275 "@container maincol (min-width: 1142px)",
287 "@media (min-width: 1400px)",
276 "@media (min-width: 1400px)",
288 "@media (min-width: 1160px)",
277 "@media (min-width: 1160px)",
278 ".commitgraph-slot:not(.is-right) { display: none !important; }",
289 } {
279 } {
290 if !strings.Contains(s, want) {
280 if !strings.Contains(s, want) {
291 t.Fatalf("stylesheet mist %q", want)
281 t.Fatalf("stylesheet mist %q", want)
292 }
282 }
293 }
283 }
284 svgW, textX, panelW := gitgraph.PanelMetrics(5)
285 if svgW != 140 || textX != 148 || panelW != 406 {
286 t.Fatalf("PanelMetrics(5)=%d,%d,%d, wil 140,148,406", svgW, textX, panelW)
287 }
294 for _, old := range []string{
288 for _, old := range []string{
295 "@media (min-width: 1860px)",
289 "@media (min-width: 1860px)",
296 "@media (min-width: 1140px)",
290 "@media (min-width: 1140px)",
@@ -315,3 +309,39 @@ func TestAssetCSSAndJSAreNotCached(t *testing.T) {
315 }
309 }
316 _ = js.Body.Close()
310 _ = js.Body.Close()
317}
311}
312
313func TestOverviewGraphFollowsCSP(t *testing.T) {
314 ts, client, _ := graphTestRepo(t)
315 res := mustGet(t, client, ts.URL+"/tim/grafiek")
316 csp := res.Header.Get("Content-Security-Policy")
317 if !strings.Contains(csp, "style-src 'self'") {
318 t.Fatalf("CSP mist style-src 'self': %q", csp)
319 }
320 // style-src mag geen unsafe-inline hebben; anders zouden we
321 // per ongeluk weer op attributen leunen die een strikt beleid blokkeert.
322 if i := strings.Index(csp, "style-src"); i >= 0 {
323 part := csp[i:]
324 if j := strings.Index(part, ";"); j >= 0 {
325 part = part[:j]
326 }
327 if strings.Contains(part, "unsafe-inline") {
328 t.Fatalf("style-src staat unsafe-inline toe, dat maskeert deze bug: %q", csp)
329 }
330 }
331 page := read(t, res)
332 start := strings.Index(page, `class="commitgraph-slot`)
333 if start < 0 {
334 t.Fatal("geen commitgraph-slot")
335 }
336 end := strings.Index(page[start:], "</aside>")
337 if end < 0 {
338 end = len(page) - start
339 }
340 chunk := page[start : start+end]
341 if strings.Contains(chunk, "style=") {
342 t.Fatalf("grafiek-HTML heeft een style-attribuut, CSP negeert die: %s", chunk)
343 }
344 if !strings.Contains(chunk, `<a class="commitgraph-node`) {
345 t.Fatal("svg-knopen ontbreken")
346 }
347}
internal/server/static/style.css +67 −30
@@ -1531,11 +1531,55 @@ li.rel-asset form.rel-asset-actions { display: inline-flex; align-items: center;
1531 1531 .status.waiting_for_job { background: #fff4e0; color: #8a5a00; }
1532 1532 form.cancelform { display: inline; }
1533 1533
1534 /* Commitgrafiek links van de centrale kolom. In de flow, zodat de
1535 kolom naar rechts schuift. De paneelbreedte (--graph-w) komt inline
1536 uit de server en krimpt niet: lanes blijven op schaal, tekst krijgt
1537 een ellipsis. Past hij niet links, dan hangt hij rechts; anders
1538 blijft hij verborgen. */
1534 /* Commitgrafiek links van de centrale kolom. Avatars zitten in de
1535 SVG op de lane-x. Breedtes komen uit .lanes-N in dit stylesheet,
1536 niet uit inline style-attributen (CSP style-src 'self'). De grafiek
1537 krimpt niet; te lange tekst krijgt een ellipsis. Past hij links niet
1538 zonder de hoofdkolom te knijpen, dan hangt hij rechts of blijft hij
1539 verborgen. */
1540 /* Paneelmaten per lanettal. Geen inline styles: CSP style-src is
1541 'self' zonder unsafe-inline, dus custom properties komen uit deze
1542 klassen (niet uit style="--graph-w: …"). */
1543 .commitgraph-slot.lanes-1 { --lanes: 1; --graph-svg-w: 28px; --graph-lanes-w: 36px; --graph-w: 294px; }
1544 .commitgraph-slot.lanes-2 { --lanes: 2; --graph-svg-w: 56px; --graph-lanes-w: 64px; --graph-w: 322px; }
1545 .commitgraph-slot.lanes-3 { --lanes: 3; --graph-svg-w: 84px; --graph-lanes-w: 92px; --graph-w: 350px; }
1546 .commitgraph-slot.lanes-4 { --lanes: 4; --graph-svg-w: 112px; --graph-lanes-w: 120px; --graph-w: 378px; }
1547 .commitgraph-slot.lanes-5 { --lanes: 5; --graph-svg-w: 140px; --graph-lanes-w: 148px; --graph-w: 406px; }
1548 .commitgraph-slot.lanes-6 { --lanes: 6; --graph-svg-w: 168px; --graph-lanes-w: 176px; --graph-w: 434px; }
1549 .commitgraph-slot.lanes-7 { --lanes: 7; --graph-svg-w: 196px; --graph-lanes-w: 204px; --graph-w: 462px; }
1550 .commitgraph-slot.lanes-8 { --lanes: 8; --graph-svg-w: 224px; --graph-lanes-w: 232px; --graph-w: 490px; }
1551 .commitgraph-slot.lanes-9 { --lanes: 9; --graph-svg-w: 252px; --graph-lanes-w: 260px; --graph-w: 518px; }
1552 .commitgraph-slot.lanes-10 { --lanes: 10; --graph-svg-w: 280px; --graph-lanes-w: 288px; --graph-w: 546px; }
1553 .commitgraph-slot.lanes-11 { --lanes: 11; --graph-svg-w: 308px; --graph-lanes-w: 316px; --graph-w: 574px; }
1554 .commitgraph-slot.lanes-12 { --lanes: 12; --graph-svg-w: 336px; --graph-lanes-w: 344px; --graph-w: 602px; }
1555 .commitgraph-slot.lanes-13 { --lanes: 13; --graph-svg-w: 364px; --graph-lanes-w: 372px; --graph-w: 630px; }
1556 .commitgraph-slot.lanes-14 { --lanes: 14; --graph-svg-w: 392px; --graph-lanes-w: 400px; --graph-w: 658px; }
1557 .commitgraph-slot.lanes-15 { --lanes: 15; --graph-svg-w: 420px; --graph-lanes-w: 428px; --graph-w: 686px; }
1558 .commitgraph-slot.lanes-16 { --lanes: 16; --graph-svg-w: 448px; --graph-lanes-w: 456px; --graph-w: 714px; }
1559 .commitgraph-slot.lanes-17 { --lanes: 17; --graph-svg-w: 476px; --graph-lanes-w: 484px; --graph-w: 742px; }
1560 .commitgraph-slot.lanes-18 { --lanes: 18; --graph-svg-w: 504px; --graph-lanes-w: 512px; --graph-w: 770px; }
1561 .commitgraph-slot.lanes-19 { --lanes: 19; --graph-svg-w: 532px; --graph-lanes-w: 540px; --graph-w: 798px; }
1562 .commitgraph-slot.lanes-20 { --lanes: 20; --graph-svg-w: 560px; --graph-lanes-w: 568px; --graph-w: 826px; }
1563 .commitgraph-slot.lanes-21 { --lanes: 21; --graph-svg-w: 588px; --graph-lanes-w: 596px; --graph-w: 854px; }
1564 .commitgraph-slot.lanes-22 { --lanes: 22; --graph-svg-w: 616px; --graph-lanes-w: 624px; --graph-w: 882px; }
1565 .commitgraph-slot.lanes-23 { --lanes: 23; --graph-svg-w: 644px; --graph-lanes-w: 652px; --graph-w: 910px; }
1566 .commitgraph-slot.lanes-24 { --lanes: 24; --graph-svg-w: 672px; --graph-lanes-w: 680px; --graph-w: 938px; }
1567 .commitgraph-slot.lanes-25 { --lanes: 25; --graph-svg-w: 700px; --graph-lanes-w: 708px; --graph-w: 966px; }
1568 .commitgraph-slot.lanes-26 { --lanes: 26; --graph-svg-w: 728px; --graph-lanes-w: 736px; --graph-w: 994px; }
1569 .commitgraph-slot.lanes-27 { --lanes: 27; --graph-svg-w: 756px; --graph-lanes-w: 764px; --graph-w: 1022px; }
1570 .commitgraph-slot.lanes-28 { --lanes: 28; --graph-svg-w: 784px; --graph-lanes-w: 792px; --graph-w: 1050px; }
1571 .commitgraph-slot.lanes-29 { --lanes: 29; --graph-svg-w: 812px; --graph-lanes-w: 820px; --graph-w: 1078px; }
1572 .commitgraph-slot.lanes-30 { --lanes: 30; --graph-svg-w: 840px; --graph-lanes-w: 848px; --graph-w: 1106px; }
1573 .commitgraph-slot.lanes-31 { --lanes: 31; --graph-svg-w: 868px; --graph-lanes-w: 876px; --graph-w: 1134px; }
1574 .commitgraph-slot.lanes-32 { --lanes: 32; --graph-svg-w: 896px; --graph-lanes-w: 904px; --graph-w: 1162px; }
1575 .commitgraph-slot.lanes-33 { --lanes: 33; --graph-svg-w: 924px; --graph-lanes-w: 932px; --graph-w: 1190px; }
1576 .commitgraph-slot.lanes-34 { --lanes: 34; --graph-svg-w: 952px; --graph-lanes-w: 960px; --graph-w: 1218px; }
1577 .commitgraph-slot.lanes-35 { --lanes: 35; --graph-svg-w: 980px; --graph-lanes-w: 988px; --graph-w: 1246px; }
1578 .commitgraph-slot.lanes-36 { --lanes: 36; --graph-svg-w: 1008px; --graph-lanes-w: 1016px; --graph-w: 1274px; }
1579 .commitgraph-slot.lanes-37 { --lanes: 37; --graph-svg-w: 1036px; --graph-lanes-w: 1044px; --graph-w: 1302px; }
1580 .commitgraph-slot.lanes-38 { --lanes: 38; --graph-svg-w: 1064px; --graph-lanes-w: 1072px; --graph-w: 1330px; }
1581 .commitgraph-slot.lanes-39 { --lanes: 39; --graph-svg-w: 1092px; --graph-lanes-w: 1100px; --graph-w: 1358px; }
1582 .commitgraph-slot.lanes-40 { --lanes: 40; --graph-svg-w: 1120px; --graph-lanes-w: 1128px; --graph-w: 1386px; }
1539 1583 .commitgraph-slot {
1540 1584 display: none;
1541 1585 position: sticky;
@@ -1567,12 +1611,15 @@ form.cancelform { display: inline; }
1567 1611 max-width: none;
1568 1612 max-height: none;
1569 1613 pointer-events: none;
1570 z-index: 0;
1614 z-index: 1;
1571 1615 flex-shrink: 0;
1616 overflow: visible;
1572 1617 }
1618 .commitgraph-svg a.commitgraph-node { pointer-events: auto; cursor: pointer; }
1619 .commitgraph-svg a.commitgraph-node:focus { outline: none; }
1620 .commitgraph-svg a.commitgraph-node:focus-visible circle { stroke: var(--c, var(--blue)); stroke-width: 2; }
1573 1621 .commitgraph-row {
1574 1622 display: grid;
1575 /* Fallback als de inline pixel-grid ontbreekt; de template zet de echte kolommen. */
1576 1623 grid-template-columns: var(--graph-ref-w) var(--graph-lanes-w, calc(var(--lanes, 1) * var(--graph-lane) + 8px)) minmax(0, 1fr);
1577 1624 align-items: center;
1578 1625 height: var(--graph-row);
@@ -1609,25 +1656,18 @@ form.cancelform { display: inline; }
1609 1656 .commitgraph-node.c5, .commitgraph-ref.c5, .commitgraph-svg .c5 { --c: var(--graph-5); color: var(--graph-5); }
1610 1657 .commitgraph-node.c6, .commitgraph-ref.c6, .commitgraph-svg .c6 { --c: var(--graph-6); color: var(--graph-6); }
1611 1658 .commitgraph-node.c7, .commitgraph-ref.c7, .commitgraph-svg .c7 { --c: var(--graph-7); color: var(--graph-7); }
1612 .commitgraph-node {
1613 /* Deel van de hele rij (niet een extra gridcel), zodat left t.o.v. de rij loopt. */
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. */
1619 left: calc(var(--graph-ref-w) + var(--lane, 0) * var(--graph-lane) + var(--graph-lane) / 2 - var(--graph-node) / 2);
1620 width: var(--graph-node); height: var(--graph-node); border-radius: 50%;
1621 z-index: 1;
1622 overflow: hidden;
1623 background: var(--c, var(--blue));
1624 color: #fff;
1625 font-size: 9px; font-weight: 700;
1626 display: grid; place-items: center;
1627 text-decoration: none;
1628 box-shadow: 0 0 0 2px var(--paper);
1659 .commitgraph-svg a.commitgraph-node circle {
1660 stroke: var(--paper);
1661 stroke-width: 2;
1662 }
1663 .commitgraph-svg a.commitgraph-node.is-glow circle,
1664 .commitgraph-svg a.commitgraph-node.is-glow image {
1665 filter: drop-shadow(0 0 2px var(--c, var(--blue)));
1666 }
1667 .commitgraph-svg a.commitgraph-node.is-glow circle {
1668 stroke: var(--c, var(--blue));
1669 stroke-width: 2.5;
1629 1670 }
1630 .commitgraph-node img { width: var(--graph-node); height: var(--graph-node); object-fit: cover; display: block; }
1631 1671 .commitgraph-msg {
1632 1672 min-width: 0;
1633 1673 color: var(--ink);
@@ -1639,9 +1679,6 @@ form.cancelform { display: inline; }
1639 1679 stroke-width: 2.5;
1640 1680 filter: drop-shadow(0 0 2px var(--c, var(--blue)));
1641 1681 }
1642 .commitgraph-node.is-glow {
1643 box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px var(--c, var(--blue));
1644 }
1645 1682 .commitgraph-ref.is-glow { box-shadow: 0 0 0 1px var(--c, var(--blue)); }
1646 1683 /* Toon links alleen als de grafiek plus een bruikbare hoofdkolom
1647 1684 (~720px, voor last-commit-balk en knoppen) past. Op 1280px met
@@ -1676,10 +1713,10 @@ form.cancelform { display: inline; }
1676 1713 .frame:not(.with-side) .commitgraph { margin-right: var(--graph-gap); }
1677 1714 }
1678 1715 @media (max-width: 1159px) {
1679 .frame:not(.with-side) .commitgraph-slot:not(.is-right) { display: none; }
1716 .commitgraph-slot:not(.is-right) { display: none !important; }
1680 1717 }
1681 1718 @media (max-width: 1399px) {
1682 .frame.with-side .commitgraph-slot:not(.is-right) { display: none; }
1719 .frame.with-side .commitgraph-slot:not(.is-right) { display: none !important; }
1683 1720 }
1684 1721 .commitgraph-slot.is-right {
1685 1722 display: block;
@@ -1531,11 +1531,55 @@ li.rel-asset form.rel-asset-actions { display: inline-flex; align-items: center;
1531.status.waiting_for_job { background: #fff4e0; color: #8a5a00; }
1531.status.waiting_for_job { background: #fff4e0; color: #8a5a00; }
1532form.cancelform { display: inline; }
1532form.cancelform { display: inline; }
1533
1533
1534/* Commitgrafiek links van de centrale kolom. In de flow, zodat de
1534/* Commitgrafiek links van de centrale kolom. Avatars zitten in de
1535 kolom naar rechts schuift. De paneelbreedte (--graph-w) komt inline
1535 SVG op de lane-x. Breedtes komen uit .lanes-N in dit stylesheet,
1536 uit de server en krimpt niet: lanes blijven op schaal, tekst krijgt
1536 niet uit inline style-attributen (CSP style-src 'self'). De grafiek
1537 een ellipsis. Past hij niet links, dan hangt hij rechts; anders
1537 krimpt niet; te lange tekst krijgt een ellipsis. Past hij links niet
1538 blijft hij verborgen. */
1538 zonder de hoofdkolom te knijpen, dan hangt hij rechts of blijft hij
1539 verborgen. */
1540/* Paneelmaten per lanettal. Geen inline styles: CSP style-src is
1541 'self' zonder unsafe-inline, dus custom properties komen uit deze
1542 klassen (niet uit style="--graph-w: …"). */
1543.commitgraph-slot.lanes-1 { --lanes: 1; --graph-svg-w: 28px; --graph-lanes-w: 36px; --graph-w: 294px; }
1544.commitgraph-slot.lanes-2 { --lanes: 2; --graph-svg-w: 56px; --graph-lanes-w: 64px; --graph-w: 322px; }
1545.commitgraph-slot.lanes-3 { --lanes: 3; --graph-svg-w: 84px; --graph-lanes-w: 92px; --graph-w: 350px; }
1546.commitgraph-slot.lanes-4 { --lanes: 4; --graph-svg-w: 112px; --graph-lanes-w: 120px; --graph-w: 378px; }
1547.commitgraph-slot.lanes-5 { --lanes: 5; --graph-svg-w: 140px; --graph-lanes-w: 148px; --graph-w: 406px; }
1548.commitgraph-slot.lanes-6 { --lanes: 6; --graph-svg-w: 168px; --graph-lanes-w: 176px; --graph-w: 434px; }
1549.commitgraph-slot.lanes-7 { --lanes: 7; --graph-svg-w: 196px; --graph-lanes-w: 204px; --graph-w: 462px; }
1550.commitgraph-slot.lanes-8 { --lanes: 8; --graph-svg-w: 224px; --graph-lanes-w: 232px; --graph-w: 490px; }
1551.commitgraph-slot.lanes-9 { --lanes: 9; --graph-svg-w: 252px; --graph-lanes-w: 260px; --graph-w: 518px; }
1552.commitgraph-slot.lanes-10 { --lanes: 10; --graph-svg-w: 280px; --graph-lanes-w: 288px; --graph-w: 546px; }
1553.commitgraph-slot.lanes-11 { --lanes: 11; --graph-svg-w: 308px; --graph-lanes-w: 316px; --graph-w: 574px; }
1554.commitgraph-slot.lanes-12 { --lanes: 12; --graph-svg-w: 336px; --graph-lanes-w: 344px; --graph-w: 602px; }
1555.commitgraph-slot.lanes-13 { --lanes: 13; --graph-svg-w: 364px; --graph-lanes-w: 372px; --graph-w: 630px; }
1556.commitgraph-slot.lanes-14 { --lanes: 14; --graph-svg-w: 392px; --graph-lanes-w: 400px; --graph-w: 658px; }
1557.commitgraph-slot.lanes-15 { --lanes: 15; --graph-svg-w: 420px; --graph-lanes-w: 428px; --graph-w: 686px; }
1558.commitgraph-slot.lanes-16 { --lanes: 16; --graph-svg-w: 448px; --graph-lanes-w: 456px; --graph-w: 714px; }
1559.commitgraph-slot.lanes-17 { --lanes: 17; --graph-svg-w: 476px; --graph-lanes-w: 484px; --graph-w: 742px; }
1560.commitgraph-slot.lanes-18 { --lanes: 18; --graph-svg-w: 504px; --graph-lanes-w: 512px; --graph-w: 770px; }
1561.commitgraph-slot.lanes-19 { --lanes: 19; --graph-svg-w: 532px; --graph-lanes-w: 540px; --graph-w: 798px; }
1562.commitgraph-slot.lanes-20 { --lanes: 20; --graph-svg-w: 560px; --graph-lanes-w: 568px; --graph-w: 826px; }
1563.commitgraph-slot.lanes-21 { --lanes: 21; --graph-svg-w: 588px; --graph-lanes-w: 596px; --graph-w: 854px; }
1564.commitgraph-slot.lanes-22 { --lanes: 22; --graph-svg-w: 616px; --graph-lanes-w: 624px; --graph-w: 882px; }
1565.commitgraph-slot.lanes-23 { --lanes: 23; --graph-svg-w: 644px; --graph-lanes-w: 652px; --graph-w: 910px; }
1566.commitgraph-slot.lanes-24 { --lanes: 24; --graph-svg-w: 672px; --graph-lanes-w: 680px; --graph-w: 938px; }
1567.commitgraph-slot.lanes-25 { --lanes: 25; --graph-svg-w: 700px; --graph-lanes-w: 708px; --graph-w: 966px; }
1568.commitgraph-slot.lanes-26 { --lanes: 26; --graph-svg-w: 728px; --graph-lanes-w: 736px; --graph-w: 994px; }
1569.commitgraph-slot.lanes-27 { --lanes: 27; --graph-svg-w: 756px; --graph-lanes-w: 764px; --graph-w: 1022px; }
1570.commitgraph-slot.lanes-28 { --lanes: 28; --graph-svg-w: 784px; --graph-lanes-w: 792px; --graph-w: 1050px; }
1571.commitgraph-slot.lanes-29 { --lanes: 29; --graph-svg-w: 812px; --graph-lanes-w: 820px; --graph-w: 1078px; }
1572.commitgraph-slot.lanes-30 { --lanes: 30; --graph-svg-w: 840px; --graph-lanes-w: 848px; --graph-w: 1106px; }
1573.commitgraph-slot.lanes-31 { --lanes: 31; --graph-svg-w: 868px; --graph-lanes-w: 876px; --graph-w: 1134px; }
1574.commitgraph-slot.lanes-32 { --lanes: 32; --graph-svg-w: 896px; --graph-lanes-w: 904px; --graph-w: 1162px; }
1575.commitgraph-slot.lanes-33 { --lanes: 33; --graph-svg-w: 924px; --graph-lanes-w: 932px; --graph-w: 1190px; }
1576.commitgraph-slot.lanes-34 { --lanes: 34; --graph-svg-w: 952px; --graph-lanes-w: 960px; --graph-w: 1218px; }
1577.commitgraph-slot.lanes-35 { --lanes: 35; --graph-svg-w: 980px; --graph-lanes-w: 988px; --graph-w: 1246px; }
1578.commitgraph-slot.lanes-36 { --lanes: 36; --graph-svg-w: 1008px; --graph-lanes-w: 1016px; --graph-w: 1274px; }
1579.commitgraph-slot.lanes-37 { --lanes: 37; --graph-svg-w: 1036px; --graph-lanes-w: 1044px; --graph-w: 1302px; }
1580.commitgraph-slot.lanes-38 { --lanes: 38; --graph-svg-w: 1064px; --graph-lanes-w: 1072px; --graph-w: 1330px; }
1581.commitgraph-slot.lanes-39 { --lanes: 39; --graph-svg-w: 1092px; --graph-lanes-w: 1100px; --graph-w: 1358px; }
1582.commitgraph-slot.lanes-40 { --lanes: 40; --graph-svg-w: 1120px; --graph-lanes-w: 1128px; --graph-w: 1386px; }
1539.commitgraph-slot {
1583.commitgraph-slot {
1540 display: none;
1584 display: none;
1541 position: sticky;
1585 position: sticky;
@@ -1567,12 +1611,15 @@ form.cancelform { display: inline; }
1567 max-width: none;
1611 max-width: none;
1568 max-height: none;
1612 max-height: none;
1569 pointer-events: none;
1613 pointer-events: none;
1570 z-index: 0;
1614 z-index: 1;
1571 flex-shrink: 0;
1615 flex-shrink: 0;
1616 overflow: visible;
1572}
1617}
1618.commitgraph-svg a.commitgraph-node { pointer-events: auto; cursor: pointer; }
1619.commitgraph-svg a.commitgraph-node:focus { outline: none; }
1620.commitgraph-svg a.commitgraph-node:focus-visible circle { stroke: var(--c, var(--blue)); stroke-width: 2; }
1573.commitgraph-row {
1621.commitgraph-row {
1574 display: grid;
1622 display: grid;
1575 /* Fallback als de inline pixel-grid ontbreekt; de template zet de echte kolommen. */
1576 grid-template-columns: var(--graph-ref-w) var(--graph-lanes-w, calc(var(--lanes, 1) * var(--graph-lane) + 8px)) minmax(0, 1fr);
1623 grid-template-columns: var(--graph-ref-w) var(--graph-lanes-w, calc(var(--lanes, 1) * var(--graph-lane) + 8px)) minmax(0, 1fr);
1577 align-items: center;
1624 align-items: center;
1578 height: var(--graph-row);
1625 height: var(--graph-row);
@@ -1609,25 +1656,18 @@ form.cancelform { display: inline; }
1609.commitgraph-node.c5, .commitgraph-ref.c5, .commitgraph-svg .c5 { --c: var(--graph-5); color: var(--graph-5); }
1656.commitgraph-node.c5, .commitgraph-ref.c5, .commitgraph-svg .c5 { --c: var(--graph-5); color: var(--graph-5); }
1610.commitgraph-node.c6, .commitgraph-ref.c6, .commitgraph-svg .c6 { --c: var(--graph-6); color: var(--graph-6); }
1657.commitgraph-node.c6, .commitgraph-ref.c6, .commitgraph-svg .c6 { --c: var(--graph-6); color: var(--graph-6); }
1611.commitgraph-node.c7, .commitgraph-ref.c7, .commitgraph-svg .c7 { --c: var(--graph-7); color: var(--graph-7); }
1658.commitgraph-node.c7, .commitgraph-ref.c7, .commitgraph-svg .c7 { --c: var(--graph-7); color: var(--graph-7); }
1612.commitgraph-node {
1659.commitgraph-svg a.commitgraph-node circle {
1613 /* Deel van de hele rij (niet een extra gridcel), zodat left t.o.v. de rij loopt. */
1660 stroke: var(--paper);
1614 position: absolute;
1661 stroke-width: 2;
1615 grid-column: 1 / -1;
1662}
1616 grid-row: 1;
1663.commitgraph-svg a.commitgraph-node.is-glow circle,
1617 top: calc((var(--graph-row) - var(--graph-node)) / 2);
1664.commitgraph-svg a.commitgraph-node.is-glow image {
1618 /* Fallback; de template zet left in pixels op het element zelf. */
1665 filter: drop-shadow(0 0 2px var(--c, var(--blue)));
1619 left: calc(var(--graph-ref-w) + var(--lane, 0) * var(--graph-lane) + var(--graph-lane) / 2 - var(--graph-node) / 2);
1666}
1620 width: var(--graph-node); height: var(--graph-node); border-radius: 50%;
1667.commitgraph-svg a.commitgraph-node.is-glow circle {
1621 z-index: 1;
1668 stroke: var(--c, var(--blue));
1622 overflow: hidden;
1669 stroke-width: 2.5;
1623 background: var(--c, var(--blue));
1624 color: #fff;
1625 font-size: 9px; font-weight: 700;
1626 display: grid; place-items: center;
1627 text-decoration: none;
1628 box-shadow: 0 0 0 2px var(--paper);
1629}
1670}
1630.commitgraph-node img { width: var(--graph-node); height: var(--graph-node); object-fit: cover; display: block; }
1631.commitgraph-msg {
1671.commitgraph-msg {
1632 min-width: 0;
1672 min-width: 0;
1633 color: var(--ink);
1673 color: var(--ink);
@@ -1639,9 +1679,6 @@ form.cancelform { display: inline; }
1639 stroke-width: 2.5;
1679 stroke-width: 2.5;
1640 filter: drop-shadow(0 0 2px var(--c, var(--blue)));
1680 filter: drop-shadow(0 0 2px var(--c, var(--blue)));
1641}
1681}
1642.commitgraph-node.is-glow {
1643 box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px var(--c, var(--blue));
1644}
1645.commitgraph-ref.is-glow { box-shadow: 0 0 0 1px var(--c, var(--blue)); }
1682.commitgraph-ref.is-glow { box-shadow: 0 0 0 1px var(--c, var(--blue)); }
1646/* Toon links alleen als de grafiek plus een bruikbare hoofdkolom
1683/* Toon links alleen als de grafiek plus een bruikbare hoofdkolom
1647 (~720px, voor last-commit-balk en knoppen) past. Op 1280px met
1684 (~720px, voor last-commit-balk en knoppen) past. Op 1280px met
@@ -1676,10 +1713,10 @@ form.cancelform { display: inline; }
1676 .frame:not(.with-side) .commitgraph { margin-right: var(--graph-gap); }
1713 .frame:not(.with-side) .commitgraph { margin-right: var(--graph-gap); }
1677}
1714}
1678@media (max-width: 1159px) {
1715@media (max-width: 1159px) {
1679 .frame:not(.with-side) .commitgraph-slot:not(.is-right) { display: none; }
1716 .commitgraph-slot:not(.is-right) { display: none !important; }
1680}
1717}
1681@media (max-width: 1399px) {
1718@media (max-width: 1399px) {
1682 .frame.with-side .commitgraph-slot:not(.is-right) { display: none; }
1719 .frame.with-side .commitgraph-slot:not(.is-right) { display: none !important; }
1683}
1720}
1684.commitgraph-slot.is-right {
1721.commitgraph-slot.is-right {
1685 display: block;
1722 display: block;
internal/server/templates/commitgraph.html +2 −3
@@ -1,14 +1,13 @@
1 1 {{define "commitgraph"}}
2 <div class="commitgraph-slot" style="--lanes: {{.Graph.Lanes}}; --graph-w: {{.Graph.PanelWidth}}px; --graph-lanes-w: {{.Graph.TextX}}px; --graph-svg-w: {{.Graph.Width}}px">
2 <div class="commitgraph-slot lanes-{{.Graph.Lanes}}">
3 3 <aside class="commitgraph" aria-label="{{t "graph.label"}}" data-selected="{{.Rev}}">
4 4 {{.Graph.SVG}}
5 5 <ol class="commitgraph-list">
6 6 {{range .Graph.Rows}}
7 <li class="commitgraph-row" style="--lane: {{.Lane}}; grid-template-columns: {{$.Graph.RefW}}px {{$.Graph.TextX}}px minmax(0, 1fr)">
7 <li class="commitgraph-row"{{if .Branch}} data-branch="{{.Branch}}"{{end}}>
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}}" style="left: {{.NodeLeft}}px"{{if .Branch}} data-branch="{{.Branch}}"{{end}}>{{if .Avatar}}<img src="{{.Avatar}}" alt="">{{else}}<span>{{.Initial}}</span>{{end}}</a>
12 11 </li>
13 12 {{end}}
14 13 </ol>
@@ -1,14 +1,13 @@
1{{define "commitgraph"}}
1{{define "commitgraph"}}
2<div class="commitgraph-slot" style="--lanes: {{.Graph.Lanes}}; --graph-w: {{.Graph.PanelWidth}}px; --graph-lanes-w: {{.Graph.TextX}}px; --graph-svg-w: {{.Graph.Width}}px">
2<div class="commitgraph-slot lanes-{{.Graph.Lanes}}">
3<aside class="commitgraph" aria-label="{{t "graph.label"}}" data-selected="{{.Rev}}">
3<aside class="commitgraph" aria-label="{{t "graph.label"}}" data-selected="{{.Rev}}">
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}}; grid-template-columns: {{$.Graph.RefW}}px {{$.Graph.TextX}}px minmax(0, 1fr)">
7 <li class="commitgraph-row"{{if .Branch}} data-branch="{{.Branch}}"{{end}}>
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}}" style="left: {{.NodeLeft}}px"{{if .Branch}} data-branch="{{.Branch}}"{{end}}>{{if .Avatar}}<img src="{{.Avatar}}" alt="">{{else}}<span>{{.Initial}}</span>{{end}}</a>
12 </li>
11 </li>
13 {{end}}
12 {{end}}
14 </ol>
13 </ol>