summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--Makefile2
-rw-r--r--cgit.c2
-rw-r--r--cgit.css50
-rw-r--r--cgit.h5
-rw-r--r--parsing.c1
-rw-r--r--ui-commit.c80
-rw-r--r--ui-log.c11
-rw-r--r--ui-tree.c6
-rw-r--r--ui-view.c2
9 files changed, 140 insertions, 19 deletions
diff --git a/Makefile b/Makefile
index 2a4d62a..58a583b 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ CACHE_ROOT = /var/cache/cgit
6 6
7EXTLIBS = ../git/libgit.a ../git/xdiff/lib.a -lz -lcrypto 7EXTLIBS = ../git/libgit.a ../git/xdiff/lib.a -lz -lcrypto
8OBJECTS = shared.o cache.o parsing.o html.o ui-shared.o ui-repolist.o \ 8OBJECTS = shared.o cache.o parsing.o html.o ui-shared.o ui-repolist.o \
9 ui-summary.o ui-log.o ui-view.c ui-tree.c 9 ui-summary.o ui-log.o ui-view.c ui-tree.c ui-commit.c
10 10
11CFLAGS += -Wall 11CFLAGS += -Wall
12 12
diff --git a/cgit.c b/cgit.c
index d7e586d..37cdb83 100644
--- a/cgit.c
+++ b/cgit.c
@@ -32,6 +32,8 @@ static void cgit_print_repo_page(struct cacheitem *item)
32 cgit_print_log(cgit_query_head, cgit_query_ofs, 100); 32 cgit_print_log(cgit_query_head, cgit_query_ofs, 100);
33 } else if (!strcmp(cgit_query_page, "tree")) { 33 } else if (!strcmp(cgit_query_page, "tree")) {
34 cgit_print_tree(cgit_query_sha1); 34 cgit_print_tree(cgit_query_sha1);
35 } else if (!strcmp(cgit_query_page, "commit")) {
36 cgit_print_commit(cgit_query_sha1);
35 } else if (!strcmp(cgit_query_page, "view")) { 37 } else if (!strcmp(cgit_query_page, "view")) {
36 cgit_print_view(cgit_query_sha1); 38 cgit_print_view(cgit_query_sha1);
37 } 39 }
diff --git a/cgit.css b/cgit.css
index 97b4e27..3579598 100644
--- a/cgit.css
+++ b/cgit.css
@@ -21,16 +21,15 @@ table.list {
21} 21}
22 22
23table.list th { 23table.list th {
24 text-align: left;
25 font-weight: bold; 24 font-weight: bold;
26 background: #ddd; 25 background: #ddd;
27 border-bottom: solid 1px #aaa; 26 border-bottom: solid 1px #aaa;
28 padding: 0.1em 0.5em 0.1em; 27 padding: 0.1em 0.5em 0.1em 0.5em;
29 vertical-align: baseline; 28 vertical-align: baseline;
30} 29}
31table.list td { 30table.list td {
32 border: none; 31 border: none;
33 padding: 0.1em 1em 0.1em 0.5em; 32 padding: 0.1em 0.5em 0.1em 0.5em;
34 background: white; 33 background: white;
35} 34}
36 35
@@ -56,6 +55,10 @@ div#content {
56 margin: 0.5em 0.5em; 55 margin: 0.5em 0.5em;
57} 56}
58 57
58div#blob {
59 border: solid 1px black;
60}
61
59div.error { 62div.error {
60 color: red; 63 color: red;
61 font-weight: bold; 64 font-weight: bold;
@@ -75,4 +78,43 @@ td.blob {
75 white-space: pre; 78 white-space: pre;
76 font-family: courier; 79 font-family: courier;
77 font-size: 100%; 80 font-size: 100%;
78} \ No newline at end of file 81}
82
83table.log td {
84 white-space: nowrap;
85}
86
87table.commit-info {
88 border-collapse: collapse;
89 margin-top: 1em;
90
91}
92table.commit-info th {
93 text-align: left;
94 font-weight: normal;
95 padding: 0.1em 1em 0.1em 0.1em;
96}
97table.commit-info td {
98 font-weight: normal;
99 padding: 0.1em 1em 0.1em 0.1em;
100}
101div.commit-subject {
102 font-weight: bold;
103 font-size: 110%;
104 margin: 1em 0em 1em;
105}
106div.commit-msg {
107 white-space: pre;
108 font-family: courier;
109 font-size: 100%;
110}
111.sha1 {
112 font-family: courier;
113 font-size: 90%;
114}
115.left {
116 text-align: left;
117}
118.right {
119 text-align: right;
120}
diff --git a/cgit.h b/cgit.h
index 268db53..a905e47 100644
--- a/cgit.h
+++ b/cgit.h
@@ -92,7 +92,8 @@ extern void cgit_print_pageheader(char *title);
92extern void cgit_print_repolist(struct cacheitem *item); 92extern void cgit_print_repolist(struct cacheitem *item);
93extern void cgit_print_summary(); 93extern void cgit_print_summary();
94extern void cgit_print_log(const char *tip, int ofs, int cnt); 94extern void cgit_print_log(const char *tip, int ofs, int cnt);
95extern void cgit_print_view(char *hex); 95extern void cgit_print_view(const char *hex);
96extern void cgit_print_tree(const char *sha1); 96extern void cgit_print_tree(const char *hex);
97extern void cgit_print_commit(const char *hex);
97 98
98#endif /* CGIT_H */ 99#endif /* CGIT_H */
diff --git a/parsing.c b/parsing.c
index 6cab0e9..be471b5 100644
--- a/parsing.c
+++ b/parsing.c
@@ -150,6 +150,7 @@ struct commitinfo *cgit_parse_commit(struct commit *commit)
150 150
151 t = strchr(p, '\n'); 151 t = strchr(p, '\n');
152 ret->subject = substr(p, t); 152 ret->subject = substr(p, t);
153 p = t + 1;
153 154
154 while (*p == '\n') 155 while (*p == '\n')
155 p = strchr(p, '\n') + 1; 156 p = strchr(p, '\n') + 1;
diff --git a/ui-commit.c b/ui-commit.c
new file mode 100644
index 0000000..1c0e7e5
--- a/dev/null
+++ b/ui-commit.c
@@ -0,0 +1,80 @@
1#include "cgit.h"
2
3void cgit_print_date(unsigned long secs)
4{
5 char buf[32];
6 struct tm *time;
7
8 time = gmtime(&secs);
9 strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", time);
10 html_txt(buf);
11
12}
13
14void cgit_print_commit(const char *hex)
15{
16 struct commit *commit;
17 struct commitinfo *info;
18 struct commit_list *p;
19 unsigned long size;
20 char type[20];
21 char *buf;
22
23 unsigned char sha1[20];
24
25 if (get_sha1(hex, sha1)) {
26 cgit_print_error(fmt("Bad object id: %s", hex));
27 return;
28 }
29
30 buf = read_sha1_file(sha1, type, &size);
31 if (!buf) {
32 cgit_print_error(fmt("Bad object reference: %s", hex));
33 return;
34 }
35
36 commit = lookup_commit(sha1);
37 if (!commit) {
38 cgit_print_error(fmt("Bad commit reference: %s", hex));
39 return;
40 }
41
42 commit->buffer = buf;
43 if (parse_commit_buffer(commit, buf, size)) {
44 cgit_print_error(fmt("Malformed commit buffer: %s", hex));
45 return;
46 }
47
48 info = cgit_parse_commit(commit);
49
50 html("<table class='commit-info'>\n");
51 html("<tr><th>author</th><td colspan='2'>");
52 html_txt(info->author);
53 html("</td></tr>\n");
54 html("<tr><th>committer</th><td>");
55 html_txt(info->committer);
56 html("</td><td class='right'>");
57 cgit_print_date(commit->date);
58 html("</td></tr>\n");
59 html("<tr><th>tree</th><td colspan='2' class='sha1'><a href='");
60 html_attr(cgit_pageurl(cgit_query_repo, "tree", fmt("id=%s", sha1_to_hex(commit->tree->object.sha1))));
61 htmlf("'>%s</a></td></tr>\n", sha1_to_hex(commit->tree->object.sha1));
62
63 for (p = commit->parents; p ; p = p->next) {
64 html("<tr><th>parent</th><td colspan='2' class='sha1'><a href='");
65 html_attr(cgit_pageurl(cgit_query_repo, "commit", fmt("id=%s", sha1_to_hex(p->item->object.sha1))));
66 htmlf("'>%s</a></td></tr>\n",
67 sha1_to_hex(p->item->object.sha1));
68 }
69 html("</table>\n");
70 html("<div class='commit-subject'>");
71 html_txt(info->subject);
72 html("</div>");
73 html("<div class='commit-msg'>");
74 html_txt(info->msg);
75 html("</div>");
76 free(info->author);
77 free(info->committer);
78 free(info->subject);
79 free(info);
80}
diff --git a/ui-log.c b/ui-log.c
index 31331ef..c52af79 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -21,17 +21,12 @@ void print_commit(struct commit *commit)
21 html_txt(buf); 21 html_txt(buf);
22 html("</td><td>"); 22 html("</td><td>");
23 char *qry = fmt("id=%s", sha1_to_hex(commit->object.sha1)); 23 char *qry = fmt("id=%s", sha1_to_hex(commit->object.sha1));
24 char *url = cgit_pageurl(cgit_query_repo, "view", qry); 24 char *url = cgit_pageurl(cgit_query_repo, "commit", qry);
25 html_link_open(url, NULL, NULL); 25 html_link_open(url, NULL, NULL);
26 html_txt(info->subject); 26 html_txt(info->subject);
27 html_link_close(); 27 html_link_close();
28 html("</td><td>"); 28 html("</td><td>");
29 html_txt(info->author); 29 html_txt(info->author);
30 html("</td><td><a href='");
31 html_attr(cgit_pageurl(cgit_query_repo, "tree",
32 fmt("id=%s",
33 sha1_to_hex(commit->tree->object.sha1))));
34 html("'>tree</a>");
35 html("</td></tr>\n"); 30 html("</td></tr>\n");
36 free(info->author); 31 free(info->author);
37 free(info->committer); 32 free(info->committer);
@@ -56,8 +51,8 @@ void cgit_print_log(const char *tip, int ofs, int cnt)
56 prepare_revision_walk(&rev); 51 prepare_revision_walk(&rev);
57 52
58 html("<h2>Log</h2>"); 53 html("<h2>Log</h2>");
59 html("<table class='list'>"); 54 html("<table class='list log'>");
60 html("<tr><th>Date</th><th>Message</th><th>Author</th><th>Link</th></tr>\n"); 55 html("<tr><th class='left'>Date</th><th class='left'>Message</th><th class='left'>Author</th></tr>\n");
61 56
62 if (ofs<0) 57 if (ofs<0)
63 ofs = 0; 58 ofs = 0;
diff --git a/ui-tree.c b/ui-tree.c
index 84930cb..c4d75ab 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -62,9 +62,9 @@ void cgit_print_tree(const char *hex)
62 62
63 html("<h2>Tree content</h2>\n"); 63 html("<h2>Tree content</h2>\n");
64 html("<table class='list'>\n"); 64 html("<table class='list'>\n");
65 html("<tr><th>Name</th>"); 65 html("<tr><th class='left'>Name</th>");
66 html("<th class='filesize'>Size</th>"); 66 html("<th class='right'>Size</th>");
67 html("<th class='filemode'>Mode</th></tr>\n"); 67 html("<th class='right'>Mode</th></tr>\n");
68 read_tree_recursive(tree, "", 0, 1, NULL, print_entry); 68 read_tree_recursive(tree, "", 0, 1, NULL, print_entry);
69 html("</table>\n"); 69 html("</table>\n");
70} 70}
diff --git a/ui-view.c b/ui-view.c
index 9d13be1..b75ce9a 100644
--- a/ui-view.c
+++ b/ui-view.c
@@ -8,7 +8,7 @@
8 8
9#include "cgit.h" 9#include "cgit.h"
10 10
11void cgit_print_view(char *hex) 11void cgit_print_view(const char *hex)
12{ 12{
13 unsigned char sha1[20]; 13 unsigned char sha1[20];
14 char type[20]; 14 char type[20];