-rw-r--r-- | cgit.css | 149 | ||||
-rw-r--r-- | cgit.h | 2 | ||||
-rw-r--r-- | cgit.png | bin | 0 -> 3790 bytes | |||
-rw-r--r-- | cgitrc | 9 | ||||
-rw-r--r-- | shared.c | 31 | ||||
-rw-r--r-- | ui-shared.c | 172 | ||||
-rw-r--r-- | ui-summary.c | 65 |
7 files changed, 231 insertions, 197 deletions
@@ -1,454 +1,431 @@ | |||
1 | body { | ||
2 | font-family: arial, sans-serif; | ||
3 | font-size: 11pt; | ||
4 | color: black; | ||
5 | background: white; | ||
6 | } | ||
7 | |||
8 | body, table { | 1 | body, table { |
9 | padding: 0em; | 2 | padding: 0em; |
10 | margin: 0em; | 3 | margin: 0em; |
11 | } | 4 | } |
12 | 5 | ||
6 | body { | ||
7 | font-family: sans; | ||
8 | font-size: 10pt; | ||
9 | color: #333; | ||
10 | background: white; | ||
11 | padding-left: 4px; | ||
12 | } | ||
13 | |||
13 | table { | 14 | table { |
14 | border-collapse: collapse; | 15 | border-collapse: collapse; |
15 | } | 16 | } |
16 | 17 | ||
17 | h2 { | 18 | h2 { |
18 | font-size: 120%; | 19 | font-size: 120%; |
19 | font-weight: bold; | 20 | font-weight: bold; |
20 | margin-top: 0em; | 21 | margin-top: 0em; |
21 | margin-bottom: 0.25em; | 22 | margin-bottom: 0.25em; |
22 | } | 23 | } |
23 | 24 | ||
24 | h3 { | 25 | h3 { |
25 | margin-top: 0em; | 26 | margin-top: 0em; |
26 | font-size: 100%; | 27 | font-size: 100%; |
27 | font-weight: normal; | 28 | font-weight: normal; |
28 | } | 29 | } |
29 | 30 | ||
30 | h4 { | 31 | h4 { |
31 | margin-top: 1.5em; | 32 | margin-top: 1.5em; |
32 | margin-bottom: 0.1em; | 33 | margin-bottom: 0.1em; |
33 | font-size: 100%; | 34 | font-size: 100%; |
34 | font-weight: bold; | 35 | font-weight: bold; |
35 | } | 36 | } |
36 | 37 | ||
37 | a { | 38 | a { |
38 | color: blue; | 39 | color: #600; |
39 | text-decoration: none; | 40 | text-decoration: none; |
40 | } | 41 | } |
41 | 42 | ||
42 | a:hover { | 43 | a:hover { |
43 | text-decoration: underline; | 44 | background-color: #ddd; |
45 | text-decoration: none; | ||
44 | } | 46 | } |
45 | 47 | ||
46 | table.list { | 48 | table.list { |
47 | border: none; | 49 | border: none; |
48 | border-collapse: collapse; | 50 | border-collapse: collapse; |
49 | } | 51 | } |
50 | 52 | ||
51 | table.list tr { | 53 | table.list tr { |
52 | background: white; | 54 | background: white; |
53 | } | 55 | } |
54 | 56 | ||
55 | table.list tr:hover { | 57 | table.list tr:hover { |
56 | background: #eee; | 58 | background: #f8f8f8; |
57 | } | 59 | } |
58 | 60 | ||
59 | table.list tr.nohover:hover { | 61 | table.list tr.nohover:hover { |
60 | background: white; | 62 | background: white; |
61 | } | 63 | } |
62 | 64 | ||
63 | table.list th { | 65 | table.list th { |
64 | font-weight: bold; | 66 | font-weight: bold; |
65 | border-bottom: solid 1px #777; | 67 | border-bottom: solid 1px #777; |
66 | padding: 0.1em 0.5em 0.1em 0.5em; | 68 | padding: 0.1em 0.5em 0.1em 0.5em; |
67 | vertical-align: baseline; | 69 | vertical-align: baseline; |
68 | } | 70 | } |
69 | 71 | ||
70 | table.list td { | 72 | table.list td { |
71 | border: none; | 73 | border: none; |
72 | padding: 0.1em 0.5em 0.1em 0.5em; | 74 | padding: 0.1em 0.5em 0.1em 0.5em; |
73 | } | 75 | } |
74 | 76 | ||
75 | img { | 77 | img { |
76 | border: none; | 78 | border: none; |
77 | } | 79 | } |
78 | 80 | ||
79 | table#layout { | 81 | div#sidebar { |
80 | width: 100%; | 82 | vertical-align: top; |
81 | border-collapse: collapse; | 83 | width: 162px; |
82 | margin: 0px; | 84 | padding: 0px 0px 0px 0px; |
83 | } | 85 | margin: 4px; |
84 | 86 | float: left; | |
85 | td#header, td#logo { | ||
86 | color: #666; | ||
87 | background-color: #ddd; | ||
88 | border-bottom: solid 1px #000; | ||
89 | } | ||
90 | |||
91 | td#header { | ||
92 | font-size: 150%; | ||
93 | font-weight: bold; | ||
94 | padding: 0.2em 0.5em; | ||
95 | vertical-align: text-bottom; | ||
96 | } | ||
97 | |||
98 | td#header a { | ||
99 | color: #666; | ||
100 | } | ||
101 | |||
102 | td#header a:hover { | ||
103 | text-decoration: underline; | ||
104 | } | 87 | } |
105 | 88 | ||
106 | td#logo { | 89 | div#logo { |
107 | text-align: right; | 90 | margin: 0px; |
108 | vertical-align: middle; | 91 | padding: 4px 0px 4px 0px; |
109 | padding-right: 0.5em; | 92 | text-align: center; |
93 | background-color: #ccc; | ||
94 | border-top: solid 1px #eee; | ||
95 | border-left: solid 1px #eee; | ||
96 | border-right: solid 1px #aaa; | ||
97 | border-bottom: solid 1px #aaa; | ||
110 | } | 98 | } |
111 | 99 | ||
112 | td#crumb, td#search { | 100 | div#sidebar div.infobox { |
113 | color: #ccc; | 101 | margin: 0px 0px 0pax 0px; |
114 | border-top: solid 3px #555; | 102 | padding: 0.5em; |
115 | background-color: #666; | 103 | text-align: left; |
116 | border-bottom: solid 1px #333; | 104 | background-color: #ccc; |
117 | padding: 2px 1em; | 105 | border-top: solid 1px #eee; |
106 | border-left: solid 1px #eee; | ||
107 | border-right: solid 1px #aaa; | ||
108 | border-bottom: solid 1px #aaa; | ||
118 | } | 109 | } |
119 | 110 | ||
120 | td#crumb { | 111 | div#sidebar div.infobox h1 { |
112 | font-size: 11pt; | ||
121 | font-weight: bold; | 113 | font-weight: bold; |
114 | margin: 0px; | ||
122 | } | 115 | } |
123 | 116 | ||
124 | td#crumb a { | 117 | div#sidebar div.infobox a.menu { |
125 | color: #ccc; | 118 | display: block; |
126 | background-color: #666; | ||
127 | padding: 0em 0.5em 0em 0.5em; | ||
128 | } | ||
129 | |||
130 | td#crumb a:hover { | ||
131 | color: #666; | ||
132 | background-color: #ccc; | 119 | background-color: #ccc; |
120 | padding: 0.1em 0.5em; | ||
133 | text-decoration: none; | 121 | text-decoration: none; |
134 | } | 122 | } |
135 | 123 | ||
136 | td#search { | 124 | div#sidebar div.infobox a.menu:hover { |
137 | text-align: right; | 125 | background-color: #bbb; |
138 | vertical-align: middle; | 126 | text-decoration: none; |
139 | padding-right: 0.5em; | ||
140 | } | ||
141 | |||
142 | td#search form { | ||
143 | margin: 0px; | ||
144 | padding: 0px; | ||
145 | } | 127 | } |
146 | 128 | ||
147 | td#search select { | 129 | div#sidebar div.infobox select { |
148 | font-size: 9pt; | 130 | width: 100%; |
131 | border: solid 1px #aaa; | ||
132 | background-color: #bbb; | ||
133 | margin: 2px 0px 0px 0px; | ||
149 | padding: 0px; | 134 | padding: 0px; |
150 | border: solid 1px #333; | ||
151 | color: #333; | ||
152 | background-color: #fff; | ||
153 | } | 135 | } |
154 | 136 | ||
155 | td#search input { | 137 | div#sidebar div.infobox input.txt { |
156 | font-size: 9pt; | 138 | width: 100%; |
157 | padding: 0px; | 139 | border: solid 1px #aaa; |
140 | background-color: #bbb; | ||
141 | margin: 2px 0px 0px 0px; | ||
142 | padding: 0; | ||
158 | } | 143 | } |
159 | 144 | ||
160 | td#search input.txt { | 145 | table#grid { |
161 | width: 8em; | 146 | margin: 0px; |
162 | border: solid 1px #333; | ||
163 | color: #333; | ||
164 | background-color: #fff; | ||
165 | } | 147 | } |
166 | 148 | ||
167 | td#search input.btn { | 149 | td#content { |
168 | border: solid 1px #333; | 150 | vertical-align: top; |
169 | color: #333; | 151 | padding: 1em 2em 1em 1em; |
170 | background-color: #ccc; | 152 | border: none; |
171 | } | 153 | } |
172 | 154 | ||
173 | div#summary { | 155 | div#summary { |
174 | vertical-align: top; | 156 | vertical-align: top; |
175 | margin-bottom: 1em; | 157 | margin-bottom: 1em; |
176 | } | 158 | } |
177 | 159 | ||
178 | table#downloads { | 160 | table#downloads { |
179 | float: right; | 161 | float: right; |
180 | border-collapse: collapse; | 162 | border-collapse: collapse; |
181 | border: solid 1px #777; | 163 | border: solid 1px #777; |
182 | margin-left: 0.5em; | 164 | margin-left: 0.5em; |
183 | margin-bottom: 0.5em; | 165 | margin-bottom: 0.5em; |
184 | } | 166 | } |
185 | 167 | ||
186 | table#downloads th { | 168 | table#downloads th { |
187 | background-color: #ccc; | 169 | background-color: #ccc; |
188 | } | 170 | } |
189 | 171 | ||
190 | td#content { | ||
191 | padding: 1em 0.5em; | ||
192 | } | ||
193 | |||
194 | div#blob { | 172 | div#blob { |
195 | border: solid 1px black; | 173 | border: solid 1px black; |
196 | } | 174 | } |
197 | 175 | ||
198 | div.error { | 176 | div.error { |
199 | color: red; | 177 | color: red; |
200 | font-weight: bold; | 178 | font-weight: bold; |
201 | margin: 1em 2em; | 179 | margin: 1em 2em; |
202 | } | 180 | } |
203 | 181 | ||
204 | a.ls-blob, a.ls-dir, a.ls-mod { | 182 | a.ls-blob, a.ls-dir, a.ls-mod { |
205 | font-family: monospace; | 183 | font-family: monospace; |
206 | } | 184 | } |
207 | 185 | ||
208 | td.ls-size { | 186 | td.ls-size { |
209 | text-align: right; | 187 | text-align: right; |
210 | } | 188 | } |
211 | 189 | ||
212 | td.ls-size { | 190 | td.ls-size { |
213 | font-family: monospace; | 191 | font-family: monospace; |
214 | } | 192 | } |
215 | 193 | ||
216 | td.ls-mode { | 194 | td.ls-mode { |
217 | font-family: monospace; | 195 | font-family: monospace; |
218 | } | 196 | } |
219 | 197 | ||
220 | table.blob { | 198 | table.blob { |
221 | margin-top: 0.5em; | 199 | margin-top: 0.5em; |
222 | border-top: solid 1px black; | 200 | border-top: solid 1px black; |
223 | } | 201 | } |
224 | 202 | ||
225 | table.blob td.no { | 203 | table.blob td.no { |
226 | border-right: solid 1px black; | 204 | border-right: solid 1px black; |
227 | color: black; | 205 | color: black; |
228 | background-color: #eee; | 206 | background-color: #eee; |
229 | text-align: right; | 207 | text-align: right; |
230 | } | 208 | } |
231 | 209 | ||
232 | table.blob td.no a { | 210 | table.blob td.no a { |
233 | color: black; | 211 | color: black; |
234 | } | 212 | } |
235 | 213 | ||
236 | table.blob td.no a:hover { | 214 | table.blob td.no a:hover { |
237 | color: black; | 215 | color: black; |
238 | text-decoration: none; | 216 | text-decoration: none; |
239 | } | 217 | } |
240 | 218 | ||
241 | table.blob td.txt { | 219 | table.blob td.txt { |
242 | white-space: pre; | 220 | white-space: pre; |
243 | font-family: monospace; | 221 | font-family: monospace; |
244 | padding-left: 0.5em; | 222 | padding-left: 0.5em; |
245 | } | 223 | } |
246 | 224 | ||
247 | table.nowrap td { | 225 | table.nowrap td { |
248 | white-space: nowrap; | 226 | white-space: nowrap; |
249 | } | 227 | } |
250 | 228 | ||
251 | table.commit-info { | 229 | table.commit-info { |
252 | border-collapse: collapse; | 230 | border-collapse: collapse; |
253 | margin-top: 1.5em; | 231 | margin-top: 1.5em; |
254 | } | 232 | } |
255 | 233 | ||
256 | table.commit-info th { | 234 | table.commit-info th { |
257 | text-align: left; | 235 | text-align: left; |
258 | font-weight: normal; | 236 | font-weight: normal; |
259 | padding: 0.1em 1em 0.1em 0.1em; | 237 | padding: 0.1em 1em 0.1em 0.1em; |
260 | vertical-align: top; | 238 | vertical-align: top; |
261 | } | 239 | } |
262 | 240 | ||
263 | table.commit-info td { | 241 | table.commit-info td { |
264 | font-weight: normal; | 242 | font-weight: normal; |
265 | padding: 0.1em 1em 0.1em 0.1em; | 243 | padding: 0.1em 1em 0.1em 0.1em; |
266 | } | 244 | } |
267 | 245 | ||
268 | div.commit-subject { | 246 | div.commit-subject { |
269 | font-weight: bold; | 247 | font-weight: bold; |
270 | font-size: 125%; | 248 | font-size: 125%; |
271 | margin: 1.5em 0em 0.5em 0em; | 249 | margin: 1.5em 0em 0.5em 0em; |
272 | padding: 0em; | 250 | padding: 0em; |
273 | } | 251 | } |
274 | 252 | ||
275 | div.commit-msg { | 253 | div.commit-msg { |
276 | white-space: pre; | 254 | white-space: pre; |
277 | font-family: monospace; | 255 | font-family: monospace; |
278 | } | 256 | } |
279 | 257 | ||
280 | div.diffstat-header { | 258 | div.diffstat-header { |
281 | font-weight: bold; | 259 | font-weight: bold; |
282 | padding-top: 1.5em; | 260 | padding-top: 1.5em; |
283 | } | 261 | } |
284 | 262 | ||
285 | table.diffstat { | 263 | table.diffstat { |
286 | border-collapse: collapse; | 264 | border-collapse: collapse; |
287 | width: 100%; | ||
288 | border: solid 1px #aaa; | 265 | border: solid 1px #aaa; |
289 | background-color: #eee; | 266 | background-color: #eee; |
290 | } | 267 | } |
291 | 268 | ||
292 | table.diffstat th { | 269 | table.diffstat th { |
293 | font-weight: normal; | 270 | font-weight: normal; |
294 | text-align: left; | 271 | text-align: left; |
295 | text-decoration: underline; | 272 | text-decoration: underline; |
296 | padding: 0.1em 1em 0.1em 0.1em; | 273 | padding: 0.1em 1em 0.1em 0.1em; |
297 | font-size: 100%; | 274 | font-size: 100%; |
298 | } | 275 | } |
299 | 276 | ||
300 | table.diffstat td { | 277 | table.diffstat td { |
301 | padding: 0.2em 0.2em 0.1em 0.1em; | 278 | padding: 0.2em 0.2em 0.1em 0.1em; |
302 | font-size: 100%; | 279 | font-size: 100%; |
303 | border: none; | 280 | border: none; |
304 | } | 281 | } |
305 | 282 | ||
306 | table.diffstat td.mode { | 283 | table.diffstat td.mode { |
307 | white-space: nowrap; | 284 | white-space: nowrap; |
308 | } | 285 | } |
309 | 286 | ||
310 | table.diffstat td span.modechange { | 287 | table.diffstat td span.modechange { |
311 | padding-left: 1em; | 288 | padding-left: 1em; |
312 | color: red; | 289 | color: red; |
313 | } | 290 | } |
314 | 291 | ||
315 | table.diffstat td.add a { | 292 | table.diffstat td.add a { |
316 | color: green; | 293 | color: green; |
317 | } | 294 | } |
318 | 295 | ||
319 | table.diffstat td.del a { | 296 | table.diffstat td.del a { |
320 | color: red; | 297 | color: red; |
321 | } | 298 | } |
322 | 299 | ||
323 | table.diffstat td.upd a { | 300 | table.diffstat td.upd a { |
324 | color: blue; | 301 | color: blue; |
325 | } | 302 | } |
326 | 303 | ||
327 | table.diffstat td.graph { | 304 | table.diffstat td.graph { |
328 | width: 75%; | 305 | width: 500px; |
329 | vertical-align: middle; | 306 | vertical-align: middle; |
330 | } | 307 | } |
331 | 308 | ||
332 | table.diffstat td.graph table { | 309 | table.diffstat td.graph table { |
333 | border: none; | 310 | border: none; |
334 | } | 311 | } |
335 | 312 | ||
336 | table.diffstat td.graph td { | 313 | table.diffstat td.graph td { |
337 | padding: 0px; | 314 | padding: 0px; |
338 | border: 0px; | 315 | border: 0px; |
339 | height: 7pt; | 316 | height: 7pt; |
340 | } | 317 | } |
341 | 318 | ||
342 | table.diffstat td.graph td.add { | 319 | table.diffstat td.graph td.add { |
343 | background-color: #5c5; | 320 | background-color: #5c5; |
344 | } | 321 | } |
345 | 322 | ||
346 | table.diffstat td.graph td.rem { | 323 | table.diffstat td.graph td.rem { |
347 | background-color: #c55; | 324 | background-color: #c55; |
348 | } | 325 | } |
349 | 326 | ||
350 | div.diffstat-summary { | 327 | div.diffstat-summary { |
351 | color: #888; | 328 | color: #888; |
352 | padding-top: 0.5em; | 329 | padding-top: 0.5em; |
353 | } | 330 | } |
354 | 331 | ||
355 | table.diff { | 332 | table.diff { |
356 | width: 100%; | 333 | width: 100%; |
357 | } | 334 | } |
358 | 335 | ||
359 | table.diff td { | 336 | table.diff td { |
360 | font-family: monospace; | 337 | font-family: monospace; |
361 | white-space: pre; | 338 | white-space: pre; |
362 | } | 339 | } |
363 | 340 | ||
364 | table.diff td div.head { | 341 | table.diff td div.head { |
365 | font-weight: bold; | 342 | font-weight: bold; |
366 | margin-top: 1em; | 343 | margin-top: 1em; |
367 | background-color: #eee; | 344 | background-color: #eee; |
368 | } | 345 | } |
369 | 346 | ||
370 | table.diff td div.hunk { | 347 | table.diff td div.hunk { |
371 | color: #009; | 348 | color: #009; |
372 | } | 349 | } |
373 | 350 | ||
374 | table.diff td div.add { | 351 | table.diff td div.add { |
375 | color: green; | 352 | color: green; |
376 | } | 353 | } |
377 | 354 | ||
378 | table.diff td div.del { | 355 | table.diff td div.del { |
379 | color: red; | 356 | color: red; |
380 | } | 357 | } |
381 | 358 | ||
382 | .sha1 { | 359 | .sha1 { |
383 | font-family: monospace; | 360 | font-family: monospace; |
384 | font-size: 90%; | 361 | font-size: 90%; |
385 | } | 362 | } |
386 | 363 | ||
387 | .left { | 364 | .left { |
388 | text-align: left; | 365 | text-align: left; |
389 | } | 366 | } |
390 | 367 | ||
391 | .right { | 368 | .right { |
392 | text-align: right; | 369 | text-align: right; |
393 | } | 370 | } |
394 | 371 | ||
395 | table.list td.repogroup { | 372 | table.list td.repogroup { |
396 | font-style: italic; | 373 | font-style: italic; |
397 | color: #888; | 374 | color: #888; |
398 | } | 375 | } |
399 | 376 | ||
400 | a.button { | 377 | a.button { |
401 | font-size: 80%; | 378 | font-size: 80%; |
402 | color: #aaa; | 379 | color: #aaa; |
403 | background-color: #eee; | 380 | background-color: #eee; |
404 | border: solid 1px #aaa; | 381 | border: solid 1px #aaa; |
405 | padding: 0em 0.5em; | 382 | padding: 0em 0.5em; |
406 | margin: 0.1em 0.25em; | 383 | margin: 0.1em 0.25em; |
407 | } | 384 | } |
408 | 385 | ||
409 | a.button:hover { | 386 | a.button:hover { |
410 | text-decoration: none; | 387 | text-decoration: none; |
411 | color: #333; | 388 | color: #333; |
412 | background-color: #ccc; | 389 | background-color: #ccc; |
413 | } | 390 | } |
414 | 391 | ||
415 | a.primary { | 392 | a.primary { |
416 | font-size: 100%; | 393 | font-size: 100%; |
417 | } | 394 | } |
418 | 395 | ||
419 | a.secondary { | 396 | a.secondary { |
420 | font-size: 90%; | 397 | font-size: 90%; |
421 | } | 398 | } |
422 | 399 | ||
423 | td.toplevel-repo { | 400 | td.toplevel-repo { |
424 | 401 | ||
425 | } | 402 | } |
426 | 403 | ||
427 | table.list td.sublevel-repo { | 404 | table.list td.sublevel-repo { |
428 | padding-left: 1.5em; | 405 | padding-left: 1.5em; |
429 | } | 406 | } |
430 | 407 | ||
431 | span.age-mins { | 408 | span.age-mins { |
432 | font-weight: bold; | 409 | font-weight: bold; |
433 | color: #080; | 410 | color: #080; |
434 | } | 411 | } |
435 | 412 | ||
436 | span.age-hours { | 413 | span.age-hours { |
437 | color: #080; | 414 | color: #080; |
438 | } | 415 | } |
439 | 416 | ||
440 | span.age-days { | 417 | span.age-days { |
441 | color: #040; | 418 | color: #040; |
442 | } | 419 | } |
443 | 420 | ||
444 | span.age-weeks { | 421 | span.age-weeks { |
445 | color: #444; | 422 | color: #444; |
446 | } | 423 | } |
447 | 424 | ||
448 | span.age-months { | 425 | span.age-months { |
449 | color: #888; | 426 | color: #888; |
450 | } | 427 | } |
451 | 428 | ||
452 | span.age-years { | 429 | span.age-years { |
453 | color: #bbb; | 430 | color: #bbb; |
454 | } | 431 | } |
@@ -1,280 +1,282 @@ | |||
1 | #ifndef CGIT_H | 1 | #ifndef CGIT_H |
2 | #define CGIT_H | 2 | #define CGIT_H |
3 | 3 | ||
4 | 4 | ||
5 | #include <git-compat-util.h> | 5 | #include <git-compat-util.h> |
6 | #include <cache.h> | 6 | #include <cache.h> |
7 | #include <grep.h> | 7 | #include <grep.h> |
8 | #include <object.h> | 8 | #include <object.h> |
9 | #include <tree.h> | 9 | #include <tree.h> |
10 | #include <commit.h> | 10 | #include <commit.h> |
11 | #include <tag.h> | 11 | #include <tag.h> |
12 | #include <diff.h> | 12 | #include <diff.h> |
13 | #include <diffcore.h> | 13 | #include <diffcore.h> |
14 | #include <refs.h> | 14 | #include <refs.h> |
15 | #include <revision.h> | 15 | #include <revision.h> |
16 | #include <log-tree.h> | 16 | #include <log-tree.h> |
17 | #include <archive.h> | 17 | #include <archive.h> |
18 | #include <xdiff/xdiff.h> | 18 | #include <xdiff/xdiff.h> |
19 | 19 | ||
20 | 20 | ||
21 | /* | 21 | /* |
22 | * The valid cgit repo-commands | 22 | * The valid cgit repo-commands |
23 | */ | 23 | */ |
24 | #define CMD_LOG 1 | 24 | #define CMD_LOG 1 |
25 | #define CMD_COMMIT 2 | 25 | #define CMD_COMMIT 2 |
26 | #define CMD_DIFF 3 | 26 | #define CMD_DIFF 3 |
27 | #define CMD_TREE 4 | 27 | #define CMD_TREE 4 |
28 | #define CMD_BLOB 5 | 28 | #define CMD_BLOB 5 |
29 | #define CMD_SNAPSHOT 6 | 29 | #define CMD_SNAPSHOT 6 |
30 | #define CMD_TAG 7 | 30 | #define CMD_TAG 7 |
31 | #define CMD_REFS 8 | 31 | #define CMD_REFS 8 |
32 | 32 | ||
33 | /* | 33 | /* |
34 | * Dateformats used on misc. pages | 34 | * Dateformats used on misc. pages |
35 | */ | 35 | */ |
36 | #define FMT_LONGDATE "%Y-%m-%d %H:%M:%S" | 36 | #define FMT_LONGDATE "%Y-%m-%d %H:%M:%S" |
37 | #define FMT_SHORTDATE "%Y-%m-%d" | 37 | #define FMT_SHORTDATE "%Y-%m-%d" |
38 | 38 | ||
39 | 39 | ||
40 | /* | 40 | /* |
41 | * Limits used for relative dates | 41 | * Limits used for relative dates |
42 | */ | 42 | */ |
43 | #define TM_MIN 60 | 43 | #define TM_MIN 60 |
44 | #define TM_HOUR (TM_MIN * 60) | 44 | #define TM_HOUR (TM_MIN * 60) |
45 | #define TM_DAY (TM_HOUR * 24) | 45 | #define TM_DAY (TM_HOUR * 24) |
46 | #define TM_WEEK (TM_DAY * 7) | 46 | #define TM_WEEK (TM_DAY * 7) |
47 | #define TM_YEAR (TM_DAY * 365) | 47 | #define TM_YEAR (TM_DAY * 365) |
48 | #define TM_MONTH (TM_YEAR / 12.0) | 48 | #define TM_MONTH (TM_YEAR / 12.0) |
49 | 49 | ||
50 | 50 | ||
51 | typedef void (*configfn)(const char *name, const char *value); | 51 | typedef void (*configfn)(const char *name, const char *value); |
52 | typedef void (*filepair_fn)(struct diff_filepair *pair); | 52 | typedef void (*filepair_fn)(struct diff_filepair *pair); |
53 | typedef void (*linediff_fn)(char *line, int len); | 53 | typedef void (*linediff_fn)(char *line, int len); |
54 | 54 | ||
55 | struct cacheitem { | 55 | struct cacheitem { |
56 | char *name; | 56 | char *name; |
57 | struct stat st; | 57 | struct stat st; |
58 | int ttl; | 58 | int ttl; |
59 | int fd; | 59 | int fd; |
60 | }; | 60 | }; |
61 | 61 | ||
62 | struct repoinfo { | 62 | struct repoinfo { |
63 | char *url; | 63 | char *url; |
64 | char *name; | 64 | char *name; |
65 | char *path; | 65 | char *path; |
66 | char *desc; | 66 | char *desc; |
67 | char *owner; | 67 | char *owner; |
68 | char *defbranch; | 68 | char *defbranch; |
69 | char *group; | 69 | char *group; |
70 | char *module_link; | 70 | char *module_link; |
71 | char *readme; | 71 | char *readme; |
72 | int snapshots; | 72 | int snapshots; |
73 | int enable_log_filecount; | 73 | int enable_log_filecount; |
74 | int enable_log_linecount; | 74 | int enable_log_linecount; |
75 | }; | 75 | }; |
76 | 76 | ||
77 | struct repolist { | 77 | struct repolist { |
78 | int length; | 78 | int length; |
79 | int count; | 79 | int count; |
80 | struct repoinfo *repos; | 80 | struct repoinfo *repos; |
81 | }; | 81 | }; |
82 | 82 | ||
83 | struct commitinfo { | 83 | struct commitinfo { |
84 | struct commit *commit; | 84 | struct commit *commit; |
85 | char *author; | 85 | char *author; |
86 | char *author_email; | 86 | char *author_email; |
87 | unsigned long author_date; | 87 | unsigned long author_date; |
88 | char *committer; | 88 | char *committer; |
89 | char *committer_email; | 89 | char *committer_email; |
90 | unsigned long committer_date; | 90 | unsigned long committer_date; |
91 | char *subject; | 91 | char *subject; |
92 | char *msg; | 92 | char *msg; |
93 | }; | 93 | }; |
94 | 94 | ||
95 | struct taginfo { | 95 | struct taginfo { |
96 | char *tagger; | 96 | char *tagger; |
97 | char *tagger_email; | 97 | char *tagger_email; |
98 | int tagger_date; | 98 | int tagger_date; |
99 | char *msg; | 99 | char *msg; |
100 | }; | 100 | }; |
101 | 101 | ||
102 | struct refinfo { | 102 | struct refinfo { |
103 | const char *refname; | 103 | const char *refname; |
104 | struct object *object; | 104 | struct object *object; |
105 | union { | 105 | union { |
106 | struct taginfo *tag; | 106 | struct taginfo *tag; |
107 | struct commitinfo *commit; | 107 | struct commitinfo *commit; |
108 | }; | 108 | }; |
109 | }; | 109 | }; |
110 | 110 | ||
111 | struct reflist { | 111 | struct reflist { |
112 | struct refinfo **refs; | 112 | struct refinfo **refs; |
113 | int alloc; | 113 | int alloc; |
114 | int count; | 114 | int count; |
115 | }; | 115 | }; |
116 | 116 | ||
117 | extern const char *cgit_version; | 117 | extern const char *cgit_version; |
118 | 118 | ||
119 | extern struct repolist cgit_repolist; | 119 | extern struct repolist cgit_repolist; |
120 | extern struct repoinfo *cgit_repo; | 120 | extern struct repoinfo *cgit_repo; |
121 | extern int cgit_cmd; | 121 | extern int cgit_cmd; |
122 | 122 | ||
123 | extern char *cgit_root_title; | 123 | extern char *cgit_root_title; |
124 | extern char *cgit_css; | 124 | extern char *cgit_css; |
125 | extern char *cgit_logo; | 125 | extern char *cgit_logo; |
126 | extern char *cgit_index_header; | 126 | extern char *cgit_index_header; |
127 | extern char *cgit_index_info; | 127 | extern char *cgit_index_info; |
128 | extern char *cgit_logo_link; | 128 | extern char *cgit_logo_link; |
129 | extern char *cgit_module_link; | 129 | extern char *cgit_module_link; |
130 | extern char *cgit_agefile; | 130 | extern char *cgit_agefile; |
131 | extern char *cgit_virtual_root; | 131 | extern char *cgit_virtual_root; |
132 | extern char *cgit_script_name; | 132 | extern char *cgit_script_name; |
133 | extern char *cgit_cache_root; | 133 | extern char *cgit_cache_root; |
134 | extern char *cgit_repo_group; | 134 | extern char *cgit_repo_group; |
135 | 135 | ||
136 | extern int cgit_nocache; | 136 | extern int cgit_nocache; |
137 | extern int cgit_snapshots; | 137 | extern int cgit_snapshots; |
138 | extern int cgit_enable_index_links; | 138 | extern int cgit_enable_index_links; |
139 | extern int cgit_enable_log_filecount; | 139 | extern int cgit_enable_log_filecount; |
140 | extern int cgit_enable_log_linecount; | 140 | extern int cgit_enable_log_linecount; |
141 | extern int cgit_max_lock_attempts; | 141 | extern int cgit_max_lock_attempts; |
142 | extern int cgit_cache_root_ttl; | 142 | extern int cgit_cache_root_ttl; |
143 | extern int cgit_cache_repo_ttl; | 143 | extern int cgit_cache_repo_ttl; |
144 | extern int cgit_cache_dynamic_ttl; | 144 | extern int cgit_cache_dynamic_ttl; |
145 | extern int cgit_cache_static_ttl; | 145 | extern int cgit_cache_static_ttl; |
146 | extern int cgit_cache_max_create_time; | 146 | extern int cgit_cache_max_create_time; |
147 | extern int cgit_summary_log; | 147 | extern int cgit_summary_log; |
148 | extern int cgit_summary_tags; | 148 | extern int cgit_summary_tags; |
149 | extern int cgit_summary_branches; | 149 | extern int cgit_summary_branches; |
150 | 150 | ||
151 | extern int cgit_max_msg_len; | 151 | extern int cgit_max_msg_len; |
152 | extern int cgit_max_repodesc_len; | 152 | extern int cgit_max_repodesc_len; |
153 | extern int cgit_max_commit_count; | 153 | extern int cgit_max_commit_count; |
154 | 154 | ||
155 | extern int cgit_query_has_symref; | 155 | extern int cgit_query_has_symref; |
156 | extern int cgit_query_has_sha1; | 156 | extern int cgit_query_has_sha1; |
157 | 157 | ||
158 | extern char *cgit_querystring; | 158 | extern char *cgit_querystring; |
159 | extern char *cgit_query_repo; | 159 | extern char *cgit_query_repo; |
160 | extern char *cgit_query_page; | 160 | extern char *cgit_query_page; |
161 | extern char *cgit_query_search; | 161 | extern char *cgit_query_search; |
162 | extern char *cgit_query_grep; | 162 | extern char *cgit_query_grep; |
163 | extern char *cgit_query_head; | 163 | extern char *cgit_query_head; |
164 | extern char *cgit_query_sha1; | 164 | extern char *cgit_query_sha1; |
165 | extern char *cgit_query_sha2; | 165 | extern char *cgit_query_sha2; |
166 | extern char *cgit_query_path; | 166 | extern char *cgit_query_path; |
167 | extern char *cgit_query_name; | 167 | extern char *cgit_query_name; |
168 | extern int cgit_query_ofs; | 168 | extern int cgit_query_ofs; |
169 | 169 | ||
170 | extern int htmlfd; | 170 | extern int htmlfd; |
171 | 171 | ||
172 | extern int cgit_get_cmd_index(const char *cmd); | 172 | extern int cgit_get_cmd_index(const char *cmd); |
173 | extern struct repoinfo *cgit_get_repoinfo(const char *url); | 173 | extern struct repoinfo *cgit_get_repoinfo(const char *url); |
174 | extern void cgit_global_config_cb(const char *name, const char *value); | 174 | extern void cgit_global_config_cb(const char *name, const char *value); |
175 | extern void cgit_repo_config_cb(const char *name, const char *value); | 175 | extern void cgit_repo_config_cb(const char *name, const char *value); |
176 | extern void cgit_querystring_cb(const char *name, const char *value); | 176 | extern void cgit_querystring_cb(const char *name, const char *value); |
177 | 177 | ||
178 | extern int chk_zero(int result, char *msg); | 178 | extern int chk_zero(int result, char *msg); |
179 | extern int chk_positive(int result, char *msg); | 179 | extern int chk_positive(int result, char *msg); |
180 | extern int chk_non_negative(int result, char *msg); | 180 | extern int chk_non_negative(int result, char *msg); |
181 | 181 | ||
182 | extern int hextoint(char c); | 182 | extern int hextoint(char c); |
183 | extern char *trim_end(const char *str, char c); | 183 | extern char *trim_end(const char *str, char c); |
184 | extern char *strlpart(char *txt, int maxlen); | ||
185 | extern char *strrpart(char *txt, int maxlen); | ||
184 | 186 | ||
185 | extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); | 187 | extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); |
186 | extern int cgit_refs_cb(const char *refname, const unsigned char *sha1, | 188 | extern int cgit_refs_cb(const char *refname, const unsigned char *sha1, |
187 | int flags, void *cb_data); | 189 | int flags, void *cb_data); |
188 | 190 | ||
189 | extern void *cgit_free_commitinfo(struct commitinfo *info); | 191 | extern void *cgit_free_commitinfo(struct commitinfo *info); |
190 | 192 | ||
191 | extern int cgit_diff_files(const unsigned char *old_sha1, | 193 | extern int cgit_diff_files(const unsigned char *old_sha1, |
192 | const unsigned char *new_sha1, | 194 | const unsigned char *new_sha1, |
193 | linediff_fn fn); | 195 | linediff_fn fn); |
194 | 196 | ||
195 | extern void cgit_diff_tree(const unsigned char *old_sha1, | 197 | extern void cgit_diff_tree(const unsigned char *old_sha1, |
196 | const unsigned char *new_sha1, | 198 | const unsigned char *new_sha1, |
197 | filepair_fn fn, const char *prefix); | 199 | filepair_fn fn, const char *prefix); |
198 | 200 | ||
199 | extern void cgit_diff_commit(struct commit *commit, filepair_fn fn); | 201 | extern void cgit_diff_commit(struct commit *commit, filepair_fn fn); |
200 | 202 | ||
201 | extern char *fmt(const char *format,...); | 203 | extern char *fmt(const char *format,...); |
202 | 204 | ||
203 | extern void html(const char *txt); | 205 | extern void html(const char *txt); |
204 | extern void htmlf(const char *format,...); | 206 | extern void htmlf(const char *format,...); |
205 | extern void html_txt(char *txt); | 207 | extern void html_txt(char *txt); |
206 | extern void html_ntxt(int len, char *txt); | 208 | extern void html_ntxt(int len, char *txt); |
207 | extern void html_attr(char *txt); | 209 | extern void html_attr(char *txt); |
208 | extern void html_hidden(char *name, char *value); | 210 | extern void html_hidden(char *name, char *value); |
209 | extern void html_option(char *value, char *text, char *selected_value); | 211 | extern void html_option(char *value, char *text, char *selected_value); |
210 | extern void html_link_open(char *url, char *title, char *class); | 212 | extern void html_link_open(char *url, char *title, char *class); |
211 | extern void html_link_close(void); | 213 | extern void html_link_close(void); |
212 | extern void html_filemode(unsigned short mode); | 214 | extern void html_filemode(unsigned short mode); |
213 | extern int html_include(const char *filename); | 215 | extern int html_include(const char *filename); |
214 | 216 | ||
215 | extern int cgit_read_config(const char *filename, configfn fn); | 217 | extern int cgit_read_config(const char *filename, configfn fn); |
216 | extern int cgit_parse_query(char *txt, configfn fn); | 218 | extern int cgit_parse_query(char *txt, configfn fn); |
217 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); | 219 | extern struct commitinfo *cgit_parse_commit(struct commit *commit); |
218 | extern struct taginfo *cgit_parse_tag(struct tag *tag); | 220 | extern struct taginfo *cgit_parse_tag(struct tag *tag); |
219 | extern void cgit_parse_url(const char *url); | 221 | extern void cgit_parse_url(const char *url); |
220 | 222 | ||
221 | extern char *cache_safe_filename(const char *unsafe); | 223 | extern char *cache_safe_filename(const char *unsafe); |
222 | extern int cache_lock(struct cacheitem *item); | 224 | extern int cache_lock(struct cacheitem *item); |
223 | extern int cache_unlock(struct cacheitem *item); | 225 | extern int cache_unlock(struct cacheitem *item); |
224 | extern int cache_cancel_lock(struct cacheitem *item); | 226 | extern int cache_cancel_lock(struct cacheitem *item); |
225 | extern int cache_exist(struct cacheitem *item); | 227 | extern int cache_exist(struct cacheitem *item); |
226 | extern int cache_expired(struct cacheitem *item); | 228 | extern int cache_expired(struct cacheitem *item); |
227 | 229 | ||
228 | extern char *cgit_repourl(const char *reponame); | 230 | extern char *cgit_repourl(const char *reponame); |
229 | extern char *cgit_fileurl(const char *reponame, const char *pagename, | 231 | extern char *cgit_fileurl(const char *reponame, const char *pagename, |
230 | const char *filename, const char *query); | 232 | const char *filename, const char *query); |
231 | extern char *cgit_pageurl(const char *reponame, const char *pagename, | 233 | extern char *cgit_pageurl(const char *reponame, const char *pagename, |
232 | const char *query); | 234 | const char *query); |
233 | 235 | ||
234 | extern const char *cgit_repobasename(const char *reponame); | 236 | extern const char *cgit_repobasename(const char *reponame); |
235 | 237 | ||
236 | extern void cgit_tree_link(char *name, char *title, char *class, char *head, | 238 | extern void cgit_tree_link(char *name, char *title, char *class, char *head, |
237 | char *rev, char *path); | 239 | char *rev, char *path); |
238 | extern void cgit_log_link(char *name, char *title, char *class, char *head, | 240 | extern void cgit_log_link(char *name, char *title, char *class, char *head, |
239 | char *rev, char *path, int ofs); | 241 | char *rev, char *path, int ofs); |
240 | extern void cgit_commit_link(char *name, char *title, char *class, char *head, | 242 | extern void cgit_commit_link(char *name, char *title, char *class, char *head, |
241 | char *rev); | 243 | char *rev); |
242 | extern void cgit_refs_link(char *name, char *title, char *class, char *head, | 244 | extern void cgit_refs_link(char *name, char *title, char *class, char *head, |
243 | char *rev, char *path); | 245 | char *rev, char *path); |
244 | extern void cgit_snapshot_link(char *name, char *title, char *class, | 246 | extern void cgit_snapshot_link(char *name, char *title, char *class, |
245 | char *head, char *rev, char *archivename); | 247 | char *head, char *rev, char *archivename); |
246 | extern void cgit_diff_link(char *name, char *title, char *class, char *head, | 248 | extern void cgit_diff_link(char *name, char *title, char *class, char *head, |
247 | char *new_rev, char *old_rev, char *path); | 249 | char *new_rev, char *old_rev, char *path); |
248 | 250 | ||
249 | extern void cgit_object_link(struct object *obj); | 251 | extern void cgit_object_link(struct object *obj); |
250 | 252 | ||
251 | extern void cgit_print_error(char *msg); | 253 | extern void cgit_print_error(char *msg); |
252 | extern void cgit_print_date(time_t secs, char *format); | 254 | extern void cgit_print_date(time_t secs, char *format); |
253 | extern void cgit_print_age(time_t t, time_t max_relative, char *format); | 255 | extern void cgit_print_age(time_t t, time_t max_relative, char *format); |
254 | extern void cgit_print_docstart(char *title, struct cacheitem *item); | 256 | extern void cgit_print_docstart(char *title, struct cacheitem *item); |
255 | extern void cgit_print_docend(); | 257 | extern void cgit_print_docend(); |
256 | extern void cgit_print_pageheader(char *title, int show_search); | 258 | extern void cgit_print_pageheader(char *title, int show_search); |
257 | extern void cgit_print_snapshot_start(const char *mimetype, | 259 | extern void cgit_print_snapshot_start(const char *mimetype, |
258 | const char *filename, | 260 | const char *filename, |
259 | struct cacheitem *item); | 261 | struct cacheitem *item); |
260 | extern void cgit_print_branches(int maxcount); | 262 | extern void cgit_print_branches(int maxcount); |
261 | extern void cgit_print_tags(int maxcount); | 263 | extern void cgit_print_tags(int maxcount); |
262 | 264 | ||
263 | extern void cgit_print_repolist(struct cacheitem *item); | 265 | extern void cgit_print_repolist(struct cacheitem *item); |
264 | extern void cgit_print_summary(); | 266 | extern void cgit_print_summary(); |
265 | extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, | 267 | extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, |
266 | char *pattern, char *path, int pager); | 268 | char *pattern, char *path, int pager); |
267 | extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path); | 269 | extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path); |
268 | extern void cgit_print_tree(const char *rev, char *path); | 270 | extern void cgit_print_tree(const char *rev, char *path); |
269 | extern void cgit_print_commit(char *hex); | 271 | extern void cgit_print_commit(char *hex); |
270 | extern void cgit_print_refs(); | 272 | extern void cgit_print_refs(); |
271 | extern void cgit_print_tag(char *revname); | 273 | extern void cgit_print_tag(char *revname); |
272 | extern void cgit_print_diff(const char *new_hex, const char *old_hex, const char *prefix); | 274 | extern void cgit_print_diff(const char *new_hex, const char *old_hex, const char *prefix); |
273 | extern void cgit_print_snapshot(struct cacheitem *item, const char *head, | 275 | extern void cgit_print_snapshot(struct cacheitem *item, const char *head, |
274 | const char *hex, const char *prefix, | 276 | const char *hex, const char *prefix, |
275 | const char *filename, int snapshot); | 277 | const char *filename, int snapshot); |
276 | extern void cgit_print_snapshot_links(const char *repo, const char *head, | 278 | extern void cgit_print_snapshot_links(const char *repo, const char *head, |
277 | const char *hex, int snapshots); | 279 | const char *hex, int snapshots); |
278 | extern int cgit_parse_snapshots_mask(const char *str); | 280 | extern int cgit_parse_snapshots_mask(const char *str); |
279 | 281 | ||
280 | #endif /* CGIT_H */ | 282 | #endif /* CGIT_H */ |
diff --git a/cgit.png b/cgit.png new file mode 100644 index 0000000..ee48197 --- a/dev/null +++ b/cgit.png | |||
Binary files differ | |||
@@ -1,177 +1,182 @@ | |||
1 | ## | 1 | ## |
2 | ## cgitrc: template for /etc/cgitrc | 2 | ## cgitrc: template for /etc/cgitrc |
3 | ## | 3 | ## |
4 | 4 | ||
5 | 5 | ||
6 | ## Uncomment and set to 1 to deactivate caching of generated pages. Mostly | 6 | ## Uncomment and set to 1 to deactivate caching of generated pages. Mostly |
7 | ## usefull for testing. | 7 | ## usefull for testing. |
8 | #nocache=0 | 8 | #nocache=0 |
9 | 9 | ||
10 | 10 | ||
11 | ## Set allowed snapshot types by default. Can be overridden per repo | 11 | ## Set allowed snapshot types by default. Can be overridden per repo |
12 | # can be any combination of zip/tar.gz/tar.bz2/tar | 12 | # can be any combination of zip/tar.gz/tar.bz2/tar |
13 | #snapshots=0 | 13 | #snapshots=0 |
14 | 14 | ||
15 | 15 | ||
16 | ## Enable/disable extra links to summary/log/tree per repo on index page | 16 | ## Enable/disable extra links to summary/log/tree per repo on index page |
17 | #enable-index-links=0 | 17 | #enable-index-links=0 |
18 | 18 | ||
19 | 19 | ||
20 | ## Enable/disable display of 'number of files changed' in log view | 20 | ## Enable/disable display of 'number of files changed' in log view |
21 | #enable-log-filecount=0 | 21 | #enable-log-filecount=0 |
22 | 22 | ||
23 | 23 | ||
24 | ## Enable/disable display of 'number of lines changed' in log view | 24 | ## Enable/disable display of 'number of lines changed' in log view |
25 | #enable-log-linecount=0 | 25 | #enable-log-linecount=0 |
26 | 26 | ||
27 | 27 | ||
28 | ## Enable/disable display of HEAD shortlog in summary view. Set it to maximum | 28 | ## Enable/disable display of HEAD shortlog in summary view. Set it to maximum |
29 | ## number of commits that should be displayed | 29 | ## number of commits that should be displayed |
30 | #summary-log=0 | 30 | #summary-log=0 |
31 | 31 | ||
32 | 32 | ||
33 | ## Restrict the number of branches printed in summary view. Set to 0 to | 33 | ## Restrict the number of branches printed in summary view. Set to 0 to |
34 | ## print all branches. | 34 | ## print all branches. |
35 | #summary-branches=0 | 35 | #summary-branches=0 |
36 | 36 | ||
37 | 37 | ||
38 | ## Restrict the number of tags printed in summary view. Set to 0 to | 38 | ## Restrict the number of tags printed in summary view. Set to 0 to |
39 | ## print all tags. | 39 | ## print all tags. |
40 | #summary-tags=0 | 40 | #summary-tags=0 |
41 | 41 | ||
42 | 42 | ||
43 | ## The "Idle" column on the repository index page can read a timestamp | 43 | ## The "Idle" column on the repository index page can read a timestamp |
44 | ## from the specified agefile (if this file cannot be found, the mtime | 44 | ## from the specified agefile (if this file cannot be found, the mtime |
45 | ## of HEAD is used). | 45 | ## of HEAD is used). |
46 | ## The cgit repo on hjemli.net uses the the following command in it's | 46 | ## The cgit repo on hjemli.net uses the the following command in it's |
47 | ## post-receive hook to update the age-file: | 47 | ## post-receive hook to update the age-file: |
48 | ## git-for-each-ref --format="%(committerdate)" --sort=-committerdate \ | 48 | ## git-for-each-ref --format="%(committerdate)" --sort=-committerdate \ |
49 | ## --count=1 > $GIT_DIR/info/web/last-modifie | 49 | ## --count=1 > $GIT_DIR/info/web/last-modifie |
50 | ## | 50 | ## |
51 | #agefile=info/web/last-modified | 51 | #agefile=info/web/last-modified |
52 | 52 | ||
53 | 53 | ||
54 | ## Git detects renames, but with a limit on the number of files to | 54 | ## Git detects renames, but with a limit on the number of files to |
55 | ## consider. This option can be used to specify another limit (or -1 to | 55 | ## consider. This option can be used to specify another limit (or -1 to |
56 | ## use the default limit). | 56 | ## use the default limit). |
57 | ## | 57 | ## |
58 | #renamelimit=-1 | 58 | #renamelimit=-1 |
59 | 59 | ||
60 | 60 | ||
61 | ## Specify a root for virtual urls. This makes cgit generate urls like | 61 | ## Specify a root for virtual urls. This makes cgit generate urls like |
62 | ## | 62 | ## |
63 | ## http://localhost/git/repo/log/?h=branch | 63 | ## http://localhost/git/repo/log/?h=branch |
64 | ## | 64 | ## |
65 | ## instead of | 65 | ## instead of |
66 | ## | 66 | ## |
67 | ## http://localhost/cgit/cgit.cgi?url=repo/log&h=branch | 67 | ## http://localhost/cgit/cgit.cgi?url=repo/log&h=branch |
68 | ## | 68 | ## |
69 | ## For this to work with apache, a rewrite rule must be added to httpd.conf, | 69 | ## For this to work with apache, a rewrite rule must be added to httpd.conf, |
70 | ## possibly looking something like this: | 70 | ## possibly looking something like this: |
71 | ## | 71 | ## |
72 | ## RewriteRule ^/git/(.*)$ /cgit/cgit.cgi?url=$1 [L,QSA] | 72 | ## RewriteRule ^/git/(.*)$ /cgit/cgit.cgi?url=$1 [L,QSA] |
73 | ## | 73 | ## |
74 | ## For this to work with lighttpd, the rewrite rule should look more like this: | 74 | ## For this to work with lighttpd, the rewrite rule should look more like this: |
75 | ## | 75 | ## |
76 | ## url.rewrite = ( | 76 | ## url.rewrite = ( |
77 | ## "^/git/([^?/]+/[^?]*)?(?:\?(.*))?$" => "/cgit.cgi?url=$1&$2" | 77 | ## "^/git/([^?/]+/[^?]*)?(?:\?(.*))?$" => "/cgit.cgi?url=$1&$2" |
78 | ## ) | 78 | ## ) |
79 | ## | 79 | ## |
80 | ## This setting is disabled by default. | 80 | ## This setting is disabled by default. |
81 | #virtual-root=/git | 81 | #virtual-root=/git |
82 | 82 | ||
83 | 83 | ||
84 | ## Set the title printed on the root page | 84 | ## Set the title printed on the root page |
85 | #root-title=Git repository browser | 85 | #root-title=Git repository browser |
86 | 86 | ||
87 | 87 | ||
88 | ## If specified, the file at this path will be included as HTML in the index | 88 | ## If specified, the file at this path will be included as HTML in the |
89 | ## of repositories | 89 | ## sidebar on the repository index page |
90 | #index-info= | ||
91 | |||
92 | |||
93 | ## If specified, the file at this path will be included as HTML above | ||
94 | ## the repository index | ||
90 | #index-header= | 95 | #index-header= |
91 | 96 | ||
92 | 97 | ||
93 | ## Link to css file | 98 | ## Link to css file |
94 | #css=/cgit/cgit.css | 99 | #css=/cgit/cgit.css |
95 | 100 | ||
96 | 101 | ||
97 | ## Link to logo file | 102 | ## Link to logo file |
98 | #logo=/cgit/git-logo.png | 103 | #logo=/cgit/git-logo.png |
99 | 104 | ||
100 | 105 | ||
101 | ## Url loaded when clicking the logo | 106 | ## Url loaded when clicking the logo |
102 | #logo-link=http://www.kernel.org/pub/software/scm/git/docs/ | 107 | #logo-link=http://www.kernel.org/pub/software/scm/git/docs/ |
103 | 108 | ||
104 | 109 | ||
105 | ## Url loaded when clicking a submodule link | 110 | ## Url loaded when clicking a submodule link |
106 | #module-link=./?repo=%s&page=commit&id=%s | 111 | #module-link=./?repo=%s&page=commit&id=%s |
107 | 112 | ||
108 | 113 | ||
109 | ## Number of chars shown of repo description (in repolist view) | 114 | ## Number of chars shown of repo description (in repolist view) |
110 | #max-repodesc-length=60 | 115 | #max-repodesc-length=60 |
111 | 116 | ||
112 | 117 | ||
113 | ## Number of chars shown of commit subject message (in log view) | 118 | ## Number of chars shown of commit subject message (in log view) |
114 | #max-message-length=60 | 119 | #max-message-length=60 |
115 | 120 | ||
116 | 121 | ||
117 | ## Number of commits per page in log view | 122 | ## Number of commits per page in log view |
118 | #max-commit-count=50 | 123 | #max-commit-count=50 |
119 | 124 | ||
120 | 125 | ||
121 | ## Root of cached output | 126 | ## Root of cached output |
122 | #cache-root=/var/cache/cgit | 127 | #cache-root=/var/cache/cgit |
123 | 128 | ||
124 | 129 | ||
125 | ## Include another config-file | 130 | ## Include another config-file |
126 | #include=/var/cgit/repolist | 131 | #include=/var/cgit/repolist |
127 | 132 | ||
128 | ## | 133 | ## |
129 | ## Time-To-Live settings: specifies how long (in minutes) different pages | 134 | ## Time-To-Live settings: specifies how long (in minutes) different pages |
130 | ## should be cached (0 for instant expiration, -1 for immortal pages) | 135 | ## should be cached (0 for instant expiration, -1 for immortal pages) |
131 | ## | 136 | ## |
132 | 137 | ||
133 | ## ttl for root page | 138 | ## ttl for root page |
134 | #cache-root-ttl=5 | 139 | #cache-root-ttl=5 |
135 | 140 | ||
136 | ## ttl for repo summary page | 141 | ## ttl for repo summary page |
137 | #cache-repo-ttl=5 | 142 | #cache-repo-ttl=5 |
138 | 143 | ||
139 | ## ttl for other dynamic pages | 144 | ## ttl for other dynamic pages |
140 | #cache-dynamic-ttl=5 | 145 | #cache-dynamic-ttl=5 |
141 | 146 | ||
142 | ## ttl for static pages (addressed by SHA-1) | 147 | ## ttl for static pages (addressed by SHA-1) |
143 | #cache-static-ttl=-1 | 148 | #cache-static-ttl=-1 |
144 | 149 | ||
145 | 150 | ||
146 | 151 | ||
147 | ## Example repository entry. Required values are repo.url and repo.path (each | 152 | ## Example repository entry. Required values are repo.url and repo.path (each |
148 | ## repository section must start with repo.url). | 153 | ## repository section must start with repo.url). |
149 | #repo.url=cgit | 154 | #repo.url=cgit |
150 | #repo.name=cgit | 155 | #repo.name=cgit |
151 | #repo.desc=the caching cgi for git | 156 | #repo.desc=the caching cgi for git |
152 | #repo.path=/pub/git/cgit ## this is the path to $GIT_DIR | 157 | #repo.path=/pub/git/cgit ## this is the path to $GIT_DIR |
153 | #repo.owner=Lars Hjemli | 158 | #repo.owner=Lars Hjemli |
154 | #repo.defbranch=master ## define a default branch | 159 | #repo.defbranch=master ## define a default branch |
155 | #repo.snapshots=tar.bz2 ## override a sitewide snapshot-setting | 160 | #repo.snapshots=tar.bz2 ## override a sitewide snapshot-setting |
156 | #repo.enable-log-filecount=0 ## override the default filecount setting | 161 | #repo.enable-log-filecount=0 ## override the default filecount setting |
157 | #repo.enable-log-linecount=0 ## override the default linecount setting | 162 | #repo.enable-log-linecount=0 ## override the default linecount setting |
158 | #repo.module-link=/git/%s/commit/?id=%s ## override the standard module-link | 163 | #repo.module-link=/git/%s/commit/?id=%s ## override the standard module-link |
159 | #repo.readme=info/web/readme ## specify a file to include on summary page | 164 | #repo.readme=info/web/readme ## specify a file to include on summary page |
160 | 165 | ||
161 | ## Additional repositories grouped under "mirrors" | 166 | ## Additional repositories grouped under "mirrors" |
162 | #repo.group=mirrors | 167 | #repo.group=mirrors |
163 | 168 | ||
164 | #repo.url=git | 169 | #repo.url=git |
165 | #repo.path=/pub/git/git | 170 | #repo.path=/pub/git/git |
166 | # | 171 | # |
167 | #repo.url=linux | 172 | #repo.url=linux |
168 | #repo.path=/pub/git/linux | 173 | #repo.path=/pub/git/linux |
169 | 174 | ||
170 | ## A group of private repositories (with a working directory) | 175 | ## A group of private repositories (with a working directory) |
171 | #repo.group=private | 176 | #repo.group=private |
172 | 177 | ||
173 | #repo.url=larsh/cgit | 178 | #repo.url=larsh/cgit |
174 | #repo.path=/home/larsh/src/cgit/.git | 179 | #repo.path=/home/larsh/src/cgit/.git |
175 | 180 | ||
176 | #repo.url=larsh/git | 181 | #repo.url=larsh/git |
177 | #repo.path=/home/larsh/src/git/.git | 182 | #repo.path=/home/larsh/src/git/.git |
@@ -114,365 +114,396 @@ struct repoinfo *add_repo(const char *url) | |||
114 | 114 | ||
115 | ret = &cgit_repolist.repos[cgit_repolist.count-1]; | 115 | ret = &cgit_repolist.repos[cgit_repolist.count-1]; |
116 | ret->url = trim_end(url, '/'); | 116 | ret->url = trim_end(url, '/'); |
117 | ret->name = ret->url; | 117 | ret->name = ret->url; |
118 | ret->path = NULL; | 118 | ret->path = NULL; |
119 | ret->desc = NULL; | 119 | ret->desc = NULL; |
120 | ret->owner = NULL; | 120 | ret->owner = NULL; |
121 | ret->group = cgit_repo_group; | 121 | ret->group = cgit_repo_group; |
122 | ret->defbranch = "master"; | 122 | ret->defbranch = "master"; |
123 | ret->snapshots = cgit_snapshots; | 123 | ret->snapshots = cgit_snapshots; |
124 | ret->enable_log_filecount = cgit_enable_log_filecount; | 124 | ret->enable_log_filecount = cgit_enable_log_filecount; |
125 | ret->enable_log_linecount = cgit_enable_log_linecount; | 125 | ret->enable_log_linecount = cgit_enable_log_linecount; |
126 | ret->module_link = cgit_module_link; | 126 | ret->module_link = cgit_module_link; |
127 | ret->readme = NULL; | 127 | ret->readme = NULL; |
128 | return ret; | 128 | return ret; |
129 | } | 129 | } |
130 | 130 | ||
131 | struct repoinfo *cgit_get_repoinfo(const char *url) | 131 | struct repoinfo *cgit_get_repoinfo(const char *url) |
132 | { | 132 | { |
133 | int i; | 133 | int i; |
134 | struct repoinfo *repo; | 134 | struct repoinfo *repo; |
135 | 135 | ||
136 | for (i=0; i<cgit_repolist.count; i++) { | 136 | for (i=0; i<cgit_repolist.count; i++) { |
137 | repo = &cgit_repolist.repos[i]; | 137 | repo = &cgit_repolist.repos[i]; |
138 | if (!strcmp(repo->url, url)) | 138 | if (!strcmp(repo->url, url)) |
139 | return repo; | 139 | return repo; |
140 | } | 140 | } |
141 | return NULL; | 141 | return NULL; |
142 | } | 142 | } |
143 | 143 | ||
144 | void cgit_global_config_cb(const char *name, const char *value) | 144 | void cgit_global_config_cb(const char *name, const char *value) |
145 | { | 145 | { |
146 | if (!strcmp(name, "root-title")) | 146 | if (!strcmp(name, "root-title")) |
147 | cgit_root_title = xstrdup(value); | 147 | cgit_root_title = xstrdup(value); |
148 | else if (!strcmp(name, "css")) | 148 | else if (!strcmp(name, "css")) |
149 | cgit_css = xstrdup(value); | 149 | cgit_css = xstrdup(value); |
150 | else if (!strcmp(name, "logo")) | 150 | else if (!strcmp(name, "logo")) |
151 | cgit_logo = xstrdup(value); | 151 | cgit_logo = xstrdup(value); |
152 | else if (!strcmp(name, "index-header")) | 152 | else if (!strcmp(name, "index-header")) |
153 | cgit_index_header = xstrdup(value); | 153 | cgit_index_header = xstrdup(value); |
154 | else if (!strcmp(name, "index-info")) | 154 | else if (!strcmp(name, "index-info")) |
155 | cgit_index_info = xstrdup(value); | 155 | cgit_index_info = xstrdup(value); |
156 | else if (!strcmp(name, "logo-link")) | 156 | else if (!strcmp(name, "logo-link")) |
157 | cgit_logo_link = xstrdup(value); | 157 | cgit_logo_link = xstrdup(value); |
158 | else if (!strcmp(name, "module-link")) | 158 | else if (!strcmp(name, "module-link")) |
159 | cgit_module_link = xstrdup(value); | 159 | cgit_module_link = xstrdup(value); |
160 | else if (!strcmp(name, "virtual-root")) | 160 | else if (!strcmp(name, "virtual-root")) |
161 | cgit_virtual_root = trim_end(value, '/'); | 161 | cgit_virtual_root = trim_end(value, '/'); |
162 | else if (!strcmp(name, "nocache")) | 162 | else if (!strcmp(name, "nocache")) |
163 | cgit_nocache = atoi(value); | 163 | cgit_nocache = atoi(value); |
164 | else if (!strcmp(name, "snapshots")) | 164 | else if (!strcmp(name, "snapshots")) |
165 | cgit_snapshots = cgit_parse_snapshots_mask(value); | 165 | cgit_snapshots = cgit_parse_snapshots_mask(value); |
166 | else if (!strcmp(name, "enable-index-links")) | 166 | else if (!strcmp(name, "enable-index-links")) |
167 | cgit_enable_index_links = atoi(value); | 167 | cgit_enable_index_links = atoi(value); |
168 | else if (!strcmp(name, "enable-log-filecount")) | 168 | else if (!strcmp(name, "enable-log-filecount")) |
169 | cgit_enable_log_filecount = atoi(value); | 169 | cgit_enable_log_filecount = atoi(value); |
170 | else if (!strcmp(name, "enable-log-linecount")) | 170 | else if (!strcmp(name, "enable-log-linecount")) |
171 | cgit_enable_log_linecount = atoi(value); | 171 | cgit_enable_log_linecount = atoi(value); |
172 | else if (!strcmp(name, "cache-root")) | 172 | else if (!strcmp(name, "cache-root")) |
173 | cgit_cache_root = xstrdup(value); | 173 | cgit_cache_root = xstrdup(value); |
174 | else if (!strcmp(name, "cache-root-ttl")) | 174 | else if (!strcmp(name, "cache-root-ttl")) |
175 | cgit_cache_root_ttl = atoi(value); | 175 | cgit_cache_root_ttl = atoi(value); |
176 | else if (!strcmp(name, "cache-repo-ttl")) | 176 | else if (!strcmp(name, "cache-repo-ttl")) |
177 | cgit_cache_repo_ttl = atoi(value); | 177 | cgit_cache_repo_ttl = atoi(value); |
178 | else if (!strcmp(name, "cache-static-ttl")) | 178 | else if (!strcmp(name, "cache-static-ttl")) |
179 | cgit_cache_static_ttl = atoi(value); | 179 | cgit_cache_static_ttl = atoi(value); |
180 | else if (!strcmp(name, "cache-dynamic-ttl")) | 180 | else if (!strcmp(name, "cache-dynamic-ttl")) |
181 | cgit_cache_dynamic_ttl = atoi(value); | 181 | cgit_cache_dynamic_ttl = atoi(value); |
182 | else if (!strcmp(name, "max-message-length")) | 182 | else if (!strcmp(name, "max-message-length")) |
183 | cgit_max_msg_len = atoi(value); | 183 | cgit_max_msg_len = atoi(value); |
184 | else if (!strcmp(name, "max-repodesc-length")) | 184 | else if (!strcmp(name, "max-repodesc-length")) |
185 | cgit_max_repodesc_len = atoi(value); | 185 | cgit_max_repodesc_len = atoi(value); |
186 | else if (!strcmp(name, "max-commit-count")) | 186 | else if (!strcmp(name, "max-commit-count")) |
187 | cgit_max_commit_count = atoi(value); | 187 | cgit_max_commit_count = atoi(value); |
188 | else if (!strcmp(name, "summary-log")) | 188 | else if (!strcmp(name, "summary-log")) |
189 | cgit_summary_log = atoi(value); | 189 | cgit_summary_log = atoi(value); |
190 | else if (!strcmp(name, "summary-branches")) | 190 | else if (!strcmp(name, "summary-branches")) |
191 | cgit_summary_branches = atoi(value); | 191 | cgit_summary_branches = atoi(value); |
192 | else if (!strcmp(name, "summary-tags")) | 192 | else if (!strcmp(name, "summary-tags")) |
193 | cgit_summary_tags = atoi(value); | 193 | cgit_summary_tags = atoi(value); |
194 | else if (!strcmp(name, "agefile")) | 194 | else if (!strcmp(name, "agefile")) |
195 | cgit_agefile = xstrdup(value); | 195 | cgit_agefile = xstrdup(value); |
196 | else if (!strcmp(name, "renamelimit")) | 196 | else if (!strcmp(name, "renamelimit")) |
197 | cgit_renamelimit = atoi(value); | 197 | cgit_renamelimit = atoi(value); |
198 | else if (!strcmp(name, "repo.group")) | 198 | else if (!strcmp(name, "repo.group")) |
199 | cgit_repo_group = xstrdup(value); | 199 | cgit_repo_group = xstrdup(value); |
200 | else if (!strcmp(name, "repo.url")) | 200 | else if (!strcmp(name, "repo.url")) |
201 | cgit_repo = add_repo(value); | 201 | cgit_repo = add_repo(value); |
202 | else if (!strcmp(name, "repo.name")) | 202 | else if (!strcmp(name, "repo.name")) |
203 | cgit_repo->name = xstrdup(value); | 203 | cgit_repo->name = xstrdup(value); |
204 | else if (cgit_repo && !strcmp(name, "repo.path")) | 204 | else if (cgit_repo && !strcmp(name, "repo.path")) |
205 | cgit_repo->path = trim_end(value, '/'); | 205 | cgit_repo->path = trim_end(value, '/'); |
206 | else if (cgit_repo && !strcmp(name, "repo.desc")) | 206 | else if (cgit_repo && !strcmp(name, "repo.desc")) |
207 | cgit_repo->desc = xstrdup(value); | 207 | cgit_repo->desc = xstrdup(value); |
208 | else if (cgit_repo && !strcmp(name, "repo.owner")) | 208 | else if (cgit_repo && !strcmp(name, "repo.owner")) |
209 | cgit_repo->owner = xstrdup(value); | 209 | cgit_repo->owner = xstrdup(value); |
210 | else if (cgit_repo && !strcmp(name, "repo.defbranch")) | 210 | else if (cgit_repo && !strcmp(name, "repo.defbranch")) |
211 | cgit_repo->defbranch = xstrdup(value); | 211 | cgit_repo->defbranch = xstrdup(value); |
212 | else if (cgit_repo && !strcmp(name, "repo.snapshots")) | 212 | else if (cgit_repo && !strcmp(name, "repo.snapshots")) |
213 | cgit_repo->snapshots = cgit_snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */ | 213 | cgit_repo->snapshots = cgit_snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */ |
214 | else if (cgit_repo && !strcmp(name, "repo.enable-log-filecount")) | 214 | else if (cgit_repo && !strcmp(name, "repo.enable-log-filecount")) |
215 | cgit_repo->enable_log_filecount = cgit_enable_log_filecount * atoi(value); | 215 | cgit_repo->enable_log_filecount = cgit_enable_log_filecount * atoi(value); |
216 | else if (cgit_repo && !strcmp(name, "repo.enable-log-linecount")) | 216 | else if (cgit_repo && !strcmp(name, "repo.enable-log-linecount")) |
217 | cgit_repo->enable_log_linecount = cgit_enable_log_linecount * atoi(value); | 217 | cgit_repo->enable_log_linecount = cgit_enable_log_linecount * atoi(value); |
218 | else if (cgit_repo && !strcmp(name, "repo.module-link")) | 218 | else if (cgit_repo && !strcmp(name, "repo.module-link")) |
219 | cgit_repo->module_link= xstrdup(value); | 219 | cgit_repo->module_link= xstrdup(value); |
220 | else if (cgit_repo && !strcmp(name, "repo.readme") && value != NULL) { | 220 | else if (cgit_repo && !strcmp(name, "repo.readme") && value != NULL) { |
221 | if (*value == '/') | 221 | if (*value == '/') |
222 | cgit_repo->readme = xstrdup(value); | 222 | cgit_repo->readme = xstrdup(value); |
223 | else | 223 | else |
224 | cgit_repo->readme = xstrdup(fmt("%s/%s", cgit_repo->path, value)); | 224 | cgit_repo->readme = xstrdup(fmt("%s/%s", cgit_repo->path, value)); |
225 | } else if (!strcmp(name, "include")) | 225 | } else if (!strcmp(name, "include")) |
226 | cgit_read_config(value, cgit_global_config_cb); | 226 | cgit_read_config(value, cgit_global_config_cb); |
227 | } | 227 | } |
228 | 228 | ||
229 | void cgit_querystring_cb(const char *name, const char *value) | 229 | void cgit_querystring_cb(const char *name, const char *value) |
230 | { | 230 | { |
231 | if (!strcmp(name,"r")) { | 231 | if (!strcmp(name,"r")) { |
232 | cgit_query_repo = xstrdup(value); | 232 | cgit_query_repo = xstrdup(value); |
233 | cgit_repo = cgit_get_repoinfo(value); | 233 | cgit_repo = cgit_get_repoinfo(value); |
234 | } else if (!strcmp(name, "p")) { | 234 | } else if (!strcmp(name, "p")) { |
235 | cgit_query_page = xstrdup(value); | 235 | cgit_query_page = xstrdup(value); |
236 | cgit_cmd = cgit_get_cmd_index(value); | 236 | cgit_cmd = cgit_get_cmd_index(value); |
237 | } else if (!strcmp(name, "url")) { | 237 | } else if (!strcmp(name, "url")) { |
238 | cgit_parse_url(value); | 238 | cgit_parse_url(value); |
239 | } else if (!strcmp(name, "qt")) { | 239 | } else if (!strcmp(name, "qt")) { |
240 | cgit_query_grep = xstrdup(value); | 240 | cgit_query_grep = xstrdup(value); |
241 | } else if (!strcmp(name, "q")) { | 241 | } else if (!strcmp(name, "q")) { |
242 | cgit_query_search = xstrdup(value); | 242 | cgit_query_search = xstrdup(value); |
243 | } else if (!strcmp(name, "h")) { | 243 | } else if (!strcmp(name, "h")) { |
244 | cgit_query_head = xstrdup(value); | 244 | cgit_query_head = xstrdup(value); |
245 | cgit_query_has_symref = 1; | 245 | cgit_query_has_symref = 1; |
246 | } else if (!strcmp(name, "id")) { | 246 | } else if (!strcmp(name, "id")) { |
247 | cgit_query_sha1 = xstrdup(value); | 247 | cgit_query_sha1 = xstrdup(value); |
248 | cgit_query_has_sha1 = 1; | 248 | cgit_query_has_sha1 = 1; |
249 | } else if (!strcmp(name, "id2")) { | 249 | } else if (!strcmp(name, "id2")) { |
250 | cgit_query_sha2 = xstrdup(value); | 250 | cgit_query_sha2 = xstrdup(value); |
251 | cgit_query_has_sha1 = 1; | 251 | cgit_query_has_sha1 = 1; |
252 | } else if (!strcmp(name, "ofs")) { | 252 | } else if (!strcmp(name, "ofs")) { |
253 | cgit_query_ofs = atoi(value); | 253 | cgit_query_ofs = atoi(value); |
254 | } else if (!strcmp(name, "path")) { | 254 | } else if (!strcmp(name, "path")) { |
255 | cgit_query_path = trim_end(value, '/'); | 255 | cgit_query_path = trim_end(value, '/'); |
256 | } else if (!strcmp(name, "name")) { | 256 | } else if (!strcmp(name, "name")) { |
257 | cgit_query_name = xstrdup(value); | 257 | cgit_query_name = xstrdup(value); |
258 | } | 258 | } |
259 | } | 259 | } |
260 | 260 | ||
261 | void *cgit_free_commitinfo(struct commitinfo *info) | 261 | void *cgit_free_commitinfo(struct commitinfo *info) |
262 | { | 262 | { |
263 | free(info->author); | 263 | free(info->author); |
264 | free(info->author_email); | 264 | free(info->author_email); |
265 | free(info->committer); | 265 | free(info->committer); |
266 | free(info->committer_email); | 266 | free(info->committer_email); |
267 | free(info->subject); | 267 | free(info->subject); |
268 | free(info); | 268 | free(info); |
269 | return NULL; | 269 | return NULL; |
270 | } | 270 | } |
271 | 271 | ||
272 | int hextoint(char c) | 272 | int hextoint(char c) |
273 | { | 273 | { |
274 | if (c >= 'a' && c <= 'f') | 274 | if (c >= 'a' && c <= 'f') |
275 | return 10 + c - 'a'; | 275 | return 10 + c - 'a'; |
276 | else if (c >= 'A' && c <= 'F') | 276 | else if (c >= 'A' && c <= 'F') |
277 | return 10 + c - 'A'; | 277 | return 10 + c - 'A'; |
278 | else if (c >= '0' && c <= '9') | 278 | else if (c >= '0' && c <= '9') |
279 | return c - '0'; | 279 | return c - '0'; |
280 | else | 280 | else |
281 | return -1; | 281 | return -1; |
282 | } | 282 | } |
283 | 283 | ||
284 | char *trim_end(const char *str, char c) | 284 | char *trim_end(const char *str, char c) |
285 | { | 285 | { |
286 | int len; | 286 | int len; |
287 | char *s, *t; | 287 | char *s, *t; |
288 | 288 | ||
289 | if (str == NULL) | 289 | if (str == NULL) |
290 | return NULL; | 290 | return NULL; |
291 | t = (char *)str; | 291 | t = (char *)str; |
292 | len = strlen(t); | 292 | len = strlen(t); |
293 | while(len > 0 && t[len - 1] == c) | 293 | while(len > 0 && t[len - 1] == c) |
294 | len--; | 294 | len--; |
295 | 295 | ||
296 | if (len == 0) | 296 | if (len == 0) |
297 | return NULL; | 297 | return NULL; |
298 | 298 | ||
299 | c = t[len]; | 299 | c = t[len]; |
300 | t[len] = '\0'; | 300 | t[len] = '\0'; |
301 | s = xstrdup(t); | 301 | s = xstrdup(t); |
302 | t[len] = c; | 302 | t[len] = c; |
303 | return s; | 303 | return s; |
304 | } | 304 | } |
305 | 305 | ||
306 | char *strlpart(char *txt, int maxlen) | ||
307 | { | ||
308 | char *result; | ||
309 | |||
310 | if (!txt) | ||
311 | return txt; | ||
312 | |||
313 | if (strlen(txt) <= maxlen) | ||
314 | return txt; | ||
315 | result = xmalloc(maxlen + 1); | ||
316 | memcpy(result, txt, maxlen - 3); | ||
317 | result[maxlen-1] = result[maxlen-2] = result[maxlen-3] = '.'; | ||
318 | result[maxlen] = '\0'; | ||
319 | return result; | ||
320 | } | ||
321 | |||
322 | char *strrpart(char *txt, int maxlen) | ||
323 | { | ||
324 | char *result; | ||
325 | |||
326 | if (!txt) | ||
327 | return txt; | ||
328 | |||
329 | if (strlen(txt) <= maxlen) | ||
330 | return txt; | ||
331 | result = xmalloc(maxlen + 1); | ||
332 | memcpy(result + 3, txt + strlen(txt) - maxlen + 4, maxlen - 3); | ||
333 | result[0] = result[1] = result[2] = '.'; | ||
334 | return result; | ||
335 | } | ||
336 | |||
306 | void cgit_add_ref(struct reflist *list, struct refinfo *ref) | 337 | void cgit_add_ref(struct reflist *list, struct refinfo *ref) |
307 | { | 338 | { |
308 | size_t size; | 339 | size_t size; |
309 | 340 | ||
310 | if (list->count >= list->alloc) { | 341 | if (list->count >= list->alloc) { |
311 | list->alloc += (list->alloc ? list->alloc : 4); | 342 | list->alloc += (list->alloc ? list->alloc : 4); |
312 | size = list->alloc * sizeof(struct refinfo *); | 343 | size = list->alloc * sizeof(struct refinfo *); |
313 | list->refs = xrealloc(list->refs, size); | 344 | list->refs = xrealloc(list->refs, size); |
314 | } | 345 | } |
315 | list->refs[list->count++] = ref; | 346 | list->refs[list->count++] = ref; |
316 | } | 347 | } |
317 | 348 | ||
318 | struct refinfo *cgit_mk_refinfo(const char *refname, const unsigned char *sha1) | 349 | struct refinfo *cgit_mk_refinfo(const char *refname, const unsigned char *sha1) |
319 | { | 350 | { |
320 | struct refinfo *ref; | 351 | struct refinfo *ref; |
321 | 352 | ||
322 | ref = xmalloc(sizeof (struct refinfo)); | 353 | ref = xmalloc(sizeof (struct refinfo)); |
323 | ref->refname = xstrdup(refname); | 354 | ref->refname = xstrdup(refname); |
324 | ref->object = parse_object(sha1); | 355 | ref->object = parse_object(sha1); |
325 | switch (ref->object->type) { | 356 | switch (ref->object->type) { |
326 | case OBJ_TAG: | 357 | case OBJ_TAG: |
327 | ref->tag = cgit_parse_tag((struct tag *)ref->object); | 358 | ref->tag = cgit_parse_tag((struct tag *)ref->object); |
328 | break; | 359 | break; |
329 | case OBJ_COMMIT: | 360 | case OBJ_COMMIT: |
330 | ref->commit = cgit_parse_commit((struct commit *)ref->object); | 361 | ref->commit = cgit_parse_commit((struct commit *)ref->object); |
331 | break; | 362 | break; |
332 | } | 363 | } |
333 | return ref; | 364 | return ref; |
334 | } | 365 | } |
335 | 366 | ||
336 | int cgit_refs_cb(const char *refname, const unsigned char *sha1, int flags, | 367 | int cgit_refs_cb(const char *refname, const unsigned char *sha1, int flags, |
337 | void *cb_data) | 368 | void *cb_data) |
338 | { | 369 | { |
339 | struct reflist *list = (struct reflist *)cb_data; | 370 | struct reflist *list = (struct reflist *)cb_data; |
340 | struct refinfo *info = cgit_mk_refinfo(refname, sha1); | 371 | struct refinfo *info = cgit_mk_refinfo(refname, sha1); |
341 | 372 | ||
342 | if (info) | 373 | if (info) |
343 | cgit_add_ref(list, info); | 374 | cgit_add_ref(list, info); |
344 | return 0; | 375 | return 0; |
345 | } | 376 | } |
346 | 377 | ||
347 | void cgit_diff_tree_cb(struct diff_queue_struct *q, | 378 | void cgit_diff_tree_cb(struct diff_queue_struct *q, |
348 | struct diff_options *options, void *data) | 379 | struct diff_options *options, void *data) |
349 | { | 380 | { |
350 | int i; | 381 | int i; |
351 | 382 | ||
352 | for (i = 0; i < q->nr; i++) { | 383 | for (i = 0; i < q->nr; i++) { |
353 | if (q->queue[i]->status == 'U') | 384 | if (q->queue[i]->status == 'U') |
354 | continue; | 385 | continue; |
355 | ((filepair_fn)data)(q->queue[i]); | 386 | ((filepair_fn)data)(q->queue[i]); |
356 | } | 387 | } |
357 | } | 388 | } |
358 | 389 | ||
359 | static int load_mmfile(mmfile_t *file, const unsigned char *sha1) | 390 | static int load_mmfile(mmfile_t *file, const unsigned char *sha1) |
360 | { | 391 | { |
361 | enum object_type type; | 392 | enum object_type type; |
362 | 393 | ||
363 | if (is_null_sha1(sha1)) { | 394 | if (is_null_sha1(sha1)) { |
364 | file->ptr = (char *)""; | 395 | file->ptr = (char *)""; |
365 | file->size = 0; | 396 | file->size = 0; |
366 | } else { | 397 | } else { |
367 | file->ptr = read_sha1_file(sha1, &type, | 398 | file->ptr = read_sha1_file(sha1, &type, |
368 | (unsigned long *)&file->size); | 399 | (unsigned long *)&file->size); |
369 | } | 400 | } |
370 | return 1; | 401 | return 1; |
371 | } | 402 | } |
372 | 403 | ||
373 | /* | 404 | /* |
374 | * Receive diff-buffers from xdiff and concatenate them as | 405 | * Receive diff-buffers from xdiff and concatenate them as |
375 | * needed across multiple callbacks. | 406 | * needed across multiple callbacks. |
376 | * | 407 | * |
377 | * This is basically a copy of xdiff-interface.c/xdiff_outf(), | 408 | * This is basically a copy of xdiff-interface.c/xdiff_outf(), |
378 | * ripped from git and modified to use globals instead of | 409 | * ripped from git and modified to use globals instead of |
379 | * a special callback-struct. | 410 | * a special callback-struct. |
380 | */ | 411 | */ |
381 | char *diffbuf = NULL; | 412 | char *diffbuf = NULL; |
382 | int buflen = 0; | 413 | int buflen = 0; |
383 | 414 | ||
384 | int filediff_cb(void *priv, mmbuffer_t *mb, int nbuf) | 415 | int filediff_cb(void *priv, mmbuffer_t *mb, int nbuf) |
385 | { | 416 | { |
386 | int i; | 417 | int i; |
387 | 418 | ||
388 | for (i = 0; i < nbuf; i++) { | 419 | for (i = 0; i < nbuf; i++) { |
389 | if (mb[i].ptr[mb[i].size-1] != '\n') { | 420 | if (mb[i].ptr[mb[i].size-1] != '\n') { |
390 | /* Incomplete line */ | 421 | /* Incomplete line */ |
391 | diffbuf = xrealloc(diffbuf, buflen + mb[i].size); | 422 | diffbuf = xrealloc(diffbuf, buflen + mb[i].size); |
392 | memcpy(diffbuf + buflen, mb[i].ptr, mb[i].size); | 423 | memcpy(diffbuf + buflen, mb[i].ptr, mb[i].size); |
393 | buflen += mb[i].size; | 424 | buflen += mb[i].size; |
394 | continue; | 425 | continue; |
395 | } | 426 | } |
396 | 427 | ||
397 | /* we have a complete line */ | 428 | /* we have a complete line */ |
398 | if (!diffbuf) { | 429 | if (!diffbuf) { |
399 | ((linediff_fn)priv)(mb[i].ptr, mb[i].size); | 430 | ((linediff_fn)priv)(mb[i].ptr, mb[i].size); |
400 | continue; | 431 | continue; |
401 | } | 432 | } |
402 | diffbuf = xrealloc(diffbuf, buflen + mb[i].size); | 433 | diffbuf = xrealloc(diffbuf, buflen + mb[i].size); |
403 | memcpy(diffbuf + buflen, mb[i].ptr, mb[i].size); | 434 | memcpy(diffbuf + buflen, mb[i].ptr, mb[i].size); |
404 | ((linediff_fn)priv)(diffbuf, buflen + mb[i].size); | 435 | ((linediff_fn)priv)(diffbuf, buflen + mb[i].size); |
405 | free(diffbuf); | 436 | free(diffbuf); |
406 | diffbuf = NULL; | 437 | diffbuf = NULL; |
407 | buflen = 0; | 438 | buflen = 0; |
408 | } | 439 | } |
409 | if (diffbuf) { | 440 | if (diffbuf) { |
410 | ((linediff_fn)priv)(diffbuf, buflen); | 441 | ((linediff_fn)priv)(diffbuf, buflen); |
411 | free(diffbuf); | 442 | free(diffbuf); |
412 | diffbuf = NULL; | 443 | diffbuf = NULL; |
413 | buflen = 0; | 444 | buflen = 0; |
414 | } | 445 | } |
415 | return 0; | 446 | return 0; |
416 | } | 447 | } |
417 | 448 | ||
418 | int cgit_diff_files(const unsigned char *old_sha1, | 449 | int cgit_diff_files(const unsigned char *old_sha1, |
419 | const unsigned char *new_sha1, | 450 | const unsigned char *new_sha1, |
420 | linediff_fn fn) | 451 | linediff_fn fn) |
421 | { | 452 | { |
422 | mmfile_t file1, file2; | 453 | mmfile_t file1, file2; |
423 | xpparam_t diff_params; | 454 | xpparam_t diff_params; |
424 | xdemitconf_t emit_params; | 455 | xdemitconf_t emit_params; |
425 | xdemitcb_t emit_cb; | 456 | xdemitcb_t emit_cb; |
426 | 457 | ||
427 | if (!load_mmfile(&file1, old_sha1) || !load_mmfile(&file2, new_sha1)) | 458 | if (!load_mmfile(&file1, old_sha1) || !load_mmfile(&file2, new_sha1)) |
428 | return 1; | 459 | return 1; |
429 | 460 | ||
430 | diff_params.flags = XDF_NEED_MINIMAL; | 461 | diff_params.flags = XDF_NEED_MINIMAL; |
431 | emit_params.ctxlen = 3; | 462 | emit_params.ctxlen = 3; |
432 | emit_params.flags = XDL_EMIT_FUNCNAMES; | 463 | emit_params.flags = XDL_EMIT_FUNCNAMES; |
433 | emit_params.find_func = NULL; | 464 | emit_params.find_func = NULL; |
434 | emit_cb.outf = filediff_cb; | 465 | emit_cb.outf = filediff_cb; |
435 | emit_cb.priv = fn; | 466 | emit_cb.priv = fn; |
436 | xdl_diff(&file1, &file2, &diff_params, &emit_params, &emit_cb); | 467 | xdl_diff(&file1, &file2, &diff_params, &emit_params, &emit_cb); |
437 | return 0; | 468 | return 0; |
438 | } | 469 | } |
439 | 470 | ||
440 | void cgit_diff_tree(const unsigned char *old_sha1, | 471 | void cgit_diff_tree(const unsigned char *old_sha1, |
441 | const unsigned char *new_sha1, | 472 | const unsigned char *new_sha1, |
442 | filepair_fn fn, const char *prefix) | 473 | filepair_fn fn, const char *prefix) |
443 | { | 474 | { |
444 | struct diff_options opt; | 475 | struct diff_options opt; |
445 | int ret; | 476 | int ret; |
446 | int prefixlen; | 477 | int prefixlen; |
447 | 478 | ||
448 | diff_setup(&opt); | 479 | diff_setup(&opt); |
449 | opt.output_format = DIFF_FORMAT_CALLBACK; | 480 | opt.output_format = DIFF_FORMAT_CALLBACK; |
450 | opt.detect_rename = 1; | 481 | opt.detect_rename = 1; |
451 | opt.rename_limit = cgit_renamelimit; | 482 | opt.rename_limit = cgit_renamelimit; |
452 | opt.recursive = 1; | 483 | opt.recursive = 1; |
453 | opt.format_callback = cgit_diff_tree_cb; | 484 | opt.format_callback = cgit_diff_tree_cb; |
454 | opt.format_callback_data = fn; | 485 | opt.format_callback_data = fn; |
455 | if (prefix) { | 486 | if (prefix) { |
456 | opt.nr_paths = 1; | 487 | opt.nr_paths = 1; |
457 | opt.paths = &prefix; | 488 | opt.paths = &prefix; |
458 | prefixlen = strlen(prefix); | 489 | prefixlen = strlen(prefix); |
459 | opt.pathlens = &prefixlen; | 490 | opt.pathlens = &prefixlen; |
460 | } | 491 | } |
461 | diff_setup_done(&opt); | 492 | diff_setup_done(&opt); |
462 | 493 | ||
463 | if (old_sha1 && !is_null_sha1(old_sha1)) | 494 | if (old_sha1 && !is_null_sha1(old_sha1)) |
464 | ret = diff_tree_sha1(old_sha1, new_sha1, "", &opt); | 495 | ret = diff_tree_sha1(old_sha1, new_sha1, "", &opt); |
465 | else | 496 | else |
466 | ret = diff_root_tree_sha1(new_sha1, "", &opt); | 497 | ret = diff_root_tree_sha1(new_sha1, "", &opt); |
467 | diffcore_std(&opt); | 498 | diffcore_std(&opt); |
468 | diff_flush(&opt); | 499 | diff_flush(&opt); |
469 | } | 500 | } |
470 | 501 | ||
471 | void cgit_diff_commit(struct commit *commit, filepair_fn fn) | 502 | void cgit_diff_commit(struct commit *commit, filepair_fn fn) |
472 | { | 503 | { |
473 | unsigned char *old_sha1 = NULL; | 504 | unsigned char *old_sha1 = NULL; |
474 | 505 | ||
475 | if (commit->parents) | 506 | if (commit->parents) |
476 | old_sha1 = commit->parents->item->object.sha1; | 507 | old_sha1 = commit->parents->item->object.sha1; |
477 | cgit_diff_tree(old_sha1, commit->object.sha1, fn, NULL); | 508 | cgit_diff_tree(old_sha1, commit->object.sha1, fn, NULL); |
478 | } | 509 | } |
diff --git a/ui-shared.c b/ui-shared.c index 1418010..1d66940 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -173,275 +173,347 @@ static char *repolink(char *title, char *class, char *page, char *head, | |||
173 | 173 | ||
174 | static void reporevlink(char *page, char *name, char *title, char *class, | 174 | static void reporevlink(char *page, char *name, char *title, char *class, |
175 | char *head, char *rev, char *path) | 175 | char *head, char *rev, char *path) |
176 | { | 176 | { |
177 | char *delim; | 177 | char *delim; |
178 | 178 | ||
179 | delim = repolink(title, class, page, head, path); | 179 | delim = repolink(title, class, page, head, path); |
180 | if (rev && strcmp(rev, cgit_query_head)) { | 180 | if (rev && strcmp(rev, cgit_query_head)) { |
181 | html(delim); | 181 | html(delim); |
182 | html("id="); | 182 | html("id="); |
183 | html_attr(rev); | 183 | html_attr(rev); |
184 | } | 184 | } |
185 | html("'>"); | 185 | html("'>"); |
186 | html_txt(name); | 186 | html_txt(name); |
187 | html("</a>"); | 187 | html("</a>"); |
188 | } | 188 | } |
189 | 189 | ||
190 | void cgit_tree_link(char *name, char *title, char *class, char *head, | 190 | void cgit_tree_link(char *name, char *title, char *class, char *head, |
191 | char *rev, char *path) | 191 | char *rev, char *path) |
192 | { | 192 | { |
193 | reporevlink("tree", name, title, class, head, rev, path); | 193 | reporevlink("tree", name, title, class, head, rev, path); |
194 | } | 194 | } |
195 | 195 | ||
196 | void cgit_log_link(char *name, char *title, char *class, char *head, | 196 | void cgit_log_link(char *name, char *title, char *class, char *head, |
197 | char *rev, char *path, int ofs) | 197 | char *rev, char *path, int ofs) |
198 | { | 198 | { |
199 | char *delim; | 199 | char *delim; |
200 | 200 | ||
201 | delim = repolink(title, class, "log", head, path); | 201 | delim = repolink(title, class, "log", head, path); |
202 | if (rev && strcmp(rev, cgit_query_head)) { | 202 | if (rev && strcmp(rev, cgit_query_head)) { |
203 | html(delim); | 203 | html(delim); |
204 | html("id="); | 204 | html("id="); |
205 | html_attr(rev); | 205 | html_attr(rev); |
206 | delim = "&"; | 206 | delim = "&"; |
207 | } | 207 | } |
208 | if (ofs > 0) { | 208 | if (ofs > 0) { |
209 | html(delim); | 209 | html(delim); |
210 | html("ofs="); | 210 | html("ofs="); |
211 | htmlf("%d", ofs); | 211 | htmlf("%d", ofs); |
212 | } | 212 | } |
213 | html("'>"); | 213 | html("'>"); |
214 | html_txt(name); | 214 | html_txt(name); |
215 | html("</a>"); | 215 | html("</a>"); |
216 | } | 216 | } |
217 | 217 | ||
218 | void cgit_commit_link(char *name, char *title, char *class, char *head, | 218 | void cgit_commit_link(char *name, char *title, char *class, char *head, |
219 | char *rev) | 219 | char *rev) |
220 | { | 220 | { |
221 | if (strlen(name) > cgit_max_msg_len && cgit_max_msg_len >= 15) { | 221 | if (strlen(name) > cgit_max_msg_len && cgit_max_msg_len >= 15) { |
222 | name[cgit_max_msg_len] = '\0'; | 222 | name[cgit_max_msg_len] = '\0'; |
223 | name[cgit_max_msg_len - 1] = '.'; | 223 | name[cgit_max_msg_len - 1] = '.'; |
224 | name[cgit_max_msg_len - 2] = '.'; | 224 | name[cgit_max_msg_len - 2] = '.'; |
225 | name[cgit_max_msg_len - 3] = '.'; | 225 | name[cgit_max_msg_len - 3] = '.'; |
226 | } | 226 | } |
227 | reporevlink("commit", name, title, class, head, rev, NULL); | 227 | reporevlink("commit", name, title, class, head, rev, NULL); |
228 | } | 228 | } |
229 | 229 | ||
230 | void cgit_refs_link(char *name, char *title, char *class, char *head, | 230 | void cgit_refs_link(char *name, char *title, char *class, char *head, |
231 | char *rev, char *path) | 231 | char *rev, char *path) |
232 | { | 232 | { |
233 | reporevlink("refs", name, title, class, head, rev, path); | 233 | reporevlink("refs", name, title, class, head, rev, path); |
234 | } | 234 | } |
235 | 235 | ||
236 | void cgit_snapshot_link(char *name, char *title, char *class, char *head, | 236 | void cgit_snapshot_link(char *name, char *title, char *class, char *head, |
237 | char *rev, char *archivename) | 237 | char *rev, char *archivename) |
238 | { | 238 | { |
239 | reporevlink("snapshot", name, title, class, head, rev, archivename); | 239 | reporevlink("snapshot", name, title, class, head, rev, archivename); |
240 | } | 240 | } |
241 | 241 | ||
242 | void cgit_diff_link(char *name, char *title, char *class, char *head, | 242 | void cgit_diff_link(char *name, char *title, char *class, char *head, |
243 | char *new_rev, char *old_rev, char *path) | 243 | char *new_rev, char *old_rev, char *path) |
244 | { | 244 | { |
245 | char *delim; | 245 | char *delim; |
246 | 246 | ||
247 | delim = repolink(title, class, "diff", head, path); | 247 | delim = repolink(title, class, "diff", head, path); |
248 | if (new_rev && strcmp(new_rev, cgit_query_head)) { | 248 | if (new_rev && strcmp(new_rev, cgit_query_head)) { |
249 | html(delim); | 249 | html(delim); |
250 | html("id="); | 250 | html("id="); |
251 | html_attr(new_rev); | 251 | html_attr(new_rev); |
252 | delim = "&"; | 252 | delim = "&"; |
253 | } | 253 | } |
254 | if (old_rev) { | 254 | if (old_rev) { |
255 | html(delim); | 255 | html(delim); |
256 | html("id2="); | 256 | html("id2="); |
257 | html_attr(old_rev); | 257 | html_attr(old_rev); |
258 | } | 258 | } |
259 | html("'>"); | 259 | html("'>"); |
260 | html_txt(name); | 260 | html_txt(name); |
261 | html("</a>"); | 261 | html("</a>"); |
262 | } | 262 | } |
263 | 263 | ||
264 | void cgit_object_link(struct object *obj) | 264 | void cgit_object_link(struct object *obj) |
265 | { | 265 | { |
266 | char *page, *arg, *url; | 266 | char *page, *arg, *url; |
267 | 267 | ||
268 | if (obj->type == OBJ_COMMIT) { | 268 | if (obj->type == OBJ_COMMIT) { |
269 | cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL, | 269 | cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL, |
270 | cgit_query_head, sha1_to_hex(obj->sha1)); | 270 | cgit_query_head, sha1_to_hex(obj->sha1)); |
271 | return; | 271 | return; |
272 | } else if (obj->type == OBJ_TREE) { | 272 | } else if (obj->type == OBJ_TREE) { |
273 | page = "tree"; | 273 | page = "tree"; |
274 | arg = "id"; | 274 | arg = "id"; |
275 | } else if (obj->type == OBJ_TAG) { | 275 | } else if (obj->type == OBJ_TAG) { |
276 | page = "tag"; | 276 | page = "tag"; |
277 | arg = "id"; | 277 | arg = "id"; |
278 | } else { | 278 | } else { |
279 | page = "blob"; | 279 | page = "blob"; |
280 | arg = "id"; | 280 | arg = "id"; |
281 | } | 281 | } |
282 | 282 | ||
283 | url = cgit_pageurl(cgit_query_repo, page, | 283 | url = cgit_pageurl(cgit_query_repo, page, |
284 | fmt("%s=%s", arg, sha1_to_hex(obj->sha1))); | 284 | fmt("%s=%s", arg, sha1_to_hex(obj->sha1))); |
285 | html_link_open(url, NULL, NULL); | 285 | html_link_open(url, NULL, NULL); |
286 | htmlf("%s %s", typename(obj->type), | 286 | htmlf("%s %s", typename(obj->type), |
287 | sha1_to_hex(obj->sha1)); | 287 | sha1_to_hex(obj->sha1)); |
288 | html_link_close(); | 288 | html_link_close(); |
289 | } | 289 | } |
290 | 290 | ||
291 | void cgit_print_date(time_t secs, char *format) | 291 | void cgit_print_date(time_t secs, char *format) |
292 | { | 292 | { |
293 | char buf[64]; | 293 | char buf[64]; |
294 | struct tm *time; | 294 | struct tm *time; |
295 | 295 | ||
296 | time = gmtime(&secs); | 296 | time = gmtime(&secs); |
297 | strftime(buf, sizeof(buf)-1, format, time); | 297 | strftime(buf, sizeof(buf)-1, format, time); |
298 | html_txt(buf); | 298 | html_txt(buf); |
299 | } | 299 | } |
300 | 300 | ||
301 | void cgit_print_age(time_t t, time_t max_relative, char *format) | 301 | void cgit_print_age(time_t t, time_t max_relative, char *format) |
302 | { | 302 | { |
303 | time_t now, secs; | 303 | time_t now, secs; |
304 | 304 | ||
305 | time(&now); | 305 | time(&now); |
306 | secs = now - t; | 306 | secs = now - t; |
307 | 307 | ||
308 | if (secs > max_relative && max_relative >= 0) { | 308 | if (secs > max_relative && max_relative >= 0) { |
309 | cgit_print_date(t, format); | 309 | cgit_print_date(t, format); |
310 | return; | 310 | return; |
311 | } | 311 | } |
312 | 312 | ||
313 | if (secs < TM_HOUR * 2) { | 313 | if (secs < TM_HOUR * 2) { |
314 | htmlf("<span class='age-mins'>%.0f min.</span>", | 314 | htmlf("<span class='age-mins'>%.0f min.</span>", |
315 | secs * 1.0 / TM_MIN); | 315 | secs * 1.0 / TM_MIN); |
316 | return; | 316 | return; |
317 | } | 317 | } |
318 | if (secs < TM_DAY * 2) { | 318 | if (secs < TM_DAY * 2) { |
319 | htmlf("<span class='age-hours'>%.0f hours</span>", | 319 | htmlf("<span class='age-hours'>%.0f hours</span>", |
320 | secs * 1.0 / TM_HOUR); | 320 | secs * 1.0 / TM_HOUR); |
321 | return; | 321 | return; |
322 | } | 322 | } |
323 | if (secs < TM_WEEK * 2) { | 323 | if (secs < TM_WEEK * 2) { |
324 | htmlf("<span class='age-days'>%.0f days</span>", | 324 | htmlf("<span class='age-days'>%.0f days</span>", |
325 | secs * 1.0 / TM_DAY); | 325 | secs * 1.0 / TM_DAY); |
326 | return; | 326 | return; |
327 | } | 327 | } |
328 | if (secs < TM_MONTH * 2) { | 328 | if (secs < TM_MONTH * 2) { |
329 | htmlf("<span class='age-weeks'>%.0f weeks</span>", | 329 | htmlf("<span class='age-weeks'>%.0f weeks</span>", |
330 | secs * 1.0 / TM_WEEK); | 330 | secs * 1.0 / TM_WEEK); |
331 | return; | 331 | return; |
332 | } | 332 | } |
333 | if (secs < TM_YEAR * 2) { | 333 | if (secs < TM_YEAR * 2) { |
334 | htmlf("<span class='age-months'>%.0f months</span>", | 334 | htmlf("<span class='age-months'>%.0f months</span>", |
335 | secs * 1.0 / TM_MONTH); | 335 | secs * 1.0 / TM_MONTH); |
336 | return; | 336 | return; |
337 | } | 337 | } |
338 | htmlf("<span class='age-years'>%.0f years</span>", | 338 | htmlf("<span class='age-years'>%.0f years</span>", |
339 | secs * 1.0 / TM_YEAR); | 339 | secs * 1.0 / TM_YEAR); |
340 | } | 340 | } |
341 | 341 | ||
342 | void cgit_print_docstart(char *title, struct cacheitem *item) | 342 | void cgit_print_docstart(char *title, struct cacheitem *item) |
343 | { | 343 | { |
344 | html("Content-Type: text/html; charset=utf-8\n"); | 344 | html("Content-Type: text/html; charset=utf-8\n"); |
345 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); | 345 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); |
346 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + | 346 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + |
347 | ttl_seconds(item->ttl))); | 347 | ttl_seconds(item->ttl))); |
348 | html("\n"); | 348 | html("\n"); |
349 | html(cgit_doctype); | 349 | html(cgit_doctype); |
350 | html("<html>\n"); | 350 | html("<html>\n"); |
351 | html("<head>\n"); | 351 | html("<head>\n"); |
352 | html("<title>"); | 352 | html("<title>"); |
353 | html_txt(title); | 353 | html_txt(title); |
354 | html("</title>\n"); | 354 | html("</title>\n"); |
355 | htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); | 355 | htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); |
356 | html("<link rel='stylesheet' type='text/css' href='"); | 356 | html("<link rel='stylesheet' type='text/css' href='"); |
357 | html_attr(cgit_css); | 357 | html_attr(cgit_css); |
358 | html("'/>\n"); | 358 | html("'/>\n"); |
359 | html("</head>\n"); | 359 | html("</head>\n"); |
360 | html("<body>\n"); | 360 | html("<body>\n"); |
361 | } | 361 | } |
362 | 362 | ||
363 | void cgit_print_docend() | 363 | void cgit_print_docend() |
364 | { | 364 | { |
365 | html("</td></tr></table>"); | 365 | html("</td>\n</tr>\n<table>\n</body>\n</html>\n"); |
366 | html("</body>\n</html>\n"); | 366 | } |
367 | |||
368 | int print_branch_option(const char *refname, const unsigned char *sha1, | ||
369 | int flags, void *cb_data) | ||
370 | { | ||
371 | char *name = (char *)refname; | ||
372 | html_option(name, name, cgit_query_head); | ||
373 | return 0; | ||
374 | } | ||
375 | |||
376 | int print_archive_ref(const char *refname, const unsigned char *sha1, | ||
377 | int flags, void *cb_data) | ||
378 | { | ||
379 | struct tag *tag; | ||
380 | struct taginfo *info; | ||
381 | struct object *obj; | ||
382 | char buf[256], *url; | ||
383 | unsigned char fileid[20]; | ||
384 | int *header = (int *)cb_data; | ||
385 | |||
386 | if (prefixcmp(refname, "refs/archives")) | ||
387 | return 0; | ||
388 | strncpy(buf, refname+14, sizeof(buf)); | ||
389 | obj = parse_object(sha1); | ||
390 | if (!obj) | ||
391 | return 1; | ||
392 | if (obj->type == OBJ_TAG) { | ||
393 | tag = lookup_tag(sha1); | ||
394 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) | ||
395 | return 0; | ||
396 | hashcpy(fileid, tag->tagged->sha1); | ||
397 | } else if (obj->type != OBJ_BLOB) { | ||
398 | return 0; | ||
399 | } else { | ||
400 | hashcpy(fileid, sha1); | ||
401 | } | ||
402 | if (!*header) { | ||
403 | html("<p><h1>download</h1>"); | ||
404 | *header = 1; | ||
405 | } | ||
406 | url = cgit_pageurl(cgit_query_repo, "blob", | ||
407 | fmt("id=%s&path=%s", sha1_to_hex(fileid), | ||
408 | buf)); | ||
409 | html_link_open(url, NULL, "menu"); | ||
410 | html_txt(strlpart(buf, 20)); | ||
411 | html_link_close(); | ||
412 | return 0; | ||
413 | } | ||
414 | |||
415 | void add_hidden_formfields(int incl_head, int incl_search) | ||
416 | { | ||
417 | if (!cgit_virtual_root) { | ||
418 | if (cgit_query_repo) | ||
419 | html_hidden("r", cgit_query_repo); | ||
420 | if (cgit_query_page) | ||
421 | html_hidden("p", cgit_query_page); | ||
422 | } | ||
423 | |||
424 | if (incl_head && strcmp(cgit_query_head, cgit_repo->defbranch)) | ||
425 | html_hidden("h", cgit_query_head); | ||
426 | |||
427 | if (cgit_query_sha1) | ||
428 | html_hidden("id", cgit_query_sha1); | ||
429 | if (cgit_query_sha2) | ||
430 | html_hidden("id2", cgit_query_sha2); | ||
431 | |||
432 | if (incl_search) { | ||
433 | if (cgit_query_grep) | ||
434 | html_hidden("qt", cgit_query_grep); | ||
435 | if (cgit_query_search) | ||
436 | html_hidden("q", cgit_query_search); | ||
437 | } | ||
367 | } | 438 | } |
368 | 439 | ||
369 | void cgit_print_pageheader(char *title, int show_search) | 440 | void cgit_print_pageheader(char *title, int show_search) |
370 | { | 441 | { |
371 | html("<table id='layout'>"); | 442 | static const char *default_info = "This is cgit, a fast webinterface for git repositories"; |
372 | html("<tr><td id='header'><a href='"); | 443 | int header = 0; |
373 | html_attr(cgit_rooturl()); | 444 | |
374 | html("'>"); | 445 | html("<div id='sidebar'>\n"); |
375 | html_txt(cgit_root_title); | ||
376 | html("</a></td><td id='logo'>"); | ||
377 | html("<a href='"); | 446 | html("<a href='"); |
378 | html_attr(cgit_logo_link); | 447 | html_attr(cgit_rooturl()); |
379 | htmlf("'><img src='%s' alt='logo'/></a>", cgit_logo); | 448 | htmlf("'><div id='logo'><img src='%s' alt='cgit'/></div></a>\n", |
380 | html("</td></tr>"); | 449 | cgit_logo); |
381 | html("<tr><td id='crumb'>"); | 450 | html("<div class='infobox'>"); |
382 | if (cgit_query_repo) { | 451 | if (cgit_query_repo) { |
383 | html_txt(cgit_repo->name); | 452 | html("<h1>"); |
384 | html(" ("); | 453 | html_txt(strrpart(cgit_repo->name, 20)); |
385 | html_txt(cgit_query_head); | 454 | html("</h1>\n"); |
386 | html(") : "); | 455 | html_txt(cgit_repo->desc); |
387 | reporevlink(NULL, "summary", NULL, NULL, cgit_query_head, | 456 | if (cgit_repo->owner) { |
457 | html("<p>\n<h1>owner</h1>\n"); | ||
458 | html_txt(cgit_repo->owner); | ||
459 | } | ||
460 | html("<p>\n<h1>navigate</h1>\n"); | ||
461 | reporevlink(NULL, "summary", NULL, "menu", cgit_query_head, | ||
388 | NULL, NULL); | 462 | NULL, NULL); |
389 | html(" "); | 463 | cgit_log_link("log", NULL, "menu", cgit_query_head, |
390 | cgit_log_link("log", NULL, NULL, cgit_query_head, | ||
391 | cgit_query_sha1, cgit_query_path, 0); | 464 | cgit_query_sha1, cgit_query_path, 0); |
392 | html(" "); | 465 | cgit_tree_link("tree", NULL, "menu", cgit_query_head, |
393 | cgit_tree_link("tree", NULL, NULL, cgit_query_head, | ||
394 | cgit_query_sha1, NULL); | 466 | cgit_query_sha1, NULL); |
395 | html(" "); | 467 | cgit_commit_link("commit", NULL, "menu", cgit_query_head, |
396 | cgit_commit_link("commit", NULL, NULL, cgit_query_head, | ||
397 | cgit_query_sha1); | 468 | cgit_query_sha1); |
398 | html(" "); | 469 | cgit_diff_link("diff", NULL, "menu", cgit_query_head, |
399 | cgit_diff_link("diff", NULL, NULL, cgit_query_head, | ||
400 | cgit_query_sha1, cgit_query_sha2, | 470 | cgit_query_sha1, cgit_query_sha2, |
401 | cgit_query_path); | 471 | cgit_query_path); |
402 | } else { | 472 | |
403 | html_txt("Index of repositories"); | 473 | for_each_ref(print_archive_ref, &header); |
404 | } | 474 | |
405 | html("</td>"); | 475 | html("<p>\n<h1>branch</h1>\n"); |
406 | html("<td id='search'>"); | 476 | html("<form method='get' action=''>\n"); |
407 | if (show_search) { | 477 | add_hidden_formfields(0, 1); |
478 | html("<select name='h' onchange='this.form.submit();'>\n"); | ||
479 | for_each_branch_ref(print_branch_option, cgit_query_head); | ||
480 | html("</select>\n"); | ||
481 | html("</form>\n"); | ||
482 | |||
483 | html("<p>\n<h1>search</h1>\n"); | ||
408 | html("<form method='get' action='"); | 484 | html("<form method='get' action='"); |
409 | html_attr(cgit_currurl()); | 485 | html_attr(cgit_pageurl(cgit_query_repo, "log", NULL)); |
410 | html("'>"); | 486 | html("'>\n"); |
411 | if (!cgit_virtual_root) { | 487 | add_hidden_formfields(1, 0); |
412 | if (cgit_query_repo) | 488 | html("<select name='qt'>\n"); |
413 | html_hidden("r", cgit_query_repo); | ||
414 | if (cgit_query_page) | ||
415 | html_hidden("p", cgit_query_page); | ||
416 | } | ||
417 | if (cgit_query_head) | ||
418 | html_hidden("h", cgit_query_head); | ||
419 | if (cgit_query_sha1) | ||
420 | html_hidden("id", cgit_query_sha1); | ||
421 | if (cgit_query_sha2) | ||
422 | html_hidden("id2", cgit_query_sha2); | ||
423 | html("<select name='qt'>"); | ||
424 | html_option("grep", "log msg", cgit_query_grep); | 489 | html_option("grep", "log msg", cgit_query_grep); |
425 | html_option("author", "author", cgit_query_grep); | 490 | html_option("author", "author", cgit_query_grep); |
426 | html_option("committer", "committer", cgit_query_grep); | 491 | html_option("committer", "committer", cgit_query_grep); |
427 | html("</select>"); | 492 | html("</select>\n"); |
428 | html("<input class='txt' type='text' name='q' value='"); | 493 | html("<input class='txt' type='text' name='q' value='"); |
429 | html_attr(cgit_query_search); | 494 | html_attr(cgit_query_search); |
430 | html("'/><input class='btn' type='submit' value='...'/></form>"); | 495 | html("'/>\n"); |
496 | html("</form>\n"); | ||
497 | } else { | ||
498 | if (!cgit_index_info || html_include(cgit_index_info)) | ||
499 | html(default_info); | ||
431 | } | 500 | } |
432 | html("</td></tr>"); | 501 | |
433 | html("<tr><td id='content' colspan='2'>"); | 502 | html("</div>\n"); |
503 | |||
504 | html("</div>\n<table class='grid'><tr><td id='content'>\n"); | ||
434 | } | 505 | } |
435 | 506 | ||
507 | |||
436 | void cgit_print_snapshot_start(const char *mimetype, const char *filename, | 508 | void cgit_print_snapshot_start(const char *mimetype, const char *filename, |
437 | struct cacheitem *item) | 509 | struct cacheitem *item) |
438 | { | 510 | { |
439 | htmlf("Content-Type: %s\n", mimetype); | 511 | htmlf("Content-Type: %s\n", mimetype); |
440 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename); | 512 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename); |
441 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); | 513 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); |
442 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + | 514 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + |
443 | ttl_seconds(item->ttl))); | 515 | ttl_seconds(item->ttl))); |
444 | html("\n"); | 516 | html("\n"); |
445 | } | 517 | } |
446 | 518 | ||
447 | /* vim:set sw=8: */ | 519 | /* vim:set sw=8: */ |
diff --git a/ui-summary.c b/ui-summary.c index ba90510..39fe330 100644 --- a/ui-summary.c +++ b/ui-summary.c | |||
@@ -1,253 +1,200 @@ | |||
1 | /* ui-summary.c: functions for generating repo summary page | 1 | /* ui-summary.c: functions for generating repo summary page |
2 | * | 2 | * |
3 | * Copyright (C) 2006 Lars Hjemli | 3 | * Copyright (C) 2006 Lars Hjemli |
4 | * | 4 | * |
5 | * Licensed under GNU General Public License v2 | 5 | * Licensed under GNU General Public License v2 |
6 | * (see COPYING for full license text) | 6 | * (see COPYING for full license text) |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include "cgit.h" | 9 | #include "cgit.h" |
10 | 10 | ||
11 | static int header; | 11 | static int header; |
12 | 12 | ||
13 | static int cmp_age(int age1, int age2) | 13 | static int cmp_age(int age1, int age2) |
14 | { | 14 | { |
15 | if (age1 != 0 && age2 != 0) | 15 | if (age1 != 0 && age2 != 0) |
16 | return age2 - age1; | 16 | return age2 - age1; |
17 | 17 | ||
18 | if (age1 == 0 && age2 == 0) | 18 | if (age1 == 0 && age2 == 0) |
19 | return 0; | 19 | return 0; |
20 | 20 | ||
21 | if (age1 == 0) | 21 | if (age1 == 0) |
22 | return +1; | 22 | return +1; |
23 | 23 | ||
24 | return -1; | 24 | return -1; |
25 | } | 25 | } |
26 | 26 | ||
27 | static int cmp_ref_name(const void *a, const void *b) | 27 | static int cmp_ref_name(const void *a, const void *b) |
28 | { | 28 | { |
29 | struct refinfo *r1 = *(struct refinfo **)a; | 29 | struct refinfo *r1 = *(struct refinfo **)a; |
30 | struct refinfo *r2 = *(struct refinfo **)b; | 30 | struct refinfo *r2 = *(struct refinfo **)b; |
31 | 31 | ||
32 | return strcmp(r1->refname, r2->refname); | 32 | return strcmp(r1->refname, r2->refname); |
33 | } | 33 | } |
34 | 34 | ||
35 | static int cmp_branch_age(const void *a, const void *b) | 35 | static int cmp_branch_age(const void *a, const void *b) |
36 | { | 36 | { |
37 | struct refinfo *r1 = *(struct refinfo **)a; | 37 | struct refinfo *r1 = *(struct refinfo **)a; |
38 | struct refinfo *r2 = *(struct refinfo **)b; | 38 | struct refinfo *r2 = *(struct refinfo **)b; |
39 | 39 | ||
40 | return cmp_age(r1->commit->committer_date, r2->commit->committer_date); | 40 | return cmp_age(r1->commit->committer_date, r2->commit->committer_date); |
41 | } | 41 | } |
42 | 42 | ||
43 | static int cmp_tag_age(const void *a, const void *b) | 43 | static int cmp_tag_age(const void *a, const void *b) |
44 | { | 44 | { |
45 | struct refinfo *r1 = *(struct refinfo **)a; | 45 | struct refinfo *r1 = *(struct refinfo **)a; |
46 | struct refinfo *r2 = *(struct refinfo **)b; | 46 | struct refinfo *r2 = *(struct refinfo **)b; |
47 | 47 | ||
48 | return cmp_age(r1->tag->tagger_date, r2->tag->tagger_date); | 48 | return cmp_age(r1->tag->tagger_date, r2->tag->tagger_date); |
49 | } | 49 | } |
50 | 50 | ||
51 | static int print_branch(struct refinfo *ref) | 51 | static int print_branch(struct refinfo *ref) |
52 | { | 52 | { |
53 | struct commitinfo *info = ref->commit; | 53 | struct commitinfo *info = ref->commit; |
54 | char *name = (char *)ref->refname; | 54 | char *name = (char *)ref->refname; |
55 | 55 | ||
56 | if (!info) | 56 | if (!info) |
57 | return 1; | 57 | return 1; |
58 | html("<tr><td>"); | 58 | html("<tr><td>"); |
59 | cgit_log_link(name, NULL, NULL, name, NULL, NULL, 0); | 59 | cgit_log_link(name, NULL, NULL, name, NULL, NULL, 0); |
60 | html("</td><td>"); | 60 | html("</td><td>"); |
61 | 61 | ||
62 | if (ref->object->type == OBJ_COMMIT) { | 62 | if (ref->object->type == OBJ_COMMIT) { |
63 | cgit_print_age(info->commit->date, -1, NULL); | 63 | cgit_print_age(info->commit->date, -1, NULL); |
64 | html("</td><td>"); | 64 | html("</td><td>"); |
65 | html_txt(info->author); | 65 | html_txt(info->author); |
66 | html("</td><td>"); | 66 | html("</td><td>"); |
67 | cgit_commit_link(info->subject, NULL, NULL, name, NULL); | 67 | cgit_commit_link(info->subject, NULL, NULL, name, NULL); |
68 | } else { | 68 | } else { |
69 | html("</td><td></td><td>"); | 69 | html("</td><td></td><td>"); |
70 | cgit_object_link(ref->object); | 70 | cgit_object_link(ref->object); |
71 | } | 71 | } |
72 | html("</td></tr>\n"); | 72 | html("</td></tr>\n"); |
73 | return 0; | 73 | return 0; |
74 | } | 74 | } |
75 | 75 | ||
76 | static void print_tag_header() | 76 | static void print_tag_header() |
77 | { | 77 | { |
78 | html("<tr class='nohover'><th class='left'>Tag</th>" | 78 | html("<tr class='nohover'><th class='left'>Tag</th>" |
79 | "<th class='left'>Age</th>" | 79 | "<th class='left'>Age</th>" |
80 | "<th class='left'>Author</th>" | 80 | "<th class='left'>Author</th>" |
81 | "<th class='left'>Reference</th></tr>\n"); | 81 | "<th class='left'>Reference</th></tr>\n"); |
82 | header = 1; | 82 | header = 1; |
83 | } | 83 | } |
84 | 84 | ||
85 | static int print_tag(struct refinfo *ref) | 85 | static int print_tag(struct refinfo *ref) |
86 | { | 86 | { |
87 | struct tag *tag; | 87 | struct tag *tag; |
88 | struct taginfo *info; | 88 | struct taginfo *info; |
89 | char *url, *name = (char *)ref->refname; | 89 | char *url, *name = (char *)ref->refname; |
90 | 90 | ||
91 | if (ref->object->type == OBJ_TAG) { | 91 | if (ref->object->type == OBJ_TAG) { |
92 | tag = (struct tag *)ref->object; | 92 | tag = (struct tag *)ref->object; |
93 | info = ref->tag; | 93 | info = ref->tag; |
94 | if (!tag || !info) | 94 | if (!tag || !info) |
95 | return 1; | 95 | return 1; |
96 | html("<tr><td>"); | 96 | html("<tr><td>"); |
97 | url = cgit_pageurl(cgit_query_repo, "tag", | 97 | url = cgit_pageurl(cgit_query_repo, "tag", |
98 | fmt("id=%s", name)); | 98 | fmt("id=%s", name)); |
99 | html_link_open(url, NULL, NULL); | 99 | html_link_open(url, NULL, NULL); |
100 | html_txt(name); | 100 | html_txt(name); |
101 | html_link_close(); | 101 | html_link_close(); |
102 | html("</td><td>"); | 102 | html("</td><td>"); |
103 | if (info->tagger_date > 0) | 103 | if (info->tagger_date > 0) |
104 | cgit_print_age(info->tagger_date, -1, NULL); | 104 | cgit_print_age(info->tagger_date, -1, NULL); |
105 | html("</td><td>"); | 105 | html("</td><td>"); |
106 | if (info->tagger) | 106 | if (info->tagger) |
107 | html(info->tagger); | 107 | html(info->tagger); |
108 | html("</td><td>"); | 108 | html("</td><td>"); |
109 | cgit_object_link(tag->tagged); | 109 | cgit_object_link(tag->tagged); |
110 | html("</td></tr>\n"); | 110 | html("</td></tr>\n"); |
111 | } else { | 111 | } else { |
112 | if (!header) | 112 | if (!header) |
113 | print_tag_header(); | 113 | print_tag_header(); |
114 | html("<tr><td>"); | 114 | html("<tr><td>"); |
115 | html_txt(name); | 115 | html_txt(name); |
116 | html("</td><td colspan='2'/><td>"); | 116 | html("</td><td colspan='2'/><td>"); |
117 | cgit_object_link(ref->object); | 117 | cgit_object_link(ref->object); |
118 | html("</td></tr>\n"); | 118 | html("</td></tr>\n"); |
119 | } | 119 | } |
120 | return 0; | 120 | return 0; |
121 | } | 121 | } |
122 | 122 | ||
123 | static int cgit_print_archive_cb(const char *refname, const unsigned char *sha1, | ||
124 | int flags, void *cb_data) | ||
125 | { | ||
126 | struct tag *tag; | ||
127 | struct taginfo *info; | ||
128 | struct object *obj; | ||
129 | char buf[256], *url; | ||
130 | unsigned char fileid[20]; | ||
131 | |||
132 | if (prefixcmp(refname, "refs/archives")) | ||
133 | return 0; | ||
134 | strncpy(buf, refname+14, sizeof(buf)); | ||
135 | obj = parse_object(sha1); | ||
136 | if (!obj) | ||
137 | return 1; | ||
138 | if (obj->type == OBJ_TAG) { | ||
139 | tag = lookup_tag(sha1); | ||
140 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) | ||
141 | return 0; | ||
142 | hashcpy(fileid, tag->tagged->sha1); | ||
143 | } else if (obj->type != OBJ_BLOB) { | ||
144 | return 0; | ||
145 | } else { | ||
146 | hashcpy(fileid, sha1); | ||
147 | } | ||
148 | if (!header) { | ||
149 | html("<table id='downloads'>"); | ||
150 | html("<tr><th>Downloads</th></tr>"); | ||
151 | header = 1; | ||
152 | } | ||
153 | html("<tr><td>"); | ||
154 | url = cgit_pageurl(cgit_query_repo, "blob", | ||
155 | fmt("id=%s&path=%s", sha1_to_hex(fileid), | ||
156 | buf)); | ||
157 | html_link_open(url, NULL, NULL); | ||
158 | html_txt(buf); | ||
159 | html_link_close(); | ||
160 | html("</td></tr>"); | ||
161 | return 0; | ||
162 | } | ||
163 | |||
164 | static void print_refs_link(char *path) | 123 | static void print_refs_link(char *path) |
165 | { | 124 | { |
166 | html("<tr class='nohover'><td colspan='4'>"); | 125 | html("<tr class='nohover'><td colspan='4'>"); |
167 | cgit_refs_link("[...]", NULL, NULL, cgit_query_head, NULL, path); | 126 | cgit_refs_link("[...]", NULL, NULL, cgit_query_head, NULL, path); |
168 | html("</td></tr>"); | 127 | html("</td></tr>"); |
169 | } | 128 | } |
170 | 129 | ||
171 | void cgit_print_branches(int maxcount) | 130 | void cgit_print_branches(int maxcount) |
172 | { | 131 | { |
173 | struct reflist list; | 132 | struct reflist list; |
174 | int i; | 133 | int i; |
175 | 134 | ||
176 | html("<tr class='nohover'><th class='left'>Branch</th>" | 135 | html("<tr class='nohover'><th class='left'>Branch</th>" |
177 | "<th class='left'>Idle</th>" | 136 | "<th class='left'>Idle</th>" |
178 | "<th class='left'>Author</th>" | 137 | "<th class='left'>Author</th>" |
179 | "<th class='left'>Head commit</th></tr>\n"); | 138 | "<th class='left'>Head commit</th></tr>\n"); |
180 | 139 | ||
181 | list.refs = NULL; | 140 | list.refs = NULL; |
182 | list.alloc = list.count = 0; | 141 | list.alloc = list.count = 0; |
183 | for_each_branch_ref(cgit_refs_cb, &list); | 142 | for_each_branch_ref(cgit_refs_cb, &list); |
184 | 143 | ||
185 | if (maxcount == 0 || maxcount > list.count) | 144 | if (maxcount == 0 || maxcount > list.count) |
186 | maxcount = list.count; | 145 | maxcount = list.count; |
187 | 146 | ||
188 | if (maxcount < list.count) { | 147 | if (maxcount < list.count) { |
189 | qsort(list.refs, list.count, sizeof(*list.refs), cmp_branch_age); | 148 | qsort(list.refs, list.count, sizeof(*list.refs), cmp_branch_age); |
190 | qsort(list.refs, maxcount, sizeof(*list.refs), cmp_ref_name); | 149 | qsort(list.refs, maxcount, sizeof(*list.refs), cmp_ref_name); |
191 | } | 150 | } |
192 | 151 | ||
193 | for(i=0; i<maxcount; i++) | 152 | for(i=0; i<maxcount; i++) |
194 | print_branch(list.refs[i]); | 153 | print_branch(list.refs[i]); |
195 | 154 | ||
196 | if (maxcount < list.count) | 155 | if (maxcount < list.count) |
197 | print_refs_link("heads"); | 156 | print_refs_link("heads"); |
198 | } | 157 | } |
199 | 158 | ||
200 | void cgit_print_tags(int maxcount) | 159 | void cgit_print_tags(int maxcount) |
201 | { | 160 | { |
202 | struct reflist list; | 161 | struct reflist list; |
203 | int i; | 162 | int i; |
204 | 163 | ||
205 | header = 0; | 164 | header = 0; |
206 | list.refs = NULL; | 165 | list.refs = NULL; |
207 | list.alloc = list.count = 0; | 166 | list.alloc = list.count = 0; |
208 | for_each_tag_ref(cgit_refs_cb, &list); | 167 | for_each_tag_ref(cgit_refs_cb, &list); |
209 | if (list.count == 0) | 168 | if (list.count == 0) |
210 | return; | 169 | return; |
211 | qsort(list.refs, list.count, sizeof(*list.refs), cmp_tag_age); | 170 | qsort(list.refs, list.count, sizeof(*list.refs), cmp_tag_age); |
212 | if (!maxcount) | 171 | if (!maxcount) |
213 | maxcount = list.count; | 172 | maxcount = list.count; |
214 | else if (maxcount > list.count) | 173 | else if (maxcount > list.count) |
215 | maxcount = list.count; | 174 | maxcount = list.count; |
216 | print_tag_header(); | 175 | print_tag_header(); |
217 | for(i=0; i<maxcount; i++) | 176 | for(i=0; i<maxcount; i++) |
218 | print_tag(list.refs[i]); | 177 | print_tag(list.refs[i]); |
219 | 178 | ||
220 | if (maxcount < list.count) | 179 | if (maxcount < list.count) |
221 | print_refs_link("tags"); | 180 | print_refs_link("tags"); |
222 | } | 181 | } |
223 | 182 | ||
224 | static void cgit_print_archives() | ||
225 | { | ||
226 | header = 0; | ||
227 | for_each_ref(cgit_print_archive_cb, NULL); | ||
228 | if (header) | ||
229 | html("</table>"); | ||
230 | } | ||
231 | |||
232 | void cgit_print_summary() | 183 | void cgit_print_summary() |
233 | { | 184 | { |
234 | html("<div id='summary'>"); | 185 | if (cgit_repo->readme) { |
235 | cgit_print_archives(); | 186 | html("<div id='summary'>"); |
236 | html("<h2>"); | ||
237 | html_txt(cgit_repo->name); | ||
238 | html(" - "); | ||
239 | html_txt(cgit_repo->desc); | ||
240 | html("</h2>"); | ||
241 | if (cgit_repo->readme) | ||
242 | html_include(cgit_repo->readme); | 187 | html_include(cgit_repo->readme); |
243 | html("</div>"); | 188 | html("</div>"); |
189 | } | ||
244 | if (cgit_summary_log > 0) | 190 | if (cgit_summary_log > 0) |
245 | cgit_print_log(cgit_query_head, 0, cgit_summary_log, NULL, NULL, NULL, 0); | 191 | cgit_print_log(cgit_query_head, 0, cgit_summary_log, NULL, |
192 | NULL, NULL, 0); | ||
246 | html("<table class='list nowrap'>"); | 193 | html("<table class='list nowrap'>"); |
247 | if (cgit_summary_log > 0) | 194 | if (cgit_summary_log > 0) |
248 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); | 195 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); |
249 | cgit_print_branches(cgit_summary_branches); | 196 | cgit_print_branches(cgit_summary_branches); |
250 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); | 197 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); |
251 | cgit_print_tags(cgit_summary_tags); | 198 | cgit_print_tags(cgit_summary_tags); |
252 | html("</table>"); | 199 | html("</table>"); |
253 | } | 200 | } |