blob: 0a7b4045951509d228c66f422caf598a8beb3303 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
|
# cgit — CSS Theming
## Overview
cgit ships with a comprehensive CSS stylesheet (`cgit.css`) that controls
the visual appearance of all pages. The stylesheet is designed with a light
color scheme and semantic CSS classes that map directly to cgit's HTML
structure.
Source file: `cgit.css` (~450 lines).
## Loading Stylesheets
CSS files are specified via the `css` configuration directive:
```ini
css=/cgit/cgit.css
```
Multiple stylesheets can be loaded by repeating the directive:
```ini
css=/cgit/cgit.css
css=/cgit/custom.css
```
Stylesheets are included in document order in the `<head>` section via
`cgit_print_docstart()` in `ui-shared.c`.
## Page Structure
The HTML layout uses this basic structure:
```html
<body>
<div id='cgit'>
<table id='header'>...</table> <!-- site header with logo -->
<table id='navigation'>...</table> <!-- tab navigation -->
<div id='content'> <!-- page content -->
<!-- page-specific content -->
</div>
<div class='footer'>...</div> <!-- footer -->
</div>
</body>
```
## Base Styles
### Body and Layout
```css
body {
font-family: sans-serif;
font-size: 11px;
color: #000;
background: white;
padding: 4px;
}
div#cgit {
padding: 0;
margin: 0;
font-family: monospace;
font-size: 12px;
}
```
### Header
```css
table#header {
width: 100%;
margin-bottom: 1em;
}
table#header td.logo {
/* logo cell */
}
table#header td.main {
font-size: 250%;
font-weight: bold;
vertical-align: bottom;
padding-left: 10px;
}
table#header td.sub {
color: #999;
font-size: 75%;
vertical-align: top;
padding-left: 10px;
}
```
### Navigation Tabs
```css
table#navigation {
width: 100%;
}
table#navigation a {
padding: 2px 6px;
color: #000;
text-decoration: none;
}
table#navigation a:hover {
color: #00f;
}
```
## Content Areas
### Repository List
```css
table.list {
border-collapse: collapse;
border: solid 1px #aaa;
width: 100%;
}
table.list th {
text-align: left;
font-weight: bold;
background: #ddd;
border-bottom: solid 1px #aaa;
padding: 2px 4px;
}
table.list td {
padding: 2px 4px;
border: none;
}
table.list tr:hover {
background: #eee;
}
table.list td a {
color: #00f;
text-decoration: none;
}
table.list td a:hover {
text-decoration: underline;
}
```
### Sections
```css
div.section-header {
background: #eee;
border: solid 1px #ddd;
padding: 2px 4px;
font-weight: bold;
margin-top: 1em;
}
```
## Diff Styles
### Diffstat
```css
table.diffstat {
border-collapse: collapse;
border: solid 1px #aaa;
}
table.diffstat td {
padding: 1px 4px;
border: none;
}
table.diffstat td.mode {
font-weight: bold;
/* status indicator: A/M/D/R */
}
table.diffstat td.graph {
width: 500px;
}
table.diffstat td.graph span.add {
background: #5f5;
/* green bar for additions */
}
table.diffstat td.graph span.rem {
background: #f55;
/* red bar for deletions */
}
table.diffstat .total {
font-weight: bold;
text-align: center;
}
```
### Unified Diff
```css
table.diff {
width: 100%;
}
table.diff td div.head {
font-weight: bold;
margin-top: 1em;
color: #000;
}
table.diff td div.hunk {
color: #009;
/* hunk header @@ ... @@ */
}
table.diff td div.add {
color: green;
background: #dfd;
}
table.diff td div.del {
color: red;
background: #fdd;
}
```
### Side-by-Side Diff
```css
table.ssdiff {
width: 100%;
}
table.ssdiff td {
font-family: monospace;
font-size: 12px;
padding: 1px 4px;
vertical-align: top;
}
table.ssdiff td.lineno {
text-align: right;
width: 3em;
background: #eee;
color: #999;
}
table.ssdiff td.add {
background: #dfd;
}
table.ssdiff td.del {
background: #fdd;
}
table.ssdiff td.changed {
background: #ffc;
}
table.ssdiff span.add {
background: #afa;
font-weight: bold;
}
table.ssdiff span.del {
background: #faa;
font-weight: bold;
}
```
## Blob/Tree View
```css
table.blob {
border-collapse: collapse;
width: 100%;
}
table.blob td {
font-family: monospace;
font-size: 12px;
padding: 0 4px;
vertical-align: top;
}
table.blob td.linenumbers {
text-align: right;
color: #999;
background: #eee;
width: 3em;
border-right: solid 1px #ddd;
}
table.blob td.lines {
white-space: pre;
}
```
### Tree Listing
```css
table.list td.ls-mode {
font-family: monospace;
width: 10em;
}
table.list td.ls-size {
text-align: right;
width: 5em;
}
```
## Commit View
```css
table.commit-info {
border-collapse: collapse;
border: solid 1px #aaa;
margin-bottom: 1em;
}
table.commit-info th {
text-align: left;
font-weight: bold;
padding: 2px 6px;
vertical-align: top;
}
table.commit-info td {
padding: 2px 6px;
}
div.commit-subject {
font-weight: bold;
font-size: 125%;
margin: 1em 0 0.5em;
}
div.commit-msg {
white-space: pre;
font-family: monospace;
}
div.notes-header {
font-weight: bold;
padding-top: 1em;
}
div.notes {
white-space: pre;
font-family: monospace;
border-left: solid 3px #dd5;
padding: 0.5em;
background: #ffe;
}
```
## Log View
```css
div.commit-graph {
font-family: monospace;
white-space: pre;
color: #000;
}
/* Column colors for commit graph */
.column1 { color: #a00; }
.column2 { color: #0a0; }
.column3 { color: #00a; }
.column4 { color: #aa0; }
.column5 { color: #0aa; }
.column6 { color: #a0a; }
```
## Stats View
```css
table.stats {
border-collapse: collapse;
border: solid 1px #aaa;
}
table.stats th {
text-align: left;
padding: 2px 6px;
background: #ddd;
}
table.stats td {
padding: 2px 6px;
}
div.stats-graph {
/* bar chart container */
}
```
## Form Elements
```css
div.cgit-panel {
float: right;
margin: 0 0 0.5em 0.5em;
padding: 4px;
border: solid 1px #aaa;
background: #eee;
}
div.cgit-panel b {
display: block;
margin-bottom: 2px;
}
div.cgit-panel select,
div.cgit-panel input {
font-size: 11px;
}
```
## Customization Strategies
### Method 1: Override Stylesheet
Create a custom CSS file that overrides specific rules:
```css
/* /cgit/custom.css */
body {
background: #1a1a2e;
color: #e0e0e0;
}
div#cgit {
background: #16213e;
}
table.list th {
background: #0f3460;
color: #e0e0e0;
}
```
```ini
css=/cgit/cgit.css
css=/cgit/custom.css
```
### Method 2: Replace Stylesheet
Replace the default stylesheet entirely:
```ini
css=/cgit/mytheme.css
```
### Method 3: head-include
Inject inline styles via the `head-include` directive:
```ini
head-include=/etc/cgit/extra-head.html
```
```html
<!-- /etc/cgit/extra-head.html -->
<style>
body { background: #f0f0f0; }
</style>
```
## CSS Classes Reference
### Layout Classes
| Class/ID | Element | Description |
|----------|---------|-------------|
| `#cgit` | div | Main container |
| `#header` | table | Site header |
| `#navigation` | table | Tab navigation |
| `#content` | div | Page content area |
| `.footer` | div | Page footer |
### Content Classes
| Class | Element | Description |
|-------|---------|-------------|
| `.list` | table | Data listing (repos, files, refs) |
| `.blob` | table | File content display |
| `.diff` | table | Unified diff |
| `.ssdiff` | table | Side-by-side diff |
| `.diffstat` | table | Diff statistics |
| `.commit-info` | table | Commit metadata |
| `.stats` | table | Statistics data |
| `.cgit-panel` | div | Control panel |
### Diff Classes
| Class | Element | Description |
|-------|---------|-------------|
| `.add` | div/span | Added lines/chars |
| `.del` | div/span | Deleted lines/chars |
| `.hunk` | div | Hunk header |
| `.ctx` | div | Context lines |
| `.head` | div | File header |
| `.changed` | td | Modified line (ssdiff) |
| `.lineno` | td | Line number column |
### Status Classes
| Class | Description |
|-------|-------------|
| `.upd` | Modified file |
| `.add` | Added file |
| `.del` | Deleted file |
| `.mode` | File mode indicator |
| `.graph` | Graph bar container |
|