author | Lars Hjemli <larsh@slaptop.hjemli.net> | 2007-01-27 23:39:26 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-01-27 23:52:41 (UTC) |
commit | 777faf7e509e1de2b795b2a326ff00c9bd799104 (patch) (unidiff) | |
tree | ccb440445caf46cbfa3d4bd21d743697f37a9876 | |
parent | 447025f62ccbbb6e038d42009368e28f3e162460 (diff) | |
download | cgit-777faf7e509e1de2b795b2a326ff00c9bd799104.zip cgit-777faf7e509e1de2b795b2a326ff00c9bd799104.tar.gz cgit-777faf7e509e1de2b795b2a326ff00c9bd799104.tar.bz2 |
Cleanup table listings
Make the output for <table class='list'> a bit nicer
Signed-off-by: Lars Hjemli <larsh@slaptop.hjemli.net>
-rw-r--r-- | cgit.css | 10 | ||||
-rw-r--r-- | ui-log.c | 2 | ||||
-rw-r--r-- | ui-repolist.c | 2 | ||||
-rw-r--r-- | ui-summary.c | 4 | ||||
-rw-r--r-- | ui-tree.c | 2 | ||||
-rw-r--r-- | ui-view.c | 2 |
6 files changed, 9 insertions, 13 deletions
@@ -1,200 +1,196 @@ | |||
1 | body { | 1 | body { |
2 | font-family: arial; | 2 | font-family: arial; |
3 | font-size: normal; | 3 | font-size: normal; |
4 | background: white; | 4 | background: white; |
5 | padding: 0em; | 5 | padding: 0em; |
6 | margin: 0.5em 1em; | 6 | margin: 0.5em 1em; |
7 | } | 7 | } |
8 | 8 | ||
9 | 9 | ||
10 | h2 { | 10 | h2 { |
11 | font-size: 120%; | 11 | font-size: 120%; |
12 | font-weight: bold; | 12 | font-weight: bold; |
13 | margin-bottom: 0.5em; | 13 | margin-bottom: 0.5em; |
14 | } | 14 | } |
15 | 15 | ||
16 | a { | 16 | a { |
17 | color: blue; | 17 | color: blue; |
18 | text-decoration: none; | 18 | text-decoration: none; |
19 | } | 19 | } |
20 | 20 | ||
21 | a:hover { | 21 | a:hover { |
22 | text-decoration: underline; | 22 | text-decoration: underline; |
23 | } | 23 | } |
24 | 24 | ||
25 | table.list { | 25 | table.list { |
26 | border: solid 1px black; | 26 | border: none; |
27 | border-collapse: collapse; | 27 | border-collapse: collapse; |
28 | border: solid 1px #aaa; | ||
29 | } | 28 | } |
30 | table.list tr { | 29 | table.list tr { |
31 | background: white; | 30 | background: white; |
32 | } | 31 | } |
33 | table.list tr:hover { | 32 | table.list tr:hover { |
34 | background: #eeb; | 33 | background: #eee; |
35 | } | 34 | } |
36 | table.list tr.nohover:hover { | 35 | table.list tr.nohover:hover { |
37 | background: white; | 36 | background: white; |
38 | } | 37 | } |
39 | table.list th { | 38 | table.list th { |
40 | font-weight: normal; | 39 | font-weight: normal; |
41 | background: #ddd; | 40 | border-bottom: solid 1px #777; |
42 | border-top: solid 1px #aaa; | ||
43 | border-bottom: solid 1px #aaa; | ||
44 | padding: 0.1em 0.5em 0.1em 0.5em; | 41 | padding: 0.1em 0.5em 0.1em 0.5em; |
45 | vertical-align: baseline; | 42 | vertical-align: baseline; |
46 | } | 43 | } |
47 | table.list td { | 44 | table.list td { |
48 | border: none; | 45 | border: none; |
49 | padding: 0.1em 0.5em 0.1em 0.5em; | 46 | padding: 0.1em 0.5em 0.1em 0.5em; |
50 | } | 47 | } |
51 | img { | 48 | img { |
52 | border: none; | 49 | border: none; |
53 | } | 50 | } |
54 | 51 | ||
55 | |||
56 | div#header { | 52 | div#header { |
57 | background-color: #ddd; | 53 | background-color: #ddd; |
58 | padding: 0.25em 0.25em 0.25em 0.5em; | 54 | padding: 0.25em 0.25em 0.25em 0.5em; |
59 | font-size: 150%; | 55 | font-size: 150%; |
60 | font-weight: bold; | 56 | font-weight: bold; |
61 | border: solid 1px #aaa; | 57 | border: solid 1px #aaa; |
62 | vertical-align: middle; | 58 | vertical-align: middle; |
63 | margin-bottom: 2em; | 59 | margin-bottom: 2em; |
64 | } | 60 | } |
65 | div#header img#logo { | 61 | div#header img#logo { |
66 | float: right; | 62 | float: right; |
67 | } | 63 | } |
68 | 64 | ||
69 | div#header input { | 65 | div#header input { |
70 | float: right; | 66 | float: right; |
71 | margin: 0.25em 1em; | 67 | margin: 0.25em 1em; |
72 | } | 68 | } |
73 | div#header a { | 69 | div#header a { |
74 | color: black; | 70 | color: black; |
75 | } | 71 | } |
76 | 72 | ||
77 | div#content { | 73 | div#content { |
78 | margin: 0.5em 0.5em; | 74 | margin: 0.5em 0.5em; |
79 | } | 75 | } |
80 | 76 | ||
81 | div#blob { | 77 | div#blob { |
82 | border: solid 1px black; | 78 | border: solid 1px black; |
83 | } | 79 | } |
84 | 80 | ||
85 | div.error { | 81 | div.error { |
86 | color: red; | 82 | color: red; |
87 | font-weight: bold; | 83 | font-weight: bold; |
88 | margin: 1em 2em; | 84 | margin: 1em 2em; |
89 | } | 85 | } |
90 | div.ls-blob, div.ls-dir { | 86 | div.ls-blob, div.ls-dir { |
91 | font-family: monospace; | 87 | font-family: monospace; |
92 | } | 88 | } |
93 | div.ls-dir a { | 89 | div.ls-dir a { |
94 | font-weight: bold; | 90 | font-weight: bold; |
95 | } | 91 | } |
96 | th.filesize, td.filesize { | 92 | th.filesize, td.filesize { |
97 | text-align: right; | 93 | text-align: right; |
98 | } | 94 | } |
99 | td.filesize { | 95 | td.filesize { |
100 | font-family: monospace; | 96 | font-family: monospace; |
101 | } | 97 | } |
102 | td.filemode { | 98 | td.filemode { |
103 | font-family: monospace; | 99 | font-family: monospace; |
104 | } | 100 | } |
105 | 101 | ||
106 | td.blob { | 102 | td.blob { |
107 | white-space: pre; | 103 | white-space: pre; |
108 | font-family: monospace; | 104 | font-family: monospace; |
109 | background-color: white; | 105 | background-color: white; |
110 | } | 106 | } |
111 | 107 | ||
112 | table.nowrap td { | 108 | table.nowrap td { |
113 | white-space: nowrap; | 109 | white-space: nowrap; |
114 | } | 110 | } |
115 | 111 | ||
116 | table.commit-info { | 112 | table.commit-info { |
117 | border-collapse: collapse; | 113 | border-collapse: collapse; |
118 | margin-top: 1.5em; | 114 | margin-top: 1.5em; |
119 | } | 115 | } |
120 | table.commit-info th { | 116 | table.commit-info th { |
121 | text-align: left; | 117 | text-align: left; |
122 | font-weight: normal; | 118 | font-weight: normal; |
123 | padding: 0.1em 1em 0.1em 0.1em; | 119 | padding: 0.1em 1em 0.1em 0.1em; |
124 | } | 120 | } |
125 | table.commit-info td { | 121 | table.commit-info td { |
126 | font-weight: normal; | 122 | font-weight: normal; |
127 | padding: 0.1em 1em 0.1em 0.1em; | 123 | padding: 0.1em 1em 0.1em 0.1em; |
128 | } | 124 | } |
129 | div.commit-subject { | 125 | div.commit-subject { |
130 | font-weight: bold; | 126 | font-weight: bold; |
131 | font-size: 125%; | 127 | font-size: 125%; |
132 | margin: 1.5em 0em 0.5em 0em; | 128 | margin: 1.5em 0em 0.5em 0em; |
133 | padding: 0em; | 129 | padding: 0em; |
134 | } | 130 | } |
135 | div.commit-msg { | 131 | div.commit-msg { |
136 | white-space: pre; | 132 | white-space: pre; |
137 | font-family: monospace; | 133 | font-family: monospace; |
138 | } | 134 | } |
139 | table.diffstat { | 135 | table.diffstat { |
140 | border-collapse: collapse; | 136 | border-collapse: collapse; |
141 | margin-top: 1.5em; | 137 | margin-top: 1.5em; |
142 | } | 138 | } |
143 | table.diffstat th { | 139 | table.diffstat th { |
144 | font-weight: normal; | 140 | font-weight: normal; |
145 | text-align: left; | 141 | text-align: left; |
146 | text-decoration: underline; | 142 | text-decoration: underline; |
147 | padding: 0.1em 1em 0.1em 0.1em; | 143 | padding: 0.1em 1em 0.1em 0.1em; |
148 | font-size: 100%; | 144 | font-size: 100%; |
149 | } | 145 | } |
150 | table.diffstat td { | 146 | table.diffstat td { |
151 | padding: 0.1em 1em 0.1em 0.1em; | 147 | padding: 0.1em 1em 0.1em 0.1em; |
152 | font-size: 100%; | 148 | font-size: 100%; |
153 | } | 149 | } |
154 | table.diffstat td span.modechange { | 150 | table.diffstat td span.modechange { |
155 | padding-left: 1em; | 151 | padding-left: 1em; |
156 | color: red; | 152 | color: red; |
157 | } | 153 | } |
158 | table.diffstat td.add a { | 154 | table.diffstat td.add a { |
159 | color: green; | 155 | color: green; |
160 | } | 156 | } |
161 | table.diffstat td.del a { | 157 | table.diffstat td.del a { |
162 | color: red; | 158 | color: red; |
163 | } | 159 | } |
164 | table.diffstat td.upd a { | 160 | table.diffstat td.upd a { |
165 | color: blue; | 161 | color: blue; |
166 | } | 162 | } |
167 | table.diffstat td.summary { | 163 | table.diffstat td.summary { |
168 | /* border-top: solid 1px black; */ | 164 | /* border-top: solid 1px black; */ |
169 | color: #888; | 165 | color: #888; |
170 | padding-top: 0.5em; | 166 | padding-top: 0.5em; |
171 | } | 167 | } |
172 | 168 | ||
173 | table.diff td { | 169 | table.diff td { |
174 | border: solid 1px black; | 170 | border: solid 1px black; |
175 | font-family: monospace; | 171 | font-family: monospace; |
176 | white-space: pre; | 172 | white-space: pre; |
177 | } | 173 | } |
178 | 174 | ||
179 | table.diff td div.hunk { | 175 | table.diff td div.hunk { |
180 | background: #ccc; | 176 | background: #ccc; |
181 | } | 177 | } |
182 | 178 | ||
183 | table.diff td div.add { | 179 | table.diff td div.add { |
184 | color: green; | 180 | color: green; |
185 | } | 181 | } |
186 | 182 | ||
187 | table.diff td div.del { | 183 | table.diff td div.del { |
188 | color: red; | 184 | color: red; |
189 | } | 185 | } |
190 | 186 | ||
191 | .sha1 { | 187 | .sha1 { |
192 | font-family: courier; | 188 | font-family: courier; |
193 | font-size: 90%; | 189 | font-size: 90%; |
194 | } | 190 | } |
195 | .left { | 191 | .left { |
196 | text-align: left; | 192 | text-align: left; |
197 | } | 193 | } |
198 | .right { | 194 | .right { |
199 | text-align: right; | 195 | text-align: right; |
200 | } | 196 | } |
@@ -1,98 +1,98 @@ | |||
1 | /* ui-log.c: functions for log output | 1 | /* ui-log.c: functions for log output |
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 | void print_commit(struct commit *commit) | 11 | void print_commit(struct commit *commit) |
12 | { | 12 | { |
13 | char buf[32]; | 13 | char buf[32]; |
14 | struct commitinfo *info; | 14 | struct commitinfo *info; |
15 | struct tm *time; | 15 | struct tm *time; |
16 | 16 | ||
17 | info = cgit_parse_commit(commit); | 17 | info = cgit_parse_commit(commit); |
18 | time = gmtime(&commit->date); | 18 | time = gmtime(&commit->date); |
19 | html("<tr><td>"); | 19 | html("<tr><td>"); |
20 | strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", time); | 20 | strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", time); |
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, "commit", 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_ntxt(80, info->subject); | 26 | html_ntxt(80, 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></tr>\n"); | 30 | html("</td></tr>\n"); |
31 | cgit_free_commitinfo(info); | 31 | cgit_free_commitinfo(info); |
32 | } | 32 | } |
33 | 33 | ||
34 | 34 | ||
35 | void cgit_print_log(const char *tip, int ofs, int cnt, char *grep) | 35 | void cgit_print_log(const char *tip, int ofs, int cnt, char *grep) |
36 | { | 36 | { |
37 | struct rev_info rev; | 37 | struct rev_info rev; |
38 | struct commit *commit; | 38 | struct commit *commit; |
39 | const char *argv[3] = {NULL, tip, NULL}; | 39 | const char *argv[3] = {NULL, tip, NULL}; |
40 | int argc = 2; | 40 | int argc = 2; |
41 | int i; | 41 | int i; |
42 | 42 | ||
43 | if (grep) | 43 | if (grep) |
44 | argv[argc++] = fmt("--grep=%s", grep); | 44 | argv[argc++] = fmt("--grep=%s", grep); |
45 | init_revisions(&rev, NULL); | 45 | init_revisions(&rev, NULL); |
46 | rev.abbrev = DEFAULT_ABBREV; | 46 | rev.abbrev = DEFAULT_ABBREV; |
47 | rev.commit_format = CMIT_FMT_DEFAULT; | 47 | rev.commit_format = CMIT_FMT_DEFAULT; |
48 | rev.verbose_header = 1; | 48 | rev.verbose_header = 1; |
49 | rev.show_root_diff = 0; | 49 | rev.show_root_diff = 0; |
50 | setup_revisions(argc, argv, &rev, NULL); | 50 | setup_revisions(argc, argv, &rev, NULL); |
51 | if (rev.grep_filter) { | 51 | if (rev.grep_filter) { |
52 | rev.grep_filter->regflags |= REG_ICASE; | 52 | rev.grep_filter->regflags |= REG_ICASE; |
53 | compile_grep_patterns(rev.grep_filter); | 53 | compile_grep_patterns(rev.grep_filter); |
54 | } | 54 | } |
55 | prepare_revision_walk(&rev); | 55 | prepare_revision_walk(&rev); |
56 | 56 | ||
57 | html("<h2>Log</h2>"); | 57 | html("<h2>Log</h2>"); |
58 | html("<table class='list nowrap'>"); | 58 | html("<table class='list nowrap'>"); |
59 | html("<tr><th class='left'>Date</th>" | 59 | html("<tr class='nohover'><th class='left'>Date</th>" |
60 | "<th class='left'>Message</th>" | 60 | "<th class='left'>Message</th>" |
61 | "<th class='left'>Author</th></tr>\n"); | 61 | "<th class='left'>Author</th></tr>\n"); |
62 | 62 | ||
63 | if (ofs<0) | 63 | if (ofs<0) |
64 | ofs = 0; | 64 | ofs = 0; |
65 | 65 | ||
66 | for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { | 66 | for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { |
67 | free(commit->buffer); | 67 | free(commit->buffer); |
68 | commit->buffer = NULL; | 68 | commit->buffer = NULL; |
69 | free_commit_list(commit->parents); | 69 | free_commit_list(commit->parents); |
70 | commit->parents = NULL; | 70 | commit->parents = NULL; |
71 | } | 71 | } |
72 | 72 | ||
73 | for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { | 73 | for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { |
74 | print_commit(commit); | 74 | print_commit(commit); |
75 | free(commit->buffer); | 75 | free(commit->buffer); |
76 | commit->buffer = NULL; | 76 | commit->buffer = NULL; |
77 | free_commit_list(commit->parents); | 77 | free_commit_list(commit->parents); |
78 | commit->parents = NULL; | 78 | commit->parents = NULL; |
79 | } | 79 | } |
80 | html("</table>\n"); | 80 | html("</table>\n"); |
81 | 81 | ||
82 | html("<div class='pager'>"); | 82 | html("<div class='pager'>"); |
83 | if (ofs > 0) { | 83 | if (ofs > 0) { |
84 | html(" <a href='"); | 84 | html(" <a href='"); |
85 | html(cgit_pageurl(cgit_query_repo, cgit_query_page, | 85 | html(cgit_pageurl(cgit_query_repo, cgit_query_page, |
86 | fmt("h=%s&ofs=%d", tip, ofs-cnt))); | 86 | fmt("h=%s&ofs=%d", tip, ofs-cnt))); |
87 | html("'>[prev]</a> "); | 87 | html("'>[prev]</a> "); |
88 | } | 88 | } |
89 | 89 | ||
90 | if ((commit = get_revision(&rev)) != NULL) { | 90 | if ((commit = get_revision(&rev)) != NULL) { |
91 | html(" <a href='"); | 91 | html(" <a href='"); |
92 | html(cgit_pageurl(cgit_query_repo, "log", | 92 | html(cgit_pageurl(cgit_query_repo, "log", |
93 | fmt("h=%s&ofs=%d", tip, ofs+cnt))); | 93 | fmt("h=%s&ofs=%d", tip, ofs+cnt))); |
94 | html("'>[next]</a> "); | 94 | html("'>[next]</a> "); |
95 | } | 95 | } |
96 | html("</div>"); | 96 | html("</div>"); |
97 | } | 97 | } |
98 | 98 | ||
diff --git a/ui-repolist.c b/ui-repolist.c index 9f12b18..bd4af59 100644 --- a/ui-repolist.c +++ b/ui-repolist.c | |||
@@ -1,63 +1,63 @@ | |||
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 "cgit.h" | 9 | #include "cgit.h" |
10 | 10 | ||
11 | void cgit_print_repolist(struct cacheitem *item) | 11 | void cgit_print_repolist(struct cacheitem *item) |
12 | { | 12 | { |
13 | DIR *d; | 13 | DIR *d; |
14 | struct dirent *de; | 14 | struct dirent *de; |
15 | struct stat st; | 15 | struct stat st; |
16 | char *name; | 16 | char *name; |
17 | 17 | ||
18 | chdir(cgit_root); | 18 | chdir(cgit_root); |
19 | cgit_print_docstart(cgit_root_title, item); | 19 | cgit_print_docstart(cgit_root_title, item); |
20 | cgit_print_pageheader(cgit_root_title, 0); | 20 | cgit_print_pageheader(cgit_root_title, 0); |
21 | 21 | ||
22 | if (!(d = opendir("."))) { | 22 | if (!(d = opendir("."))) { |
23 | cgit_print_error(fmt("Unable to scan repository directory: %s", | 23 | cgit_print_error(fmt("Unable to scan repository directory: %s", |
24 | strerror(errno))); | 24 | strerror(errno))); |
25 | cgit_print_docend(); | 25 | cgit_print_docend(); |
26 | return; | 26 | return; |
27 | } | 27 | } |
28 | 28 | ||
29 | html("<h2>Repositories</h2>\n"); | 29 | html("<h2>Repositories</h2>\n"); |
30 | html("<table class='list nowrap'>"); | 30 | html("<table class='list nowrap'>"); |
31 | html("<tr>" | 31 | html("<tr class='nohover'>" |
32 | "<th class='left'>Name</th>" | 32 | "<th class='left'>Name</th>" |
33 | "<th class='left'>Description</th>" | 33 | "<th class='left'>Description</th>" |
34 | "<th class='left'>Owner</th></tr>\n"); | 34 | "<th class='left'>Owner</th></tr>\n"); |
35 | while ((de = readdir(d)) != NULL) { | 35 | while ((de = readdir(d)) != NULL) { |
36 | if (de->d_name[0] == '.') | 36 | if (de->d_name[0] == '.') |
37 | continue; | 37 | continue; |
38 | if (stat(de->d_name, &st) < 0) | 38 | if (stat(de->d_name, &st) < 0) |
39 | continue; | 39 | continue; |
40 | if (!S_ISDIR(st.st_mode)) | 40 | if (!S_ISDIR(st.st_mode)) |
41 | continue; | 41 | continue; |
42 | 42 | ||
43 | cgit_repo_name = cgit_repo_desc = cgit_repo_owner = NULL; | 43 | cgit_repo_name = cgit_repo_desc = cgit_repo_owner = NULL; |
44 | name = fmt("%s/info/cgit", de->d_name); | 44 | name = fmt("%s/info/cgit", de->d_name); |
45 | if (cgit_read_config(name, cgit_repo_config_cb)) | 45 | if (cgit_read_config(name, cgit_repo_config_cb)) |
46 | continue; | 46 | continue; |
47 | 47 | ||
48 | html("<tr><td>"); | 48 | html("<tr><td>"); |
49 | html_link_open(cgit_repourl(de->d_name), NULL, NULL); | 49 | html_link_open(cgit_repourl(de->d_name), NULL, NULL); |
50 | html_txt(cgit_repo_name); | 50 | html_txt(cgit_repo_name); |
51 | html_link_close(); | 51 | html_link_close(); |
52 | html("</td><td>"); | 52 | html("</td><td>"); |
53 | html_txt(cgit_repo_desc); | 53 | html_txt(cgit_repo_desc); |
54 | html("</td><td>"); | 54 | html("</td><td>"); |
55 | html_txt(cgit_repo_owner); | 55 | html_txt(cgit_repo_owner); |
56 | html("</td></tr>\n"); | 56 | html("</td></tr>\n"); |
57 | } | 57 | } |
58 | closedir(d); | 58 | closedir(d); |
59 | html("</table>"); | 59 | html("</table>"); |
60 | cgit_print_docend(); | 60 | cgit_print_docend(); |
61 | } | 61 | } |
62 | 62 | ||
63 | 63 | ||
diff --git a/ui-summary.c b/ui-summary.c index 1591632..04d4912 100644 --- a/ui-summary.c +++ b/ui-summary.c | |||
@@ -1,125 +1,125 @@ | |||
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 cgit_print_branch_cb(const char *refname, const unsigned char *sha1, | 11 | static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1, |
12 | int flags, void *cb_data) | 12 | int flags, void *cb_data) |
13 | { | 13 | { |
14 | struct commit *commit; | 14 | struct commit *commit; |
15 | struct commitinfo *info; | 15 | struct commitinfo *info; |
16 | char buf[256], *url; | 16 | char buf[256], *url; |
17 | 17 | ||
18 | strncpy(buf, refname, sizeof(buf)); | 18 | strncpy(buf, refname, sizeof(buf)); |
19 | commit = lookup_commit(sha1); | 19 | commit = lookup_commit(sha1); |
20 | if (commit && !parse_commit(commit)){ | 20 | if (commit && !parse_commit(commit)){ |
21 | info = cgit_parse_commit(commit); | 21 | info = cgit_parse_commit(commit); |
22 | html("<tr><td>"); | 22 | html("<tr><td>"); |
23 | url = cgit_pageurl(cgit_query_repo, "log", | 23 | url = cgit_pageurl(cgit_query_repo, "log", |
24 | fmt("h=%s", refname)); | 24 | fmt("h=%s", refname)); |
25 | html_link_open(url, NULL, NULL); | 25 | html_link_open(url, NULL, NULL); |
26 | html_txt(buf); | 26 | html_txt(buf); |
27 | html_link_close(); | 27 | html_link_close(); |
28 | html("</td><td>"); | 28 | html("</td><td>"); |
29 | cgit_print_date(commit->date); | 29 | cgit_print_date(commit->date); |
30 | html("</td><td>"); | 30 | html("</td><td>"); |
31 | html_txt(info->author); | 31 | html_txt(info->author); |
32 | html("</td><td>"); | 32 | html("</td><td>"); |
33 | url = cgit_pageurl(cgit_query_repo, "commit", | 33 | url = cgit_pageurl(cgit_query_repo, "commit", |
34 | fmt("id=%s", sha1_to_hex(sha1))); | 34 | fmt("id=%s", sha1_to_hex(sha1))); |
35 | html_link_open(url, NULL, NULL); | 35 | html_link_open(url, NULL, NULL); |
36 | html_ntxt(80, info->subject); | 36 | html_ntxt(80, info->subject); |
37 | html_link_close(); | 37 | html_link_close(); |
38 | html("</td></tr>\n"); | 38 | html("</td></tr>\n"); |
39 | cgit_free_commitinfo(info); | 39 | cgit_free_commitinfo(info); |
40 | } else { | 40 | } else { |
41 | html("<tr><td>"); | 41 | html("<tr><td>"); |
42 | html_txt(buf); | 42 | html_txt(buf); |
43 | html("</td><td colspan='3'>"); | 43 | html("</td><td colspan='3'>"); |
44 | htmlf("*** bad ref %s ***", sha1_to_hex(sha1)); | 44 | htmlf("*** bad ref %s ***", sha1_to_hex(sha1)); |
45 | html("</td></tr>\n"); | 45 | html("</td></tr>\n"); |
46 | } | 46 | } |
47 | return 0; | 47 | return 0; |
48 | } | 48 | } |
49 | 49 | ||
50 | static int cgit_print_tag_cb(const char *refname, const unsigned char *sha1, | 50 | static int cgit_print_tag_cb(const char *refname, const unsigned char *sha1, |
51 | int flags, void *cb_data) | 51 | int flags, void *cb_data) |
52 | { | 52 | { |
53 | struct tag *tag; | 53 | struct tag *tag; |
54 | struct taginfo *info; | 54 | struct taginfo *info; |
55 | char buf[256], *page, *url; | 55 | char buf[256], *page, *url; |
56 | 56 | ||
57 | strncpy(buf, refname, sizeof(buf)); | 57 | strncpy(buf, refname, sizeof(buf)); |
58 | tag = lookup_tag(sha1); | 58 | tag = lookup_tag(sha1); |
59 | if (tag && !parse_tag(tag) && (info = cgit_parse_tag(tag))){ | 59 | if (tag && !parse_tag(tag) && (info = cgit_parse_tag(tag))){ |
60 | html("<tr><td>"); | 60 | html("<tr><td>"); |
61 | url = cgit_pageurl(cgit_query_repo, "view", | 61 | url = cgit_pageurl(cgit_query_repo, "view", |
62 | fmt("id=%s", sha1_to_hex(sha1))); | 62 | fmt("id=%s", sha1_to_hex(sha1))); |
63 | html_link_open(url, NULL, NULL); | 63 | html_link_open(url, NULL, NULL); |
64 | html_txt(buf); | 64 | html_txt(buf); |
65 | html_link_close(); | 65 | html_link_close(); |
66 | html("</td><td>"); | 66 | html("</td><td>"); |
67 | if (info->tagger_date > 0) | 67 | if (info->tagger_date > 0) |
68 | cgit_print_date(info->tagger_date); | 68 | cgit_print_date(info->tagger_date); |
69 | html("</td><td>"); | 69 | html("</td><td>"); |
70 | if (info->tagger) | 70 | if (info->tagger) |
71 | html(info->tagger); | 71 | html(info->tagger); |
72 | html("</td><td>"); | 72 | html("</td><td>"); |
73 | if (tag->tagged->type == OBJ_COMMIT) | 73 | if (tag->tagged->type == OBJ_COMMIT) |
74 | page = "commit"; | 74 | page = "commit"; |
75 | else if (tag->tagged->type == OBJ_TREE) | 75 | else if (tag->tagged->type == OBJ_TREE) |
76 | page = "tree"; | 76 | page = "tree"; |
77 | else | 77 | else |
78 | page = "view"; | 78 | page = "view"; |
79 | 79 | ||
80 | url = cgit_pageurl(cgit_query_repo, page, | 80 | url = cgit_pageurl(cgit_query_repo, page, |
81 | fmt("id=%s", sha1_to_hex(tag->tagged->sha1))); | 81 | fmt("id=%s", sha1_to_hex(tag->tagged->sha1))); |
82 | html_link_open(url, NULL, NULL); | 82 | html_link_open(url, NULL, NULL); |
83 | htmlf("%s %s", type_names[tag->tagged->type], | 83 | htmlf("%s %s", type_names[tag->tagged->type], |
84 | sha1_to_hex(tag->tagged->sha1)); | 84 | sha1_to_hex(tag->tagged->sha1)); |
85 | html_link_close(); | 85 | html_link_close(); |
86 | html("</td></tr>\n"); | 86 | html("</td></tr>\n"); |
87 | } else { | 87 | } else { |
88 | html("<tr><td>"); | 88 | html("<tr><td>"); |
89 | html_txt(buf); | 89 | html_txt(buf); |
90 | html("</td><td colspan='3'>"); | 90 | html("</td><td colspan='3'>"); |
91 | htmlf("*** bad ref %s ***", sha1_to_hex(sha1)); | 91 | htmlf("*** bad ref %s ***", sha1_to_hex(sha1)); |
92 | html("</td></tr>\n"); | 92 | html("</td></tr>\n"); |
93 | } | 93 | } |
94 | return 0; | 94 | return 0; |
95 | } | 95 | } |
96 | 96 | ||
97 | static void cgit_print_branches() | 97 | static void cgit_print_branches() |
98 | { | 98 | { |
99 | html("<tr><th class='left'>Branch</th>" | 99 | html("<tr class='nohover'><th class='left'>Branch</th>" |
100 | "<th class='left'>Updated</th>" | 100 | "<th class='left'>Updated</th>" |
101 | "<th class='left'>Author</th>" | 101 | "<th class='left'>Author</th>" |
102 | "<th class='left'>Head commit</th></tr>\n"); | 102 | "<th class='left'>Head commit</th></tr>\n"); |
103 | for_each_branch_ref(cgit_print_branch_cb, NULL); | 103 | for_each_branch_ref(cgit_print_branch_cb, NULL); |
104 | } | 104 | } |
105 | 105 | ||
106 | static void cgit_print_tags() | 106 | static void cgit_print_tags() |
107 | { | 107 | { |
108 | html("<tr><th class='left'>Tag</th>" | 108 | html("<tr class='nohover'><th class='left'>Tag</th>" |
109 | "<th class='left'>Created</th>" | 109 | "<th class='left'>Created</th>" |
110 | "<th class='left'>Author</th>" | 110 | "<th class='left'>Author</th>" |
111 | "<th class='left'>Reference</th></tr>\n"); | 111 | "<th class='left'>Reference</th></tr>\n"); |
112 | for_each_tag_ref(cgit_print_tag_cb, NULL); | 112 | for_each_tag_ref(cgit_print_tag_cb, NULL); |
113 | } | 113 | } |
114 | 114 | ||
115 | void cgit_print_summary() | 115 | void cgit_print_summary() |
116 | { | 116 | { |
117 | html("<h2>"); | 117 | html("<h2>"); |
118 | html_txt("Repo summary page"); | 118 | html_txt("Repo summary page"); |
119 | html("</h2>"); | 119 | html("</h2>"); |
120 | html("<table class='list nowrap'>"); | 120 | html("<table class='list nowrap'>"); |
121 | cgit_print_branches(); | 121 | cgit_print_branches(); |
122 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); | 122 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); |
123 | cgit_print_tags(); | 123 | cgit_print_tags(); |
124 | html("</table>"); | 124 | html("</table>"); |
125 | } | 125 | } |
@@ -1,79 +1,79 @@ | |||
1 | /* ui-tree.c: functions for tree output | 1 | /* ui-tree.c: functions for tree output |
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 | 11 | ||
12 | static int print_entry(const unsigned char *sha1, const char *base, | 12 | static int print_entry(const unsigned char *sha1, const char *base, |
13 | int baselen, const char *pathname, unsigned int mode, | 13 | int baselen, const char *pathname, unsigned int mode, |
14 | int stage) | 14 | int stage) |
15 | { | 15 | { |
16 | char *name; | 16 | char *name; |
17 | char type[20]; | 17 | char type[20]; |
18 | unsigned long size; | 18 | unsigned long size; |
19 | 19 | ||
20 | if (sha1_object_info(sha1, type, &size)) { | 20 | if (sha1_object_info(sha1, type, &size)) { |
21 | cgit_print_error(fmt("Bad object name: %s", | 21 | cgit_print_error(fmt("Bad object name: %s", |
22 | sha1_to_hex(sha1))); | 22 | sha1_to_hex(sha1))); |
23 | return 0; | 23 | return 0; |
24 | } | 24 | } |
25 | name = xstrdup(pathname); | 25 | name = xstrdup(pathname); |
26 | html("<tr><td class='filemode'>"); | 26 | html("<tr><td class='filemode'>"); |
27 | html_filemode(mode); | 27 | html_filemode(mode); |
28 | html("</td><td>"); | 28 | html("</td><td>"); |
29 | if (S_ISDIR(mode)) { | 29 | if (S_ISDIR(mode)) { |
30 | html("<div class='ls-dir'><a href='"); | 30 | html("<div class='ls-dir'><a href='"); |
31 | html_attr(cgit_pageurl(cgit_query_repo, "tree", | 31 | html_attr(cgit_pageurl(cgit_query_repo, "tree", |
32 | fmt("id=%s&path=%s%s/", | 32 | fmt("id=%s&path=%s%s/", |
33 | sha1_to_hex(sha1), | 33 | sha1_to_hex(sha1), |
34 | cgit_query_path ? cgit_query_path : "", | 34 | cgit_query_path ? cgit_query_path : "", |
35 | pathname))); | 35 | pathname))); |
36 | } else { | 36 | } else { |
37 | html("<div class='ls-blob'><a href='"); | 37 | html("<div class='ls-blob'><a href='"); |
38 | html_attr(cgit_pageurl(cgit_query_repo, "view", | 38 | html_attr(cgit_pageurl(cgit_query_repo, "view", |
39 | fmt("id=%s&path=%s%s", sha1_to_hex(sha1), | 39 | fmt("id=%s&path=%s%s", sha1_to_hex(sha1), |
40 | cgit_query_path ? cgit_query_path : "", | 40 | cgit_query_path ? cgit_query_path : "", |
41 | pathname))); | 41 | pathname))); |
42 | } | 42 | } |
43 | html("'>"); | 43 | html("'>"); |
44 | html_txt(name); | 44 | html_txt(name); |
45 | if (S_ISDIR(mode)) | 45 | if (S_ISDIR(mode)) |
46 | html("/"); | 46 | html("/"); |
47 | html("</a></div></td>"); | 47 | html("</a></div></td>"); |
48 | htmlf("<td class='filesize'>%li</td>", size); | 48 | htmlf("<td class='filesize'>%li</td>", size); |
49 | html("</tr>\n"); | 49 | html("</tr>\n"); |
50 | free(name); | 50 | free(name); |
51 | return 0; | 51 | return 0; |
52 | } | 52 | } |
53 | 53 | ||
54 | void cgit_print_tree(const char *hex, char *path) | 54 | void cgit_print_tree(const char *hex, char *path) |
55 | { | 55 | { |
56 | struct tree *tree; | 56 | struct tree *tree; |
57 | unsigned char sha1[20]; | 57 | unsigned char sha1[20]; |
58 | 58 | ||
59 | if (get_sha1_hex(hex, sha1)) { | 59 | if (get_sha1_hex(hex, sha1)) { |
60 | cgit_print_error(fmt("Invalid object id: %s", hex)); | 60 | cgit_print_error(fmt("Invalid object id: %s", hex)); |
61 | return; | 61 | return; |
62 | } | 62 | } |
63 | tree = parse_tree_indirect(sha1); | 63 | tree = parse_tree_indirect(sha1); |
64 | if (!tree) { | 64 | if (!tree) { |
65 | cgit_print_error(fmt("Not a tree object: %s", hex)); | 65 | cgit_print_error(fmt("Not a tree object: %s", hex)); |
66 | return; | 66 | return; |
67 | } | 67 | } |
68 | 68 | ||
69 | html("<h2>Tree content</h2>\n"); | 69 | html("<h2>Tree content</h2>\n"); |
70 | html_txt(path); | 70 | html_txt(path); |
71 | html("<table class='list'>\n"); | 71 | html("<table class='list'>\n"); |
72 | html("<tr>"); | 72 | html("<tr class='nohover'>"); |
73 | html("<th class='left'>Mode</th>"); | 73 | html("<th class='left'>Mode</th>"); |
74 | html("<th class='left'>Name</th>"); | 74 | html("<th class='left'>Name</th>"); |
75 | html("<th class='right'>Size</th>"); | 75 | html("<th class='right'>Size</th>"); |
76 | html("</tr>\n"); | 76 | html("</tr>\n"); |
77 | read_tree_recursive(tree, "", 0, 1, NULL, print_entry); | 77 | read_tree_recursive(tree, "", 0, 1, NULL, print_entry); |
78 | html("</table>\n"); | 78 | html("</table>\n"); |
79 | } | 79 | } |
@@ -1,42 +1,42 @@ | |||
1 | /* ui-view.c: functions to output _any_ object, given it's sha1 | 1 | /* ui-view.c: functions to output _any_ object, given it's sha1 |
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 | void cgit_print_view(const char *hex) | 11 | void 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]; |
15 | unsigned char *buf; | 15 | unsigned char *buf; |
16 | unsigned long size; | 16 | unsigned long size; |
17 | 17 | ||
18 | if (get_sha1_hex(hex, sha1)){ | 18 | if (get_sha1_hex(hex, sha1)){ |
19 | cgit_print_error(fmt("Bad hex value: %s", hex)); | 19 | cgit_print_error(fmt("Bad hex value: %s", hex)); |
20 | return; | 20 | return; |
21 | } | 21 | } |
22 | 22 | ||
23 | if (sha1_object_info(sha1, type, &size)){ | 23 | if (sha1_object_info(sha1, type, &size)){ |
24 | cgit_print_error("Bad object name"); | 24 | cgit_print_error("Bad object name"); |
25 | return; | 25 | return; |
26 | } | 26 | } |
27 | 27 | ||
28 | buf = read_sha1_file(sha1, type, &size); | 28 | buf = read_sha1_file(sha1, type, &size); |
29 | if (!buf) { | 29 | if (!buf) { |
30 | cgit_print_error("Error reading object"); | 30 | cgit_print_error("Error reading object"); |
31 | return; | 31 | return; |
32 | } | 32 | } |
33 | 33 | ||
34 | buf[size] = '\0'; | 34 | buf[size] = '\0'; |
35 | html("<h2>Object content</h2>\n"); | 35 | html("<h2>Object content</h2>\n"); |
36 | html("<table class='list'>\n"); | 36 | html("<table class='list'>\n"); |
37 | htmlf("<tr><th>%s %s, %li bytes</th></tr>\n", type, hex, size); | 37 | htmlf("<tr class='nohover'><th class='left'>%s %s, %li bytes</th></tr>\n", type, hex, size); |
38 | html("<tr><td class='blob'>\n"); | 38 | html("<tr><td class='blob'>\n"); |
39 | html_txt(buf); | 39 | html_txt(buf); |
40 | html("\n</td></tr>\n"); | 40 | html("\n</td></tr>\n"); |
41 | html("</table>\n"); | 41 | html("</table>\n"); |
42 | } | 42 | } |