-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | cgit.c | 2 | ||||
-rw-r--r-- | cgit.css | 50 | ||||
-rw-r--r-- | cgit.h | 5 | ||||
-rw-r--r-- | parsing.c | 1 | ||||
-rw-r--r-- | ui-commit.c | 80 | ||||
-rw-r--r-- | ui-log.c | 11 | ||||
-rw-r--r-- | ui-tree.c | 6 | ||||
-rw-r--r-- | ui-view.c | 2 |
9 files changed, 140 insertions, 19 deletions
@@ -8,3 +8,3 @@ EXTLIBS = ../git/libgit.a ../git/xdiff/lib.a -lz -lcrypto | |||
8 | OBJECTS = shared.o cache.o parsing.o html.o ui-shared.o ui-repolist.o \ | 8 | OBJECTS = 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 | ||
@@ -34,2 +34,4 @@ static void cgit_print_repo_page(struct cacheitem *item) | |||
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")) { |
@@ -23,3 +23,2 @@ table.list { | |||
23 | table.list th { | 23 | table.list th { |
24 | text-align: left; | ||
25 | font-weight: bold; | 24 | font-weight: bold; |
@@ -27,3 +26,3 @@ table.list th { | |||
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; |
@@ -32,3 +31,3 @@ table.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; |
@@ -58,2 +57,6 @@ div#content { | |||
58 | 57 | ||
58 | div#blob { | ||
59 | border: solid 1px black; | ||
60 | } | ||
61 | |||
59 | div.error { | 62 | div.error { |
@@ -77,2 +80,41 @@ td.blob { | |||
77 | font-size: 100%; | 80 | font-size: 100%; |
78 | } \ No newline at end of file | 81 | } |
82 | |||
83 | table.log td { | ||
84 | white-space: nowrap; | ||
85 | } | ||
86 | |||
87 | table.commit-info { | ||
88 | border-collapse: collapse; | ||
89 | margin-top: 1em; | ||
90 | |||
91 | } | ||
92 | table.commit-info th { | ||
93 | text-align: left; | ||
94 | font-weight: normal; | ||
95 | padding: 0.1em 1em 0.1em 0.1em; | ||
96 | } | ||
97 | table.commit-info td { | ||
98 | font-weight: normal; | ||
99 | padding: 0.1em 1em 0.1em 0.1em; | ||
100 | } | ||
101 | div.commit-subject { | ||
102 | font-weight: bold; | ||
103 | font-size: 110%; | ||
104 | margin: 1em 0em 1em; | ||
105 | } | ||
106 | div.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 | } | ||
@@ -94,4 +94,5 @@ extern void cgit_print_summary(); | |||
94 | extern void cgit_print_log(const char *tip, int ofs, int cnt); | 94 | extern void cgit_print_log(const char *tip, int ofs, int cnt); |
95 | extern void cgit_print_view(char *hex); | 95 | extern void cgit_print_view(const char *hex); |
96 | extern void cgit_print_tree(const char *sha1); | 96 | extern void cgit_print_tree(const char *hex); |
97 | extern void cgit_print_commit(const char *hex); | ||
97 | 98 | ||
@@ -152,2 +152,3 @@ struct commitinfo *cgit_parse_commit(struct commit *commit) | |||
152 | ret->subject = substr(p, t); | 152 | ret->subject = substr(p, t); |
153 | p = t + 1; | ||
153 | 154 | ||
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 | |||
3 | void 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 | |||
14 | void 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 | } | ||
@@ -23,3 +23,3 @@ void print_commit(struct commit *commit) | |||
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); |
@@ -29,7 +29,2 @@ void print_commit(struct commit *commit) | |||
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"); |
@@ -58,4 +53,4 @@ void cgit_print_log(const char *tip, int ofs, int cnt) | |||
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 | ||
@@ -64,5 +64,5 @@ void cgit_print_tree(const char *hex) | |||
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); |
@@ -10,3 +10,3 @@ | |||
10 | 10 | ||
11 | void cgit_print_view(char *hex) | 11 | void cgit_print_view(const char *hex) |
12 | { | 12 | { |