-rw-r--r-- | cgit.css | 64 | ||||
-rw-r--r-- | ui-repolist.c | 2 | ||||
-rw-r--r-- | ui-shared.c | 65 |
3 files changed, 98 insertions, 33 deletions
@@ -1,415 +1,445 @@ | |||
1 | body, table { | 1 | body, table { |
2 | padding: 0em; | 2 | padding: 0em; |
3 | margin: 0em; | 3 | margin: 0em; |
4 | } | 4 | } |
5 | 5 | ||
6 | body { | 6 | body { |
7 | font-family: sans; | 7 | font-family: sans; |
8 | font-size: 10pt; | 8 | font-size: 10pt; |
9 | color: #333; | 9 | color: #333; |
10 | background: white; | 10 | background: white; |
11 | padding: 4px; | 11 | padding: 4px; |
12 | } | 12 | } |
13 | 13 | ||
14 | a { | 14 | a { |
15 | color: blue; | 15 | color: blue; |
16 | text-decoration: none; | 16 | text-decoration: none; |
17 | } | 17 | } |
18 | 18 | ||
19 | a:hover { | 19 | a:hover { |
20 | text-decoration: underline; | 20 | text-decoration: underline; |
21 | } | 21 | } |
22 | 22 | ||
23 | table { | 23 | table { |
24 | border-collapse: collapse; | 24 | border-collapse: collapse; |
25 | } | 25 | } |
26 | 26 | ||
27 | table#header { | 27 | table#header { |
28 | width: 100%; | 28 | width: 100%; |
29 | margin-bottom: 1em; | 29 | margin-bottom: 1em; |
30 | } | 30 | } |
31 | 31 | ||
32 | table#header td.logo { | 32 | table#header td.logo { |
33 | width: 96px; | 33 | width: 96px; |
34 | } | 34 | } |
35 | 35 | ||
36 | table#header td.main { | 36 | table#header td.main { |
37 | font-size: 200%; | 37 | font-size: 250%; |
38 | padding-left: 10px; | ||
39 | } | ||
40 | |||
41 | table#header td.main a { | ||
42 | color: #000; | ||
43 | } | ||
44 | |||
45 | table#header td.form { | ||
46 | text-align: right; | ||
47 | vertical-align: bottom; | ||
48 | padding-right: 1em; | ||
49 | padding-bottom: 2px; | ||
50 | } | ||
51 | |||
52 | table#header td.form form, | ||
53 | table#header td.form input, | ||
54 | table#header td.form select { | ||
55 | font-size: 90%; | ||
38 | } | 56 | } |
39 | 57 | ||
40 | table#header td.sub { | 58 | table#header td.sub { |
41 | color: #777; | 59 | color: #777; |
42 | border-top: solid 1px #ccc; | 60 | border-top: solid 1px #ccc; |
61 | padding-left: 10px; | ||
43 | } | 62 | } |
44 | 63 | ||
45 | table.tabs { | 64 | table.tabs { |
46 | border-bottom: solid 2px #ccc; | 65 | /* border-bottom: solid 2px #ccc; */ |
47 | border-collapse: collapse; | 66 | border-collapse: collapse; |
48 | margin-top: 2em; | 67 | margin-top: 2em; |
49 | margin-bottom: 1em; | 68 | margin-bottom: 0px; |
50 | width: 100%; | 69 | width: 100%; |
51 | } | 70 | } |
52 | 71 | ||
53 | table.tabs td { | 72 | table.tabs td { |
54 | padding: 0px 0.5em; | 73 | padding: 0px 1em; |
55 | vertical-align: bottom; | 74 | vertical-align: bottom; |
56 | } | 75 | } |
57 | 76 | ||
58 | table.tabs td a { | 77 | table.tabs td a { |
59 | padding: 2px 1em; | 78 | padding: 2px 0.75em; |
60 | color: #007; | 79 | color: #777; |
80 | font-size: 110%; | ||
61 | } | 81 | } |
62 | 82 | ||
63 | table.tabs td a.active { | 83 | table.tabs td a.active { |
64 | color: #000; | 84 | color: #000; |
65 | background-color: #ccc; | 85 | background-color: #ccc; |
66 | } | 86 | } |
67 | 87 | ||
68 | table.tabs td.branch { | 88 | table.tabs td.form { |
69 | text-align: right; | 89 | text-align: right; |
70 | } | 90 | } |
71 | 91 | ||
72 | table.tabs td.branch form { | 92 | table.tabs td.form form { |
73 | padding-bottom: 2px; | 93 | padding-bottom: 2px; |
74 | font-size: 90%; | 94 | font-size: 90%; |
75 | } | 95 | } |
76 | 96 | ||
97 | table.tabs td.form input, | ||
98 | table.tabs td.form select { | ||
99 | font-size: 90%; | ||
100 | } | ||
101 | |||
77 | div.content { | 102 | div.content { |
78 | margin: 0px; | 103 | margin: 0px; |
79 | padding: 1em; | 104 | padding: 2em; |
105 | border-top: solid 3px #ccc; | ||
106 | border-bottom: solid 3px #ccc; | ||
80 | } | 107 | } |
81 | 108 | ||
82 | 109 | ||
83 | table.list { | 110 | table.list { |
84 | width: 100%; | 111 | width: 100%; |
85 | border: none; | 112 | border: none; |
86 | border-collapse: collapse; | 113 | border-collapse: collapse; |
87 | } | 114 | } |
88 | 115 | ||
89 | table.list tr { | 116 | table.list tr { |
90 | background: white; | 117 | background: white; |
91 | } | 118 | } |
92 | 119 | ||
93 | table.list tr:hover { | 120 | table.list tr:hover { |
94 | background: #eee; | 121 | background: #eee; |
95 | } | 122 | } |
96 | 123 | ||
97 | table.list tr.nohover:hover { | 124 | table.list tr.nohover:hover { |
98 | background: white; | 125 | background: white; |
99 | } | 126 | } |
100 | 127 | ||
101 | table.list th { | 128 | table.list th { |
102 | font-weight: normal; | 129 | font-weight: bold; |
103 | border-bottom: solid 1px #ccc; | 130 | /* color: #888; |
104 | padding: 0.1em 0.5em 0.1em 0.5em; | 131 | border-top: dashed 1px #888; |
132 | border-bottom: dashed 1px #888; | ||
133 | */ | ||
134 | padding: 0.1em 0.5em 0.05em 0.5em; | ||
105 | vertical-align: baseline; | 135 | vertical-align: baseline; |
106 | } | 136 | } |
107 | 137 | ||
108 | table.list td { | 138 | table.list td { |
109 | border: none; | 139 | border: none; |
110 | padding: 0.1em 0.5em 0.1em 0.5em; | 140 | padding: 0.1em 0.5em 0.1em 0.5em; |
111 | } | 141 | } |
112 | 142 | ||
113 | table.list td a { | 143 | table.list td a { |
114 | color: black; | 144 | color: black; |
115 | } | 145 | } |
116 | 146 | ||
117 | img { | 147 | img { |
118 | border: none; | 148 | border: none; |
119 | } | 149 | } |
120 | 150 | ||
121 | input#switch-btn { | 151 | input#switch-btn { |
122 | margin: 2px 0px 0px 0px; | 152 | margin: 2px 0px 0px 0px; |
123 | } | 153 | } |
124 | 154 | ||
125 | td#sidebar input.txt { | 155 | td#sidebar input.txt { |
126 | width: 100%; | 156 | width: 100%; |
127 | margin: 2px 0px 0px 0px; | 157 | margin: 2px 0px 0px 0px; |
128 | } | 158 | } |
129 | 159 | ||
130 | table#grid { | 160 | table#grid { |
131 | margin: 0px; | 161 | margin: 0px; |
132 | } | 162 | } |
133 | 163 | ||
134 | td#content { | 164 | td#content { |
135 | vertical-align: top; | 165 | vertical-align: top; |
136 | padding: 1em 2em 1em 1em; | 166 | padding: 1em 2em 1em 1em; |
137 | border: none; | 167 | border: none; |
138 | } | 168 | } |
139 | 169 | ||
140 | div#summary { | 170 | div#summary { |
141 | vertical-align: top; | 171 | vertical-align: top; |
142 | margin-bottom: 1em; | 172 | margin-bottom: 1em; |
143 | } | 173 | } |
144 | 174 | ||
145 | table#downloads { | 175 | table#downloads { |
146 | float: right; | 176 | float: right; |
147 | border-collapse: collapse; | 177 | border-collapse: collapse; |
148 | border: solid 1px #777; | 178 | border: solid 1px #777; |
149 | margin-left: 0.5em; | 179 | margin-left: 0.5em; |
150 | margin-bottom: 0.5em; | 180 | margin-bottom: 0.5em; |
151 | } | 181 | } |
152 | 182 | ||
153 | table#downloads th { | 183 | table#downloads th { |
154 | background-color: #ccc; | 184 | background-color: #ccc; |
155 | } | 185 | } |
156 | 186 | ||
157 | div#blob { | 187 | div#blob { |
158 | border: solid 1px black; | 188 | border: solid 1px black; |
159 | } | 189 | } |
160 | 190 | ||
161 | div.error { | 191 | div.error { |
162 | color: red; | 192 | color: red; |
163 | font-weight: bold; | 193 | font-weight: bold; |
164 | margin: 1em 2em; | 194 | margin: 1em 2em; |
165 | } | 195 | } |
166 | 196 | ||
167 | a.ls-blob, a.ls-dir, a.ls-mod { | 197 | a.ls-blob, a.ls-dir, a.ls-mod { |
168 | font-family: monospace; | 198 | font-family: monospace; |
169 | } | 199 | } |
170 | 200 | ||
171 | td.ls-size { | 201 | td.ls-size { |
172 | text-align: right; | 202 | text-align: right; |
173 | font-family: monospace; | 203 | font-family: monospace; |
174 | width: 10em; | 204 | width: 10em; |
175 | } | 205 | } |
176 | 206 | ||
177 | td.ls-mode { | 207 | td.ls-mode { |
178 | font-family: monospace; | 208 | font-family: monospace; |
179 | width: 10em; | 209 | width: 10em; |
180 | } | 210 | } |
181 | 211 | ||
182 | table.blob { | 212 | table.blob { |
183 | margin-top: 0.5em; | 213 | margin-top: 0.5em; |
184 | border-top: solid 1px black; | 214 | border-top: solid 1px black; |
185 | } | 215 | } |
186 | 216 | ||
187 | table.blob td.no { | 217 | table.blob td.no { |
188 | border-right: solid 1px black; | 218 | border-right: solid 1px black; |
189 | color: black; | 219 | color: black; |
190 | background-color: #eee; | 220 | background-color: #eee; |
191 | text-align: right; | 221 | text-align: right; |
192 | } | 222 | } |
193 | 223 | ||
194 | table.blob td.no a { | 224 | table.blob td.no a { |
195 | color: black; | 225 | color: black; |
196 | } | 226 | } |
197 | 227 | ||
198 | table.blob td.no a:hover { | 228 | table.blob td.no a:hover { |
199 | color: black; | 229 | color: black; |
200 | text-decoration: none; | 230 | text-decoration: none; |
201 | } | 231 | } |
202 | 232 | ||
203 | table.blob td.txt { | 233 | table.blob td.txt { |
204 | white-space: pre; | 234 | white-space: pre; |
205 | font-family: monospace; | 235 | font-family: monospace; |
206 | padding-left: 0.5em; | 236 | padding-left: 0.5em; |
207 | } | 237 | } |
208 | 238 | ||
209 | table.nowrap td { | 239 | table.nowrap td { |
210 | white-space: nowrap; | 240 | white-space: nowrap; |
211 | } | 241 | } |
212 | 242 | ||
213 | table.commit-info { | 243 | table.commit-info { |
214 | border-collapse: collapse; | 244 | border-collapse: collapse; |
215 | margin-top: 1.5em; | 245 | margin-top: 1.5em; |
216 | } | 246 | } |
217 | 247 | ||
218 | table.commit-info th { | 248 | table.commit-info th { |
219 | text-align: left; | 249 | text-align: left; |
220 | font-weight: normal; | 250 | font-weight: normal; |
221 | padding: 0.1em 1em 0.1em 0.1em; | 251 | padding: 0.1em 1em 0.1em 0.1em; |
222 | vertical-align: top; | 252 | vertical-align: top; |
223 | } | 253 | } |
224 | 254 | ||
225 | table.commit-info td { | 255 | table.commit-info td { |
226 | font-weight: normal; | 256 | font-weight: normal; |
227 | padding: 0.1em 1em 0.1em 0.1em; | 257 | padding: 0.1em 1em 0.1em 0.1em; |
228 | } | 258 | } |
229 | 259 | ||
230 | div.commit-subject { | 260 | div.commit-subject { |
231 | font-weight: bold; | 261 | font-weight: bold; |
232 | font-size: 125%; | 262 | font-size: 125%; |
233 | margin: 1.5em 0em 0.5em 0em; | 263 | margin: 1.5em 0em 0.5em 0em; |
234 | padding: 0em; | 264 | padding: 0em; |
235 | } | 265 | } |
236 | 266 | ||
237 | div.commit-msg { | 267 | div.commit-msg { |
238 | white-space: pre; | 268 | white-space: pre; |
239 | font-family: monospace; | 269 | font-family: monospace; |
240 | } | 270 | } |
241 | 271 | ||
242 | div.diffstat-header { | 272 | div.diffstat-header { |
243 | font-weight: bold; | 273 | font-weight: bold; |
244 | padding-top: 1.5em; | 274 | padding-top: 1.5em; |
245 | } | 275 | } |
246 | 276 | ||
247 | table.diffstat { | 277 | table.diffstat { |
248 | border-collapse: collapse; | 278 | border-collapse: collapse; |
249 | border: solid 1px #aaa; | 279 | border: solid 1px #aaa; |
250 | background-color: #eee; | 280 | background-color: #eee; |
251 | } | 281 | } |
252 | 282 | ||
253 | table.diffstat th { | 283 | table.diffstat th { |
254 | font-weight: normal; | 284 | font-weight: normal; |
255 | text-align: left; | 285 | text-align: left; |
256 | text-decoration: underline; | 286 | text-decoration: underline; |
257 | padding: 0.1em 1em 0.1em 0.1em; | 287 | padding: 0.1em 1em 0.1em 0.1em; |
258 | font-size: 100%; | 288 | font-size: 100%; |
259 | } | 289 | } |
260 | 290 | ||
261 | table.diffstat td { | 291 | table.diffstat td { |
262 | padding: 0.2em 0.2em 0.1em 0.1em; | 292 | padding: 0.2em 0.2em 0.1em 0.1em; |
263 | font-size: 100%; | 293 | font-size: 100%; |
264 | border: none; | 294 | border: none; |
265 | } | 295 | } |
266 | 296 | ||
267 | table.diffstat td.mode { | 297 | table.diffstat td.mode { |
268 | white-space: nowrap; | 298 | white-space: nowrap; |
269 | } | 299 | } |
270 | 300 | ||
271 | table.diffstat td span.modechange { | 301 | table.diffstat td span.modechange { |
272 | padding-left: 1em; | 302 | padding-left: 1em; |
273 | color: red; | 303 | color: red; |
274 | } | 304 | } |
275 | 305 | ||
276 | table.diffstat td.add a { | 306 | table.diffstat td.add a { |
277 | color: green; | 307 | color: green; |
278 | } | 308 | } |
279 | 309 | ||
280 | table.diffstat td.del a { | 310 | table.diffstat td.del a { |
281 | color: red; | 311 | color: red; |
282 | } | 312 | } |
283 | 313 | ||
284 | table.diffstat td.upd a { | 314 | table.diffstat td.upd a { |
285 | color: blue; | 315 | color: blue; |
286 | } | 316 | } |
287 | 317 | ||
288 | table.diffstat td.graph { | 318 | table.diffstat td.graph { |
289 | width: 500px; | 319 | width: 500px; |
290 | vertical-align: middle; | 320 | vertical-align: middle; |
291 | } | 321 | } |
292 | 322 | ||
293 | table.diffstat td.graph table { | 323 | table.diffstat td.graph table { |
294 | border: none; | 324 | border: none; |
295 | } | 325 | } |
296 | 326 | ||
297 | table.diffstat td.graph td { | 327 | table.diffstat td.graph td { |
298 | padding: 0px; | 328 | padding: 0px; |
299 | border: 0px; | 329 | border: 0px; |
300 | height: 7pt; | 330 | height: 7pt; |
301 | } | 331 | } |
302 | 332 | ||
303 | table.diffstat td.graph td.add { | 333 | table.diffstat td.graph td.add { |
304 | background-color: #5c5; | 334 | background-color: #5c5; |
305 | } | 335 | } |
306 | 336 | ||
307 | table.diffstat td.graph td.rem { | 337 | table.diffstat td.graph td.rem { |
308 | background-color: #c55; | 338 | background-color: #c55; |
309 | } | 339 | } |
310 | 340 | ||
311 | div.diffstat-summary { | 341 | div.diffstat-summary { |
312 | color: #888; | 342 | color: #888; |
313 | padding-top: 0.5em; | 343 | padding-top: 0.5em; |
314 | } | 344 | } |
315 | 345 | ||
316 | table.diff { | 346 | table.diff { |
317 | width: 100%; | 347 | width: 100%; |
318 | } | 348 | } |
319 | 349 | ||
320 | table.diff td { | 350 | table.diff td { |
321 | font-family: monospace; | 351 | font-family: monospace; |
322 | white-space: pre; | 352 | white-space: pre; |
323 | } | 353 | } |
324 | 354 | ||
325 | table.diff td div.head { | 355 | table.diff td div.head { |
326 | font-weight: bold; | 356 | font-weight: bold; |
327 | margin-top: 1em; | 357 | margin-top: 1em; |
328 | color: black; | 358 | color: black; |
329 | } | 359 | } |
330 | 360 | ||
331 | table.diff td div.hunk { | 361 | table.diff td div.hunk { |
332 | color: #009; | 362 | color: #009; |
333 | } | 363 | } |
334 | 364 | ||
335 | table.diff td div.add { | 365 | table.diff td div.add { |
336 | color: green; | 366 | color: green; |
337 | } | 367 | } |
338 | 368 | ||
339 | table.diff td div.del { | 369 | table.diff td div.del { |
340 | color: red; | 370 | color: red; |
341 | } | 371 | } |
342 | 372 | ||
343 | .sha1 { | 373 | .sha1 { |
344 | font-family: monospace; | 374 | font-family: monospace; |
345 | font-size: 90%; | 375 | font-size: 90%; |
346 | } | 376 | } |
347 | 377 | ||
348 | .left { | 378 | .left { |
349 | text-align: left; | 379 | text-align: left; |
350 | } | 380 | } |
351 | 381 | ||
352 | .right { | 382 | .right { |
353 | text-align: right; | 383 | text-align: right; |
354 | } | 384 | } |
355 | 385 | ||
356 | table.list td.repogroup { | 386 | table.list td.repogroup { |
357 | font-style: italic; | 387 | font-style: italic; |
358 | color: #888; | 388 | color: #888; |
359 | } | 389 | } |
360 | 390 | ||
361 | a.button { | 391 | a.button { |
362 | font-size: 80%; | 392 | font-size: 80%; |
363 | color: #aaa; | 393 | color: #33c; |
394 | /* | ||
364 | background-color: #eee; | 395 | background-color: #eee; |
365 | border: solid 1px #aaa; | 396 | border: solid 1px #aaa; |
366 | padding: 0em 0.5em; | ||
367 | margin: 0.1em 0.25em; | 397 | margin: 0.1em 0.25em; |
398 | */ | ||
399 | padding: 0em 0.5em; | ||
368 | } | 400 | } |
369 | 401 | ||
370 | a.button:hover { | 402 | a.button:hover { |
371 | text-decoration: none; | 403 | text-decoration: underline; |
372 | color: #333; | ||
373 | background-color: #ccc; | ||
374 | } | 404 | } |
375 | 405 | ||
376 | a.primary { | 406 | a.primary { |
377 | font-size: 100%; | 407 | font-size: 100%; |
378 | } | 408 | } |
379 | 409 | ||
380 | a.secondary { | 410 | a.secondary { |
381 | font-size: 90%; | 411 | font-size: 90%; |
382 | } | 412 | } |
383 | 413 | ||
384 | td.toplevel-repo { | 414 | td.toplevel-repo { |
385 | 415 | ||
386 | } | 416 | } |
387 | 417 | ||
388 | table.list td.sublevel-repo { | 418 | table.list td.sublevel-repo { |
389 | padding-left: 1.5em; | 419 | padding-left: 1.5em; |
390 | } | 420 | } |
391 | 421 | ||
392 | span.age-mins { | 422 | span.age-mins { |
393 | font-weight: bold; | 423 | font-weight: bold; |
394 | color: #080; | 424 | color: #080; |
395 | } | 425 | } |
396 | 426 | ||
397 | span.age-hours { | 427 | span.age-hours { |
398 | color: #080; | 428 | color: #080; |
399 | } | 429 | } |
400 | 430 | ||
401 | span.age-days { | 431 | span.age-days { |
402 | color: #040; | 432 | color: #040; |
403 | } | 433 | } |
404 | 434 | ||
405 | span.age-weeks { | 435 | span.age-weeks { |
406 | color: #444; | 436 | color: #444; |
407 | } | 437 | } |
408 | 438 | ||
409 | span.age-months { | 439 | span.age-months { |
410 | color: #888; | 440 | color: #888; |
411 | } | 441 | } |
412 | 442 | ||
413 | span.age-years { | 443 | span.age-years { |
414 | color: #bbb; | 444 | color: #bbb; |
415 | } | 445 | } |
diff --git a/ui-repolist.c b/ui-repolist.c index eeeaf3d..9eba222 100644 --- a/ui-repolist.c +++ b/ui-repolist.c | |||
@@ -1,114 +1,114 @@ | |||
1 | /* ui-repolist.c: functions for generating the repolist page | 1 | /* ui-repolist.c: functions for generating the repolist 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 <time.h> | 9 | #include <time.h> |
10 | 10 | ||
11 | #include "cgit.h" | 11 | #include "cgit.h" |
12 | #include "html.h" | 12 | #include "html.h" |
13 | #include "ui-shared.h" | 13 | #include "ui-shared.h" |
14 | 14 | ||
15 | time_t read_agefile(char *path) | 15 | time_t read_agefile(char *path) |
16 | { | 16 | { |
17 | FILE *f; | 17 | FILE *f; |
18 | static char buf[64], buf2[64]; | 18 | static char buf[64], buf2[64]; |
19 | 19 | ||
20 | if (!(f = fopen(path, "r"))) | 20 | if (!(f = fopen(path, "r"))) |
21 | return -1; | 21 | return -1; |
22 | fgets(buf, sizeof(buf), f); | 22 | fgets(buf, sizeof(buf), f); |
23 | fclose(f); | 23 | fclose(f); |
24 | if (parse_date(buf, buf2, sizeof(buf2))) | 24 | if (parse_date(buf, buf2, sizeof(buf2))) |
25 | return strtoul(buf2, NULL, 10); | 25 | return strtoul(buf2, NULL, 10); |
26 | else | 26 | else |
27 | return 0; | 27 | return 0; |
28 | } | 28 | } |
29 | 29 | ||
30 | static void print_modtime(struct cgit_repo *repo) | 30 | static void print_modtime(struct cgit_repo *repo) |
31 | { | 31 | { |
32 | char *path; | 32 | char *path; |
33 | struct stat s; | 33 | struct stat s; |
34 | 34 | ||
35 | path = fmt("%s/%s", repo->path, ctx.cfg.agefile); | 35 | path = fmt("%s/%s", repo->path, ctx.cfg.agefile); |
36 | if (stat(path, &s) == 0) { | 36 | if (stat(path, &s) == 0) { |
37 | cgit_print_age(read_agefile(path), -1, NULL); | 37 | cgit_print_age(read_agefile(path), -1, NULL); |
38 | return; | 38 | return; |
39 | } | 39 | } |
40 | 40 | ||
41 | path = fmt("%s/refs/heads/%s", repo->path, repo->defbranch); | 41 | path = fmt("%s/refs/heads/%s", repo->path, repo->defbranch); |
42 | if (stat(path, &s) != 0) | 42 | if (stat(path, &s) != 0) |
43 | return; | 43 | return; |
44 | cgit_print_age(s.st_mtime, -1, NULL); | 44 | cgit_print_age(s.st_mtime, -1, NULL); |
45 | } | 45 | } |
46 | 46 | ||
47 | void cgit_print_repolist() | 47 | void cgit_print_repolist() |
48 | { | 48 | { |
49 | int i, columns = 4; | 49 | int i, columns = 4; |
50 | char *last_group = NULL; | 50 | char *last_group = NULL; |
51 | 51 | ||
52 | if (ctx.cfg.enable_index_links) | 52 | if (ctx.cfg.enable_index_links) |
53 | columns++; | 53 | columns++; |
54 | 54 | ||
55 | ctx.page.title = ctx.cfg.root_title; | 55 | ctx.page.title = ctx.cfg.root_title; |
56 | cgit_print_http_headers(&ctx); | 56 | cgit_print_http_headers(&ctx); |
57 | cgit_print_docstart(&ctx); | 57 | cgit_print_docstart(&ctx); |
58 | cgit_print_pageheader(&ctx); | 58 | cgit_print_pageheader(&ctx); |
59 | 59 | ||
60 | html("<table summary='repository list' class='list nowrap'>"); | 60 | html("<table summary='repository list' class='list nowrap'>"); |
61 | if (ctx.cfg.index_header) { | 61 | if (ctx.cfg.index_header) { |
62 | htmlf("<tr class='nohover'><td colspan='%d' class='include-block'>", | 62 | htmlf("<tr class='nohover'><td colspan='%d' class='include-block'>", |
63 | columns); | 63 | columns); |
64 | html_include(ctx.cfg.index_header); | 64 | html_include(ctx.cfg.index_header); |
65 | html("</td></tr>"); | 65 | html("</td></tr>"); |
66 | } | 66 | } |
67 | html("<tr class='nohover'>" | 67 | html("<tr class='nohover'>" |
68 | "<th class='left'>Name</th>" | 68 | "<th class='left'>Name</th>" |
69 | "<th class='left'>Description</th>" | 69 | "<th class='left'>Description</th>" |
70 | "<th class='left'>Owner</th>" | 70 | "<th class='left'>Owner</th>" |
71 | "<th class='left'>Idle</th>"); | 71 | "<th class='left'>Idle</th>"); |
72 | if (ctx.cfg.enable_index_links) | 72 | if (ctx.cfg.enable_index_links) |
73 | html("<th>Links</th>"); | 73 | html("<th class='left'>Links</th>"); |
74 | html("</tr>\n"); | 74 | html("</tr>\n"); |
75 | 75 | ||
76 | for (i=0; i<cgit_repolist.count; i++) { | 76 | for (i=0; i<cgit_repolist.count; i++) { |
77 | ctx.repo = &cgit_repolist.repos[i]; | 77 | ctx.repo = &cgit_repolist.repos[i]; |
78 | if ((last_group == NULL && ctx.repo->group != NULL) || | 78 | if ((last_group == NULL && ctx.repo->group != NULL) || |
79 | (last_group != NULL && ctx.repo->group == NULL) || | 79 | (last_group != NULL && ctx.repo->group == NULL) || |
80 | (last_group != NULL && ctx.repo->group != NULL && | 80 | (last_group != NULL && ctx.repo->group != NULL && |
81 | strcmp(ctx.repo->group, last_group))) { | 81 | strcmp(ctx.repo->group, last_group))) { |
82 | htmlf("<tr class='nohover'><td colspan='%d' class='repogroup'>", | 82 | htmlf("<tr class='nohover'><td colspan='%d' class='repogroup'>", |
83 | columns); | 83 | columns); |
84 | html_txt(ctx.repo->group); | 84 | html_txt(ctx.repo->group); |
85 | html("</td></tr>"); | 85 | html("</td></tr>"); |
86 | last_group = ctx.repo->group; | 86 | last_group = ctx.repo->group; |
87 | } | 87 | } |
88 | htmlf("<tr><td class='%s'>", | 88 | htmlf("<tr><td class='%s'>", |
89 | ctx.repo->group ? "sublevel-repo" : "toplevel-repo"); | 89 | ctx.repo->group ? "sublevel-repo" : "toplevel-repo"); |
90 | html_link_open(cgit_repourl(ctx.repo->url), NULL, NULL); | 90 | html_link_open(cgit_repourl(ctx.repo->url), NULL, NULL); |
91 | html_txt(ctx.repo->name); | 91 | html_txt(ctx.repo->name); |
92 | html_link_close(); | 92 | html_link_close(); |
93 | html("</td><td>"); | 93 | html("</td><td>"); |
94 | html_ntxt(ctx.cfg.max_repodesc_len, ctx.repo->desc); | 94 | html_ntxt(ctx.cfg.max_repodesc_len, ctx.repo->desc); |
95 | html("</td><td>"); | 95 | html("</td><td>"); |
96 | html_txt(ctx.repo->owner); | 96 | html_txt(ctx.repo->owner); |
97 | html("</td><td>"); | 97 | html("</td><td>"); |
98 | print_modtime(ctx.repo); | 98 | print_modtime(ctx.repo); |
99 | html("</td>"); | 99 | html("</td>"); |
100 | if (ctx.cfg.enable_index_links) { | 100 | if (ctx.cfg.enable_index_links) { |
101 | html("<td>"); | 101 | html("<td>"); |
102 | html_link_open(cgit_repourl(ctx.repo->url), | 102 | html_link_open(cgit_repourl(ctx.repo->url), |
103 | NULL, "button"); | 103 | NULL, "button"); |
104 | html("summary</a>"); | 104 | html("summary</a>"); |
105 | cgit_log_link("log", NULL, "button", NULL, NULL, NULL, | 105 | cgit_log_link("log", NULL, "button", NULL, NULL, NULL, |
106 | 0, NULL, NULL); | 106 | 0, NULL, NULL); |
107 | cgit_tree_link("tree", NULL, "button", NULL, NULL, NULL); | 107 | cgit_tree_link("tree", NULL, "button", NULL, NULL, NULL); |
108 | html("</td>"); | 108 | html("</td>"); |
109 | } | 109 | } |
110 | html("</tr>\n"); | 110 | html("</tr>\n"); |
111 | } | 111 | } |
112 | html("</table>"); | 112 | html("</table>"); |
113 | cgit_print_docend(); | 113 | cgit_print_docend(); |
114 | } | 114 | } |
diff --git a/ui-shared.c b/ui-shared.c index 73e3d4c..782caa7 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -200,368 +200,403 @@ void cgit_log_link(char *name, char *title, char *class, char *head, | |||
200 | html("id="); | 200 | html("id="); |
201 | html_attr(rev); | 201 | html_attr(rev); |
202 | delim = "&"; | 202 | delim = "&"; |
203 | } | 203 | } |
204 | if (grep && pattern) { | 204 | if (grep && pattern) { |
205 | html(delim); | 205 | html(delim); |
206 | html("qt="); | 206 | html("qt="); |
207 | html_attr(grep); | 207 | html_attr(grep); |
208 | delim = "&"; | 208 | delim = "&"; |
209 | html(delim); | 209 | html(delim); |
210 | html("q="); | 210 | html("q="); |
211 | html_attr(pattern); | 211 | html_attr(pattern); |
212 | } | 212 | } |
213 | if (ofs > 0) { | 213 | if (ofs > 0) { |
214 | html(delim); | 214 | html(delim); |
215 | html("ofs="); | 215 | html("ofs="); |
216 | htmlf("%d", ofs); | 216 | htmlf("%d", ofs); |
217 | } | 217 | } |
218 | html("'>"); | 218 | html("'>"); |
219 | html_txt(name); | 219 | html_txt(name); |
220 | html("</a>"); | 220 | html("</a>"); |
221 | } | 221 | } |
222 | 222 | ||
223 | void cgit_commit_link(char *name, char *title, char *class, char *head, | 223 | void cgit_commit_link(char *name, char *title, char *class, char *head, |
224 | char *rev) | 224 | char *rev) |
225 | { | 225 | { |
226 | if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) { | 226 | if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) { |
227 | name[ctx.cfg.max_msg_len] = '\0'; | 227 | name[ctx.cfg.max_msg_len] = '\0'; |
228 | name[ctx.cfg.max_msg_len - 1] = '.'; | 228 | name[ctx.cfg.max_msg_len - 1] = '.'; |
229 | name[ctx.cfg.max_msg_len - 2] = '.'; | 229 | name[ctx.cfg.max_msg_len - 2] = '.'; |
230 | name[ctx.cfg.max_msg_len - 3] = '.'; | 230 | name[ctx.cfg.max_msg_len - 3] = '.'; |
231 | } | 231 | } |
232 | reporevlink("commit", name, title, class, head, rev, NULL); | 232 | reporevlink("commit", name, title, class, head, rev, NULL); |
233 | } | 233 | } |
234 | 234 | ||
235 | void cgit_refs_link(char *name, char *title, char *class, char *head, | 235 | void cgit_refs_link(char *name, char *title, char *class, char *head, |
236 | char *rev, char *path) | 236 | char *rev, char *path) |
237 | { | 237 | { |
238 | reporevlink("refs", name, title, class, head, rev, path); | 238 | reporevlink("refs", name, title, class, head, rev, path); |
239 | } | 239 | } |
240 | 240 | ||
241 | void cgit_snapshot_link(char *name, char *title, char *class, char *head, | 241 | void cgit_snapshot_link(char *name, char *title, char *class, char *head, |
242 | char *rev, char *archivename) | 242 | char *rev, char *archivename) |
243 | { | 243 | { |
244 | reporevlink("snapshot", name, title, class, head, rev, archivename); | 244 | reporevlink("snapshot", name, title, class, head, rev, archivename); |
245 | } | 245 | } |
246 | 246 | ||
247 | void cgit_diff_link(char *name, char *title, char *class, char *head, | 247 | void cgit_diff_link(char *name, char *title, char *class, char *head, |
248 | char *new_rev, char *old_rev, char *path) | 248 | char *new_rev, char *old_rev, char *path) |
249 | { | 249 | { |
250 | char *delim; | 250 | char *delim; |
251 | 251 | ||
252 | delim = repolink(title, class, "diff", head, path); | 252 | delim = repolink(title, class, "diff", head, path); |
253 | if (new_rev && strcmp(new_rev, ctx.qry.head)) { | 253 | if (new_rev && strcmp(new_rev, ctx.qry.head)) { |
254 | html(delim); | 254 | html(delim); |
255 | html("id="); | 255 | html("id="); |
256 | html_attr(new_rev); | 256 | html_attr(new_rev); |
257 | delim = "&"; | 257 | delim = "&"; |
258 | } | 258 | } |
259 | if (old_rev) { | 259 | if (old_rev) { |
260 | html(delim); | 260 | html(delim); |
261 | html("id2="); | 261 | html("id2="); |
262 | html_attr(old_rev); | 262 | html_attr(old_rev); |
263 | } | 263 | } |
264 | html("'>"); | 264 | html("'>"); |
265 | html_txt(name); | 265 | html_txt(name); |
266 | html("</a>"); | 266 | html("</a>"); |
267 | } | 267 | } |
268 | 268 | ||
269 | void cgit_patch_link(char *name, char *title, char *class, char *head, | 269 | void cgit_patch_link(char *name, char *title, char *class, char *head, |
270 | char *rev) | 270 | char *rev) |
271 | { | 271 | { |
272 | reporevlink("patch", name, title, class, head, rev, NULL); | 272 | reporevlink("patch", name, title, class, head, rev, NULL); |
273 | } | 273 | } |
274 | 274 | ||
275 | void cgit_object_link(struct object *obj) | 275 | void cgit_object_link(struct object *obj) |
276 | { | 276 | { |
277 | char *page, *arg, *url; | 277 | char *page, *arg, *url; |
278 | 278 | ||
279 | if (obj->type == OBJ_COMMIT) { | 279 | if (obj->type == OBJ_COMMIT) { |
280 | cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL, | 280 | cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL, |
281 | ctx.qry.head, sha1_to_hex(obj->sha1)); | 281 | ctx.qry.head, sha1_to_hex(obj->sha1)); |
282 | return; | 282 | return; |
283 | } else if (obj->type == OBJ_TREE) { | 283 | } else if (obj->type == OBJ_TREE) { |
284 | page = "tree"; | 284 | page = "tree"; |
285 | arg = "id"; | 285 | arg = "id"; |
286 | } else if (obj->type == OBJ_TAG) { | 286 | } else if (obj->type == OBJ_TAG) { |
287 | page = "tag"; | 287 | page = "tag"; |
288 | arg = "id"; | 288 | arg = "id"; |
289 | } else { | 289 | } else { |
290 | page = "blob"; | 290 | page = "blob"; |
291 | arg = "id"; | 291 | arg = "id"; |
292 | } | 292 | } |
293 | 293 | ||
294 | url = cgit_pageurl(ctx.qry.repo, page, | 294 | url = cgit_pageurl(ctx.qry.repo, page, |
295 | fmt("%s=%s", arg, sha1_to_hex(obj->sha1))); | 295 | fmt("%s=%s", arg, sha1_to_hex(obj->sha1))); |
296 | html_link_open(url, NULL, NULL); | 296 | html_link_open(url, NULL, NULL); |
297 | htmlf("%s %s", typename(obj->type), | 297 | htmlf("%s %s", typename(obj->type), |
298 | sha1_to_hex(obj->sha1)); | 298 | sha1_to_hex(obj->sha1)); |
299 | html_link_close(); | 299 | html_link_close(); |
300 | } | 300 | } |
301 | 301 | ||
302 | void cgit_print_date(time_t secs, char *format) | 302 | void cgit_print_date(time_t secs, char *format) |
303 | { | 303 | { |
304 | char buf[64]; | 304 | char buf[64]; |
305 | struct tm *time; | 305 | struct tm *time; |
306 | 306 | ||
307 | if (!secs) | 307 | if (!secs) |
308 | return; | 308 | return; |
309 | time = gmtime(&secs); | 309 | time = gmtime(&secs); |
310 | strftime(buf, sizeof(buf)-1, format, time); | 310 | strftime(buf, sizeof(buf)-1, format, time); |
311 | html_txt(buf); | 311 | html_txt(buf); |
312 | } | 312 | } |
313 | 313 | ||
314 | void cgit_print_age(time_t t, time_t max_relative, char *format) | 314 | void cgit_print_age(time_t t, time_t max_relative, char *format) |
315 | { | 315 | { |
316 | time_t now, secs; | 316 | time_t now, secs; |
317 | 317 | ||
318 | if (!t) | 318 | if (!t) |
319 | return; | 319 | return; |
320 | time(&now); | 320 | time(&now); |
321 | secs = now - t; | 321 | secs = now - t; |
322 | 322 | ||
323 | if (secs > max_relative && max_relative >= 0) { | 323 | if (secs > max_relative && max_relative >= 0) { |
324 | cgit_print_date(t, format); | 324 | cgit_print_date(t, format); |
325 | return; | 325 | return; |
326 | } | 326 | } |
327 | 327 | ||
328 | if (secs < TM_HOUR * 2) { | 328 | if (secs < TM_HOUR * 2) { |
329 | htmlf("<span class='age-mins'>%.0f min.</span>", | 329 | htmlf("<span class='age-mins'>%.0f min.</span>", |
330 | secs * 1.0 / TM_MIN); | 330 | secs * 1.0 / TM_MIN); |
331 | return; | 331 | return; |
332 | } | 332 | } |
333 | if (secs < TM_DAY * 2) { | 333 | if (secs < TM_DAY * 2) { |
334 | htmlf("<span class='age-hours'>%.0f hours</span>", | 334 | htmlf("<span class='age-hours'>%.0f hours</span>", |
335 | secs * 1.0 / TM_HOUR); | 335 | secs * 1.0 / TM_HOUR); |
336 | return; | 336 | return; |
337 | } | 337 | } |
338 | if (secs < TM_WEEK * 2) { | 338 | if (secs < TM_WEEK * 2) { |
339 | htmlf("<span class='age-days'>%.0f days</span>", | 339 | htmlf("<span class='age-days'>%.0f days</span>", |
340 | secs * 1.0 / TM_DAY); | 340 | secs * 1.0 / TM_DAY); |
341 | return; | 341 | return; |
342 | } | 342 | } |
343 | if (secs < TM_MONTH * 2) { | 343 | if (secs < TM_MONTH * 2) { |
344 | htmlf("<span class='age-weeks'>%.0f weeks</span>", | 344 | htmlf("<span class='age-weeks'>%.0f weeks</span>", |
345 | secs * 1.0 / TM_WEEK); | 345 | secs * 1.0 / TM_WEEK); |
346 | return; | 346 | return; |
347 | } | 347 | } |
348 | if (secs < TM_YEAR * 2) { | 348 | if (secs < TM_YEAR * 2) { |
349 | htmlf("<span class='age-months'>%.0f months</span>", | 349 | htmlf("<span class='age-months'>%.0f months</span>", |
350 | secs * 1.0 / TM_MONTH); | 350 | secs * 1.0 / TM_MONTH); |
351 | return; | 351 | return; |
352 | } | 352 | } |
353 | htmlf("<span class='age-years'>%.0f years</span>", | 353 | htmlf("<span class='age-years'>%.0f years</span>", |
354 | secs * 1.0 / TM_YEAR); | 354 | secs * 1.0 / TM_YEAR); |
355 | } | 355 | } |
356 | 356 | ||
357 | void cgit_print_http_headers(struct cgit_context *ctx) | 357 | void cgit_print_http_headers(struct cgit_context *ctx) |
358 | { | 358 | { |
359 | if (ctx->page.mimetype && ctx->page.charset) | 359 | if (ctx->page.mimetype && ctx->page.charset) |
360 | htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype, | 360 | htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype, |
361 | ctx->page.charset); | 361 | ctx->page.charset); |
362 | else if (ctx->page.mimetype) | 362 | else if (ctx->page.mimetype) |
363 | htmlf("Content-Type: %s\n", ctx->page.mimetype); | 363 | htmlf("Content-Type: %s\n", ctx->page.mimetype); |
364 | if (ctx->page.filename) | 364 | if (ctx->page.filename) |
365 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", | 365 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", |
366 | ctx->page.filename); | 366 | ctx->page.filename); |
367 | htmlf("Last-Modified: %s\n", http_date(ctx->page.modified)); | 367 | htmlf("Last-Modified: %s\n", http_date(ctx->page.modified)); |
368 | htmlf("Expires: %s\n", http_date(ctx->page.expires)); | 368 | htmlf("Expires: %s\n", http_date(ctx->page.expires)); |
369 | html("\n"); | 369 | html("\n"); |
370 | } | 370 | } |
371 | 371 | ||
372 | void cgit_print_docstart(struct cgit_context *ctx) | 372 | void cgit_print_docstart(struct cgit_context *ctx) |
373 | { | 373 | { |
374 | html(cgit_doctype); | 374 | html(cgit_doctype); |
375 | html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"); | 375 | html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"); |
376 | html("<head>\n"); | 376 | html("<head>\n"); |
377 | html("<title>"); | 377 | html("<title>"); |
378 | html_txt(ctx->page.title); | 378 | html_txt(ctx->page.title); |
379 | html("</title>\n"); | 379 | html("</title>\n"); |
380 | htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); | 380 | htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); |
381 | if (ctx->cfg.robots && *ctx->cfg.robots) | 381 | if (ctx->cfg.robots && *ctx->cfg.robots) |
382 | htmlf("<meta name='robots' content='%s'/>\n", ctx->cfg.robots); | 382 | htmlf("<meta name='robots' content='%s'/>\n", ctx->cfg.robots); |
383 | html("<link rel='stylesheet' type='text/css' href='"); | 383 | html("<link rel='stylesheet' type='text/css' href='"); |
384 | html_attr(ctx->cfg.css); | 384 | html_attr(ctx->cfg.css); |
385 | html("'/>\n"); | 385 | html("'/>\n"); |
386 | html("</head>\n"); | 386 | html("</head>\n"); |
387 | html("<body>\n"); | 387 | html("<body>\n"); |
388 | } | 388 | } |
389 | 389 | ||
390 | void cgit_print_docend() | 390 | void cgit_print_docend() |
391 | { | 391 | { |
392 | html("</td>\n</tr>\n</table>\n</body>\n</html>\n"); | 392 | html("</div>\n</body>\n</html>\n"); |
393 | } | 393 | } |
394 | 394 | ||
395 | int print_branch_option(const char *refname, const unsigned char *sha1, | 395 | int print_branch_option(const char *refname, const unsigned char *sha1, |
396 | int flags, void *cb_data) | 396 | int flags, void *cb_data) |
397 | { | 397 | { |
398 | char *name = (char *)refname; | 398 | char *name = (char *)refname; |
399 | html_option(name, name, ctx.qry.head); | 399 | html_option(name, name, ctx.qry.head); |
400 | return 0; | 400 | return 0; |
401 | } | 401 | } |
402 | 402 | ||
403 | int print_archive_ref(const char *refname, const unsigned char *sha1, | 403 | int print_archive_ref(const char *refname, const unsigned char *sha1, |
404 | int flags, void *cb_data) | 404 | int flags, void *cb_data) |
405 | { | 405 | { |
406 | struct tag *tag; | 406 | struct tag *tag; |
407 | struct taginfo *info; | 407 | struct taginfo *info; |
408 | struct object *obj; | 408 | struct object *obj; |
409 | char buf[256], *url; | 409 | char buf[256], *url; |
410 | unsigned char fileid[20]; | 410 | unsigned char fileid[20]; |
411 | int *header = (int *)cb_data; | 411 | int *header = (int *)cb_data; |
412 | 412 | ||
413 | if (prefixcmp(refname, "refs/archives")) | 413 | if (prefixcmp(refname, "refs/archives")) |
414 | return 0; | 414 | return 0; |
415 | strncpy(buf, refname+14, sizeof(buf)); | 415 | strncpy(buf, refname+14, sizeof(buf)); |
416 | obj = parse_object(sha1); | 416 | obj = parse_object(sha1); |
417 | if (!obj) | 417 | if (!obj) |
418 | return 1; | 418 | return 1; |
419 | if (obj->type == OBJ_TAG) { | 419 | if (obj->type == OBJ_TAG) { |
420 | tag = lookup_tag(sha1); | 420 | tag = lookup_tag(sha1); |
421 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) | 421 | if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) |
422 | return 0; | 422 | return 0; |
423 | hashcpy(fileid, tag->tagged->sha1); | 423 | hashcpy(fileid, tag->tagged->sha1); |
424 | } else if (obj->type != OBJ_BLOB) { | 424 | } else if (obj->type != OBJ_BLOB) { |
425 | return 0; | 425 | return 0; |
426 | } else { | 426 | } else { |
427 | hashcpy(fileid, sha1); | 427 | hashcpy(fileid, sha1); |
428 | } | 428 | } |
429 | if (!*header) { | 429 | if (!*header) { |
430 | html("<h1>download</h1>\n"); | 430 | html("<h1>download</h1>\n"); |
431 | *header = 1; | 431 | *header = 1; |
432 | } | 432 | } |
433 | url = cgit_pageurl(ctx.qry.repo, "blob", | 433 | url = cgit_pageurl(ctx.qry.repo, "blob", |
434 | fmt("id=%s&path=%s", sha1_to_hex(fileid), | 434 | fmt("id=%s&path=%s", sha1_to_hex(fileid), |
435 | buf)); | 435 | buf)); |
436 | html_link_open(url, NULL, "menu"); | 436 | html_link_open(url, NULL, "menu"); |
437 | html_txt(strlpart(buf, 20)); | 437 | html_txt(strlpart(buf, 20)); |
438 | html_link_close(); | 438 | html_link_close(); |
439 | return 0; | 439 | return 0; |
440 | } | 440 | } |
441 | 441 | ||
442 | void add_hidden_formfields(int incl_head, int incl_search, char *page) | 442 | void add_hidden_formfields(int incl_head, int incl_search, char *page) |
443 | { | 443 | { |
444 | char *url; | 444 | char *url; |
445 | 445 | ||
446 | if (!ctx.cfg.virtual_root) { | 446 | if (!ctx.cfg.virtual_root) { |
447 | url = fmt("%s/%s", ctx.qry.repo, page); | 447 | url = fmt("%s/%s", ctx.qry.repo, page); |
448 | if (ctx.qry.path) | 448 | if (ctx.qry.path) |
449 | url = fmt("%s/%s", url, ctx.qry.path); | 449 | url = fmt("%s/%s", url, ctx.qry.path); |
450 | html_hidden("url", url); | 450 | html_hidden("url", url); |
451 | } | 451 | } |
452 | 452 | ||
453 | if (incl_head && strcmp(ctx.qry.head, ctx.repo->defbranch)) | 453 | if (incl_head && strcmp(ctx.qry.head, ctx.repo->defbranch)) |
454 | html_hidden("h", ctx.qry.head); | 454 | html_hidden("h", ctx.qry.head); |
455 | 455 | ||
456 | if (ctx.qry.sha1) | 456 | if (ctx.qry.sha1) |
457 | html_hidden("id", ctx.qry.sha1); | 457 | html_hidden("id", ctx.qry.sha1); |
458 | if (ctx.qry.sha2) | 458 | if (ctx.qry.sha2) |
459 | html_hidden("id2", ctx.qry.sha2); | 459 | html_hidden("id2", ctx.qry.sha2); |
460 | 460 | ||
461 | if (incl_search) { | 461 | if (incl_search) { |
462 | if (ctx.qry.grep) | 462 | if (ctx.qry.grep) |
463 | html_hidden("qt", ctx.qry.grep); | 463 | html_hidden("qt", ctx.qry.grep); |
464 | if (ctx.qry.search) | 464 | if (ctx.qry.search) |
465 | html_hidden("q", ctx.qry.search); | 465 | html_hidden("q", ctx.qry.search); |
466 | } | 466 | } |
467 | } | 467 | } |
468 | 468 | ||
469 | char *hc(struct cgit_cmd *cmd, const char *page) | 469 | char *hc(struct cgit_cmd *cmd, const char *page) |
470 | { | 470 | { |
471 | return (strcmp(cmd->name, page) ? NULL : "active"); | 471 | return (strcmp(cmd->name, page) ? NULL : "active"); |
472 | } | 472 | } |
473 | 473 | ||
474 | void cgit_print_pageheader(struct cgit_context *ctx) | 474 | void cgit_print_pageheader(struct cgit_context *ctx) |
475 | { | 475 | { |
476 | struct cgit_cmd *cmd = cgit_get_cmd(ctx); | 476 | struct cgit_cmd *cmd = cgit_get_cmd(ctx); |
477 | 477 | ||
478 | html("<table id='header'>\n"); | 478 | html("<table id='header'>\n"); |
479 | html("<tr>\n"); | 479 | html("<tr>\n"); |
480 | html("<td class='logo' rowspan='2'><a href='"); | 480 | html("<td class='logo' rowspan='2'><a href='"); |
481 | if (ctx->cfg.logo_link) | 481 | if (ctx->cfg.logo_link) |
482 | html_attr(ctx->cfg.logo_link); | 482 | html_attr(ctx->cfg.logo_link); |
483 | else | 483 | else |
484 | html_attr(cgit_rooturl()); | 484 | html_attr(cgit_rooturl()); |
485 | html("'><img src='"); | 485 | html("'><img src='"); |
486 | html_attr(ctx->cfg.logo); | 486 | html_attr(ctx->cfg.logo); |
487 | html("'/></a></td>\n"); | 487 | html("'/></a></td>\n"); |
488 | |||
488 | html("<td class='main'>"); | 489 | html("<td class='main'>"); |
489 | if (ctx->repo) { | 490 | if (ctx->repo) { |
491 | /* | ||
490 | html("<a href='"); | 492 | html("<a href='"); |
491 | html_attr(cgit_rooturl()); | 493 | html_attr(cgit_rooturl()); |
492 | html("'>index</a> / "); | 494 | html("'>index</a> : "); |
493 | html_txt(ctx->repo->name); | 495 | */ |
496 | reporevlink(NULL, ctx->repo->name, NULL, hc(cmd, "summary"), | ||
497 | ctx->qry.head, NULL, NULL); | ||
498 | html(" : "); | ||
499 | html_txt(ctx->qry.page); | ||
500 | html("</td><td class='form'>"); | ||
501 | html("<form method='get' action=''>\n"); | ||
502 | add_hidden_formfields(0, 1, ctx->qry.page); | ||
503 | html("<select name='h' onchange='this.form.submit();'>\n"); | ||
504 | for_each_branch_ref(print_branch_option, ctx->qry.head); | ||
505 | html("</select> "); | ||
506 | html("<input type='submit' name='' value='switch'/>"); | ||
507 | html("</form>"); | ||
494 | } else | 508 | } else |
495 | html_txt(ctx->cfg.root_title); | 509 | html_txt(ctx->cfg.root_title); |
496 | html("</td></tr>\n"); | 510 | html("</td>\n"); |
497 | html("<tr><td class='sub'>"); | 511 | |
498 | if (ctx->repo) | 512 | html("<tr><td class='sub'"); |
513 | if (ctx->repo) { | ||
514 | html(" colspan='2'>"); | ||
499 | html_txt(ctx->repo->desc); | 515 | html_txt(ctx->repo->desc); |
500 | else | 516 | } |
501 | html_txt(ctx->cfg.index_info); | 517 | /* |
518 | else if (ctx->cfg.root_subtitle) | ||
519 | html_txt(ctx->cfg.root_subtitle); | ||
520 | */ | ||
521 | else { | ||
522 | html(">"); | ||
523 | html_txt("a fast webinterface for the git dscm"); | ||
524 | } | ||
502 | html("</td></tr>\n"); | 525 | html("</td></tr>\n"); |
526 | |||
527 | html("</tr>\n"); | ||
503 | html("</table>\n"); | 528 | html("</table>\n"); |
504 | 529 | ||
505 | html("<table class='tabs'><tr><td>\n"); | 530 | html("<table class='tabs'><tr><td>\n"); |
506 | if (ctx->repo) { | 531 | if (ctx->repo) { |
507 | reporevlink(NULL, "summary", NULL, hc(cmd, "summary"), | 532 | reporevlink(NULL, "summary", NULL, hc(cmd, "summary"), |
508 | ctx->qry.head, NULL, NULL); | 533 | ctx->qry.head, NULL, NULL); |
509 | cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head, | 534 | cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head, |
510 | ctx->qry.sha1, NULL); | 535 | ctx->qry.sha1, NULL); |
511 | cgit_log_link("log", NULL, hc(cmd, "log"), ctx->qry.head, | 536 | cgit_log_link("log", NULL, hc(cmd, "log"), ctx->qry.head, |
512 | NULL, NULL, 0, NULL, NULL); | 537 | NULL, NULL, 0, NULL, NULL); |
513 | cgit_tree_link("tree", NULL, hc(cmd, "tree"), ctx->qry.head, | 538 | cgit_tree_link("tree", NULL, hc(cmd, "tree"), ctx->qry.head, |
514 | ctx->qry.sha1, NULL); | 539 | ctx->qry.sha1, NULL); |
515 | cgit_commit_link("commit", NULL, hc(cmd, "commit"), | 540 | cgit_commit_link("commit", NULL, hc(cmd, "commit"), |
516 | ctx->qry.head, ctx->qry.sha1); | 541 | ctx->qry.head, ctx->qry.sha1); |
517 | cgit_diff_link("diff", NULL, hc(cmd, "diff"), ctx->qry.head, | 542 | cgit_diff_link("diff", NULL, hc(cmd, "diff"), ctx->qry.head, |
518 | ctx->qry.sha1, ctx->qry.sha2, NULL); | 543 | ctx->qry.sha1, ctx->qry.sha2, NULL); |
519 | cgit_patch_link("patch", NULL, hc(cmd, "patch"), ctx->qry.head, | 544 | cgit_patch_link("patch", NULL, hc(cmd, "patch"), ctx->qry.head, |
520 | ctx->qry.sha1); | 545 | ctx->qry.sha1); |
521 | html("</td><td class='branch'>"); | 546 | html("</td><td class='form'>"); |
522 | html("<form method='get' action=''>\n"); | 547 | html("<form class='right' method='get' action='"); |
523 | add_hidden_formfields(0, 1, ctx->qry.page); | 548 | if (ctx->cfg.virtual_root) |
524 | html("<select name='h' onchange='this.form.submit();'>\n"); | 549 | html_attr(cgit_fileurl(ctx->qry.repo, "log", |
525 | for_each_branch_ref(print_branch_option, ctx->qry.head); | 550 | ctx->qry.path, NULL)); |
526 | html("</select> "); | 551 | html("'>\n"); |
527 | html("<input type='submit' name='' value='switch'/>"); | 552 | add_hidden_formfields(1, 0, "log"); |
553 | html("<select name='qt'>\n"); | ||
554 | html_option("grep", "log msg", ctx->qry.grep); | ||
555 | html_option("author", "author", ctx->qry.grep); | ||
556 | html_option("committer", "committer", ctx->qry.grep); | ||
557 | html("</select>\n"); | ||
558 | html("<input class='txt' type='text' size='8' name='q' value='"); | ||
559 | html_attr(ctx->qry.search); | ||
560 | html("'/>\n"); | ||
561 | html("<input type='submit' value='search'/>\n"); | ||
562 | html("</form>\n"); | ||
528 | } else { | 563 | } else { |
529 | html("<a class='active' href='"); | 564 | html("<a class='active' href='"); |
530 | html_attr(cgit_rooturl()); | 565 | html_attr(cgit_rooturl()); |
531 | html("'>index</a>\n"); | 566 | html("'>index</a>\n"); |
532 | } | 567 | } |
533 | html("</td></tr></table>\n"); | 568 | html("</td></tr></table>\n"); |
534 | html("<div class='content'>"); | 569 | html("<div class='content'>"); |
535 | } | 570 | } |
536 | 571 | ||
537 | void cgit_print_filemode(unsigned short mode) | 572 | void cgit_print_filemode(unsigned short mode) |
538 | { | 573 | { |
539 | if (S_ISDIR(mode)) | 574 | if (S_ISDIR(mode)) |
540 | html("d"); | 575 | html("d"); |
541 | else if (S_ISLNK(mode)) | 576 | else if (S_ISLNK(mode)) |
542 | html("l"); | 577 | html("l"); |
543 | else if (S_ISGITLINK(mode)) | 578 | else if (S_ISGITLINK(mode)) |
544 | html("m"); | 579 | html("m"); |
545 | else | 580 | else |
546 | html("-"); | 581 | html("-"); |
547 | html_fileperm(mode >> 6); | 582 | html_fileperm(mode >> 6); |
548 | html_fileperm(mode >> 3); | 583 | html_fileperm(mode >> 3); |
549 | html_fileperm(mode); | 584 | html_fileperm(mode); |
550 | } | 585 | } |
551 | 586 | ||
552 | void cgit_print_snapshot_links(const char *repo, const char *head, | 587 | void cgit_print_snapshot_links(const char *repo, const char *head, |
553 | const char *hex, int snapshots) | 588 | const char *hex, int snapshots) |
554 | { | 589 | { |
555 | const struct cgit_snapshot_format* f; | 590 | const struct cgit_snapshot_format* f; |
556 | char *filename; | 591 | char *filename; |
557 | 592 | ||
558 | for (f = cgit_snapshot_formats; f->suffix; f++) { | 593 | for (f = cgit_snapshot_formats; f->suffix; f++) { |
559 | if (!(snapshots & f->bit)) | 594 | if (!(snapshots & f->bit)) |
560 | continue; | 595 | continue; |
561 | filename = fmt("%s-%s%s", cgit_repobasename(repo), hex, | 596 | filename = fmt("%s-%s%s", cgit_repobasename(repo), hex, |
562 | f->suffix); | 597 | f->suffix); |
563 | cgit_snapshot_link(filename, NULL, NULL, (char *)head, | 598 | cgit_snapshot_link(filename, NULL, NULL, (char *)head, |
564 | (char *)hex, filename); | 599 | (char *)hex, filename); |
565 | html("<br/>"); | 600 | html("<br/>"); |
566 | } | 601 | } |
567 | } | 602 | } |