summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.css147
-rw-r--r--cgit.pngbin5406 -> 1840 bytes
-rw-r--r--ui-shared.c125
3 files changed, 97 insertions, 175 deletions
diff --git a/cgit.css b/cgit.css
index 17c2712..67cf48e 100644
--- a/cgit.css
+++ b/cgit.css
@@ -2,160 +2,119 @@ body, table {
2 padding: 0em; 2 padding: 0em;
3 margin: 0em; 3 margin: 0em;
4} 4}
5 5
6body { 6body {
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
14a {
15 color: blue;
16 text-decoration: none;
17}
18
19a:hover {
20 text-decoration: underline;
21}
22
14table { 23table {
15 border-collapse: collapse; 24 border-collapse: collapse;
16} 25}
17 26
18h2 { 27table#header {
19 font-size: 120%; 28 width: 100%;
20 font-weight: bold; 29 margin-bottom: 1em;
21 margin-top: 0em;
22 margin-bottom: 0.25em;
23} 30}
24 31
25h3 { 32table#header td.logo {
26 margin-top: 0em; 33 width: 96px;
27 font-size: 100%;
28 font-weight: normal;
29} 34}
30 35
31h4 { 36table#header td.main {
32 margin-top: 1.5em; 37 font-size: 200%;
33 margin-bottom: 0.1em;
34 font-size: 100%;
35 font-weight: bold;
36} 38}
37 39
38a { 40table#header td.sub {
39 color: #600; 41 color: #777;
40 text-decoration: none; 42 border-top: solid 1px #ccc;
41} 43}
42 44
43a:hover { 45table.tabs {
44 background-color: #ddd; 46 border-bottom: solid 2px #ccc;
45 text-decoration: none; 47 border-collapse: collapse;
48 margin-top: 2em;
49 margin-bottom: 1em;
50 width: 100%;
51}
52
53table.tabs td {
54 padding: 0px 0.5em;
55}
56
57table.tabs td a {
58 padding: 2px 1em;
59 color: #007;
60}
61
62table.tabs td a.active {
63 color: #000;
64 background-color: #ccc;
46} 65}
47 66
67div.content {
68 margin: 0px;
69 padding: 1em;
70}
71
72
48table.list { 73table.list {
74 width: 100%;
49 border: none; 75 border: none;
50 border-collapse: collapse; 76 border-collapse: collapse;
51} 77}
52 78
53table.list tr { 79table.list tr {
54 background: white; 80 background: white;
55} 81}
56 82
57table.list tr:hover { 83table.list tr:hover {
58 background: #f8f8f8; 84 background: #eee;
59} 85}
60 86
61table.list tr.nohover:hover { 87table.list tr.nohover:hover {
62 background: white; 88 background: white;
63} 89}
64 90
65table.list th { 91table.list th {
66 font-weight: bold; 92 font-weight: normal;
67 border-bottom: solid 1px #777; 93 border-bottom: solid 1px #ccc;
68 padding: 0.1em 0.5em 0.1em 0.5em; 94 padding: 0.1em 0.5em 0.1em 0.5em;
69 vertical-align: baseline; 95 vertical-align: baseline;
70} 96}
71 97
72table.list td { 98table.list td {
73 border: none; 99 border: none;
74 padding: 0.1em 0.5em 0.1em 0.5em; 100 padding: 0.1em 0.5em 0.1em 0.5em;
75} 101}
76 102
77img { 103table.list td a {
78 border: none; 104 color: black;
79} 105}
80 106
81table#layout { 107img {
82 border-collapse: collapse;
83 border: none; 108 border: none;
84 margin: 0px;
85}
86
87td#sidebar {
88 vertical-align: top;
89 width: 162px;
90 padding: 0px 0px 0px 0px;
91 margin: 0px;
92}
93
94td#sidebar table {
95 border-collapse: separate;
96 border-spacing: 0px;
97 margin: 0px;
98 padding: 0px;
99 background-color: #ccc;
100}
101
102td#sidebar table.sidebar td.sidebar {
103 padding: 4px;
104 border-top: solid 1px #eee;
105 border-left: solid 1px #eee;
106 border-right: solid 1px #aaa;
107 border-bottom: solid 1px #aaa;
108}
109
110div#logo {
111 margin: 0px;
112 padding: 4px 0px 4px 0px;
113 text-align: center;
114 background-color: #ccc;
115 border-top: solid 1px #eee;
116 border-left: solid 1px #eee;
117 border-right: solid 1px #aaa;
118 border-bottom: solid 1px #aaa;
119}
120
121td#sidebar h1 {
122 font-size: 10pt;
123 font-weight: bold;
124 margin: 8px 0px 0px 0px;
125}
126
127td#sidebar h1.first {
128 margin-top: 0px;
129}
130
131td#sidebar a.menu {
132 display: block;
133 background-color: #ccc;
134 padding: 0.1em 0.5em;
135 text-decoration: none;
136}
137
138td#sidebar a.menu:hover {
139 background-color: #bbb;
140 text-decoration: none;
141}
142
143td#sidebar select {
144 width: 100%;
145 margin: 2px 0px 0px 0px;
146}
147
148td#sidebar form {
149 text-align: right;
150} 109}
151 110
152input#switch-btn { 111input#switch-btn {
153 margin: 2px 0px 0px 0px; 112 margin: 2px 0px 0px 0px;
154} 113}
155 114
156td#sidebar input.txt { 115td#sidebar input.txt {
157 width: 100%; 116 width: 100%;
158 margin: 2px 0px 0px 0px; 117 margin: 2px 0px 0px 0px;
159} 118}
160 119
161table#grid { 120table#grid {
@@ -348,25 +307,25 @@ div.diffstat-summary {
348table.diff { 307table.diff {
349 width: 100%; 308 width: 100%;
350} 309}
351 310
352table.diff td { 311table.diff td {
353 font-family: monospace; 312 font-family: monospace;
354 white-space: pre; 313 white-space: pre;
355} 314}
356 315
357table.diff td div.head { 316table.diff td div.head {
358 font-weight: bold; 317 font-weight: bold;
359 margin-top: 1em; 318 margin-top: 1em;
360 background-color: #eee; 319 color: black;
361} 320}
362 321
363table.diff td div.hunk { 322table.diff td div.hunk {
364 color: #009; 323 color: #009;
365} 324}
366 325
367table.diff td div.add { 326table.diff td div.add {
368 color: green; 327 color: green;
369} 328}
370 329
371table.diff td div.del { 330table.diff td div.del {
372 color: red; 331 color: red;
diff --git a/cgit.png b/cgit.png
index 22f7e95..d7f70bc 100644
--- a/cgit.png
+++ b/cgit.png
Binary files differ
diff --git a/ui-shared.c b/ui-shared.c
index aa65988..7287956 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -1,21 +1,22 @@
1/* ui-shared.c: common web output functions 1/* ui-shared.c: common web output functions
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#include "cmd.h"
10#include "html.h" 11#include "html.h"
11 12
12const char cgit_doctype[] = 13const char cgit_doctype[] =
13"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n" 14"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n"
14" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"; 15" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
15 16
16static char *http_date(time_t t) 17static char *http_date(time_t t)
17{ 18{
18 static char day[][4] = 19 static char day[][4] =
19 {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; 20 {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
20 static char month[][4] = 21 static char month[][4] =
21 {"Jan", "Feb", "Mar", "Apr", "May", "Jun", 22 {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
@@ -456,115 +457,77 @@ void add_hidden_formfields(int incl_head, int incl_search, char *page)
456 html_hidden("id", ctx.qry.sha1); 457 html_hidden("id", ctx.qry.sha1);
457 if (ctx.qry.sha2) 458 if (ctx.qry.sha2)
458 html_hidden("id2", ctx.qry.sha2); 459 html_hidden("id2", ctx.qry.sha2);
459 460
460 if (incl_search) { 461 if (incl_search) {
461 if (ctx.qry.grep) 462 if (ctx.qry.grep)
462 html_hidden("qt", ctx.qry.grep); 463 html_hidden("qt", ctx.qry.grep);
463 if (ctx.qry.search) 464 if (ctx.qry.search)
464 html_hidden("q", ctx.qry.search); 465 html_hidden("q", ctx.qry.search);
465 } 466 }
466} 467}
467 468
469char *hc(struct cgit_cmd *cmd, const char *page)
470{
471 return (strcmp(cmd->name, page) ? NULL : "active");
472}
473
468void cgit_print_pageheader(struct cgit_context *ctx) 474void cgit_print_pageheader(struct cgit_context *ctx)
469{ 475{
470 static const char *default_info = "This is cgit, a fast webinterface for git repositories"; 476 struct cgit_cmd *cmd = cgit_get_cmd(ctx);
471 int header = 0;
472 char *url;
473 477
474 html("<table id='layout' summary=''>\n"); 478 html("<table id='header'>\n");
475 html("<tr><td id='sidebar'>\n"); 479 html("<tr>\n");
476 html("<table class='sidebar' cellspacing='0' summary=''>\n"); 480 html("<td class='logo' rowspan='2'><a href='");
477 html("<tr><td class='sidebar'>\n<a href='");
478 html_attr(cgit_rooturl()); 481 html_attr(cgit_rooturl());
479 htmlf("'><img src='%s' alt='cgit'/></a>\n", 482 html("'><img src='");
480 ctx->cfg.logo); 483 html_attr(ctx->cfg.logo);
481 html("</td></tr>\n<tr><td class='sidebar'>\n"); 484 html("'/></a></td>\n");
482 if (ctx->repo) { 485 html("<td class='main'>");
483 html("<h1 class='first'>"); 486 if (ctx->repo)
484 html_txt(strrpart(ctx->repo->name, 20)); 487 html_txt(ctx->repo->name);
485 html("</h1>\n"); 488 else
489 html_txt(ctx->cfg.root_title);
490 html("</td></tr>\n");
491 html("<tr><td class='sub'>");
492 if (ctx->repo)
486 html_txt(ctx->repo->desc); 493 html_txt(ctx->repo->desc);
487 if (ctx->repo->owner) { 494 else
488 html("<h1>owner</h1>\n"); 495 html_txt(ctx->cfg.index_info);
489 html_txt(ctx->repo->owner); 496 html("</td></tr>\n");
490 } 497 html("</table>\n");
491 html("<h1>navigate</h1>\n"); 498
492 reporevlink(NULL, "summary", NULL, "menu", ctx->qry.head, 499 html("<table class='tabs'><tr><td>\n");
493 NULL, NULL); 500 if (ctx->repo) {
494 cgit_log_link("log", NULL, "menu", ctx->qry.head, NULL, NULL, 501 reporevlink(NULL, "summary", NULL, hc(cmd, "summary"),
495 0, NULL, NULL); 502 ctx->qry.head, NULL, NULL);
496 cgit_tree_link("tree", NULL, "menu", ctx->qry.head, 503 cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head,
497 ctx->qry.sha1, NULL); 504 ctx->qry.sha1, NULL);
498 cgit_commit_link("commit", NULL, "menu", ctx->qry.head, 505 cgit_log_link("log", NULL, hc(cmd, "log"), ctx->qry.head,
499 ctx->qry.sha1); 506 NULL, NULL, 0, NULL, NULL);
500 cgit_diff_link("diff", NULL, "menu", ctx->qry.head, 507 cgit_tree_link("tree", NULL, hc(cmd, "tree"), ctx->qry.head,
508 ctx->qry.sha1, NULL);
509 cgit_commit_link("commit", NULL, hc(cmd, "commit"),
510 ctx->qry.head, ctx->qry.sha1);
511 cgit_diff_link("diff", NULL, hc(cmd, "diff"), ctx->qry.head,
501 ctx->qry.sha1, ctx->qry.sha2, NULL); 512 ctx->qry.sha1, ctx->qry.sha2, NULL);
502 cgit_patch_link("patch", NULL, "menu", ctx->qry.head, 513 cgit_patch_link("patch", NULL, hc(cmd, "patch"), ctx->qry.head,
503 ctx->qry.sha1); 514 ctx->qry.sha1);
504
505 for_each_ref(print_archive_ref, &header);
506
507 if (ctx->repo->clone_url || ctx->cfg.clone_prefix) {
508 html("<h1>clone</h1>\n");
509 if (ctx->repo->clone_url)
510 url = ctx->repo->clone_url;
511 else
512 url = fmt("%s%s", ctx->cfg.clone_prefix,
513 ctx->repo->url);
514 html("<a class='menu' href='");
515 html_attr(url);
516 html("' title='");
517 html_attr(url);
518 html("'>\n");
519 html_txt(strrpart(url, 20));
520 html("</a>\n");
521 }
522
523 html("<h1>branch</h1>\n");
524 html("<form method='get' action=''>\n");
525 add_hidden_formfields(0, 1, ctx->qry.page);
526 // html("<table summary='branch selector' class='grid'><tr><td id='branch-dropdown-cell'>");
527 html("<select name='h' onchange='this.form.submit();'>\n");
528 for_each_branch_ref(print_branch_option, ctx->qry.head);
529 html("</select>\n");
530 // html("</td><td>");
531 html("<noscript><input type='submit' id='switch-btn' value='switch'/></noscript>\n");
532 // html("</td></tr></table>");
533 html("</form>\n");
534
535 html("<h1>search</h1>\n");
536 html("<form method='get' action='");
537 if (ctx->cfg.virtual_root)
538 html_attr(cgit_fileurl(ctx->qry.repo, "log",
539 ctx->qry.path, NULL));
540 html("'>\n");
541 add_hidden_formfields(1, 0, "log");
542 html("<select name='qt'>\n");
543 html_option("grep", "log msg", ctx->qry.grep);
544 html_option("author", "author", ctx->qry.grep);
545 html_option("committer", "committer", ctx->qry.grep);
546 html("</select>\n");
547 html("<input class='txt' type='text' name='q' value='");
548 html_attr(ctx->qry.search);
549 html("'/>\n");
550 html("</form>\n");
551 } else { 515 } else {
552 if (!ctx->cfg.index_info || html_include(ctx->cfg.index_info)) 516 html("<a class='active' href='");
553 html(default_info); 517 html_attr(cgit_rooturl());
518 html("'>index</a>\n");
554 } 519 }
555 520 html("</td></tr></table>\n");
556 html("</td></tr></table></td>\n"); 521 html("<div class='content'>");
557
558 html("<td id='content'>\n");
559} 522}
560 523
561void cgit_print_filemode(unsigned short mode) 524void cgit_print_filemode(unsigned short mode)
562{ 525{
563 if (S_ISDIR(mode)) 526 if (S_ISDIR(mode))
564 html("d"); 527 html("d");
565 else if (S_ISLNK(mode)) 528 else if (S_ISLNK(mode))
566 html("l"); 529 html("l");
567 else if (S_ISGITLINK(mode)) 530 else if (S_ISGITLINK(mode))
568 html("m"); 531 html("m");
569 else 532 else
570 html("-"); 533 html("-");