summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.css17
-rw-r--r--ui-tree.c18
2 files changed, 12 insertions, 23 deletions
diff --git a/cgit.css b/cgit.css
index 30fde03..cda437e 100644
--- a/cgit.css
+++ b/cgit.css
@@ -81,214 +81,205 @@ table#layout {
81 border-collapse: collapse; 81 border-collapse: collapse;
82 margin: 0px; 82 margin: 0px;
83} 83}
84 84
85td#header, td#logo { 85td#header, td#logo {
86 color: #666; 86 color: #666;
87 background-color: #ddd; 87 background-color: #ddd;
88 border-bottom: solid 1px #000; 88 border-bottom: solid 1px #000;
89} 89}
90 90
91td#header { 91td#header {
92 font-size: 150%; 92 font-size: 150%;
93 font-weight: bold; 93 font-weight: bold;
94 padding: 0.2em 0.5em; 94 padding: 0.2em 0.5em;
95 vertical-align: text-bottom; 95 vertical-align: text-bottom;
96} 96}
97 97
98td#logo { 98td#logo {
99 text-align: right; 99 text-align: right;
100 vertical-align: middle; 100 vertical-align: middle;
101 padding-right: 0.5em; 101 padding-right: 0.5em;
102} 102}
103 103
104td#crumb, td#search { 104td#crumb, td#search {
105 color: #ccc; 105 color: #ccc;
106 border-top: solid 3px #555; 106 border-top: solid 3px #555;
107 background-color: #666; 107 background-color: #666;
108 border-bottom: solid 1px #333; 108 border-bottom: solid 1px #333;
109 padding: 2px 1em; 109 padding: 2px 1em;
110} 110}
111 111
112td#crumb { 112td#crumb {
113 font-weight: bold; 113 font-weight: bold;
114} 114}
115 115
116td#crumb a { 116td#crumb a {
117 color: #ccc; 117 color: #ccc;
118 background-color: #666; 118 background-color: #666;
119} 119}
120 120
121td#crumb a:hover { 121td#crumb a:hover {
122 color: #eee; 122 color: #eee;
123 background-color: #666; 123 background-color: #666;
124} 124}
125 125
126td#search { 126td#search {
127 text-align: right; 127 text-align: right;
128 vertical-align: middle; 128 vertical-align: middle;
129 padding-right: 0.5em; 129 padding-right: 0.5em;
130} 130}
131 131
132td#search form { 132td#search form {
133 margin: 0px; 133 margin: 0px;
134 padding: 0px; 134 padding: 0px;
135} 135}
136 136
137td#search input { 137td#search input {
138 font-size: 9pt; 138 font-size: 9pt;
139 padding: 0px; 139 padding: 0px;
140 width: 10em; 140 width: 10em;
141 border: solid 1px #333; 141 border: solid 1px #333;
142 color: #333; 142 color: #333;
143 background-color: #fff; 143 background-color: #fff;
144} 144}
145 145
146div#summary { 146div#summary {
147 vertical-align: top; 147 vertical-align: top;
148 margin-bottom: 1em; 148 margin-bottom: 1em;
149} 149}
150 150
151table#downloads { 151table#downloads {
152 float: right; 152 float: right;
153 border-collapse: collapse; 153 border-collapse: collapse;
154 border: solid 1px #777; 154 border: solid 1px #777;
155 margin-left: 0.5em; 155 margin-left: 0.5em;
156 margin-bottom: 0.5em; 156 margin-bottom: 0.5em;
157} 157}
158 158
159table#downloads th { 159table#downloads th {
160 background-color: #ccc; 160 background-color: #ccc;
161} 161}
162 162
163td#content { 163td#content {
164 padding: 1em 0.5em; 164 padding: 1em 0.5em;
165} 165}
166 166
167div#blob { 167div#blob {
168 border: solid 1px black; 168 border: solid 1px black;
169} 169}
170 170
171div.error { 171div.error {
172 color: red; 172 color: red;
173 font-weight: bold; 173 font-weight: bold;
174 margin: 1em 2em; 174 margin: 1em 2em;
175} 175}
176 176
177td.ls-blob, td.ls-dir, td.ls-mod { 177a.ls-blob, a.ls-dir, a.ls-mod {
178 font-family: monospace; 178 font-family: monospace;
179} 179}
180 180
181div.ls-dir a { 181td.ls-size {
182 font-weight: bold;
183}
184
185th.filesize, td.filesize {
186 text-align: right; 182 text-align: right;
187} 183}
188 184
189td.filesize { 185td.ls-size {
190 font-family: monospace; 186 font-family: monospace;
191} 187}
192 188
193td.links { 189td.ls-mode {
194 font-size: 80%;
195 padding-left: 2em;
196}
197
198td.filemode {
199 font-family: monospace; 190 font-family: monospace;
200} 191}
201 192
202table.blob { 193table.blob {
203 margin-top: 0.5em; 194 margin-top: 0.5em;
204 border-top: solid 1px black; 195 border-top: solid 1px black;
205} 196}
206 197
207table.blob td.no { 198table.blob td.no {
208 border-right: solid 1px black; 199 border-right: solid 1px black;
209 color: black; 200 color: black;
210 background-color: #eee; 201 background-color: #eee;
211 text-align: right; 202 text-align: right;
212} 203}
213 204
214table.blob td.txt { 205table.blob td.txt {
215 white-space: pre; 206 white-space: pre;
216 font-family: monospace; 207 font-family: monospace;
217 padding-left: 0.5em; 208 padding-left: 0.5em;
218} 209}
219 210
220table.nowrap td { 211table.nowrap td {
221 white-space: nowrap; 212 white-space: nowrap;
222} 213}
223 214
224table.commit-info { 215table.commit-info {
225 border-collapse: collapse; 216 border-collapse: collapse;
226 margin-top: 1.5em; 217 margin-top: 1.5em;
227} 218}
228 219
229table.commit-info th { 220table.commit-info th {
230 text-align: left; 221 text-align: left;
231 font-weight: normal; 222 font-weight: normal;
232 padding: 0.1em 1em 0.1em 0.1em; 223 padding: 0.1em 1em 0.1em 0.1em;
233} 224}
234 225
235table.commit-info td { 226table.commit-info td {
236 font-weight: normal; 227 font-weight: normal;
237 padding: 0.1em 1em 0.1em 0.1em; 228 padding: 0.1em 1em 0.1em 0.1em;
238} 229}
239 230
240div.commit-subject { 231div.commit-subject {
241 font-weight: bold; 232 font-weight: bold;
242 font-size: 125%; 233 font-size: 125%;
243 margin: 1.5em 0em 0.5em 0em; 234 margin: 1.5em 0em 0.5em 0em;
244 padding: 0em; 235 padding: 0em;
245} 236}
246 237
247div.commit-msg { 238div.commit-msg {
248 white-space: pre; 239 white-space: pre;
249 font-family: monospace; 240 font-family: monospace;
250} 241}
251 242
252div.diffstat-header { 243div.diffstat-header {
253 font-weight: bold; 244 font-weight: bold;
254 padding-top: 1.5em; 245 padding-top: 1.5em;
255} 246}
256 247
257table.diffstat { 248table.diffstat {
258 border-collapse: collapse; 249 border-collapse: collapse;
259 width: 100%; 250 width: 100%;
260 border: solid 1px #aaa; 251 border: solid 1px #aaa;
261 background-color: #eee; 252 background-color: #eee;
262} 253}
263 254
264table.diffstat tr:hover { 255table.diffstat tr:hover {
265 background-color: #ccc; 256 background-color: #ccc;
266} 257}
267 258
268table.diffstat th { 259table.diffstat th {
269 font-weight: normal; 260 font-weight: normal;
270 text-align: left; 261 text-align: left;
271 text-decoration: underline; 262 text-decoration: underline;
272 padding: 0.1em 1em 0.1em 0.1em; 263 padding: 0.1em 1em 0.1em 0.1em;
273 font-size: 100%; 264 font-size: 100%;
274} 265}
275 266
276table.diffstat td { 267table.diffstat td {
277 padding: 0.2em 0.2em 0.1em 0.1em; 268 padding: 0.2em 0.2em 0.1em 0.1em;
278 font-size: 100%; 269 font-size: 100%;
279 border: none; 270 border: none;
280} 271}
281 272
282table.diffstat td.mode { 273table.diffstat td.mode {
283 white-space: nowrap; 274 white-space: nowrap;
284} 275}
285 276
286table.diffstat td span.modechange { 277table.diffstat td span.modechange {
287 padding-left: 1em; 278 padding-left: 1em;
288 color: red; 279 color: red;
289} 280}
290 281
291table.diffstat td.add a { 282table.diffstat td.add a {
292 color: green; 283 color: green;
293} 284}
294 285
diff --git a/ui-tree.c b/ui-tree.c
index 3b82374..d503bee 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -1,199 +1,197 @@
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
11char *curr_rev; 11char *curr_rev;
12char *match_path; 12char *match_path;
13int header = 0; 13int header = 0;
14 14
15static void print_object(const unsigned char *sha1, char *path) 15static void print_object(const unsigned char *sha1, char *path)
16{ 16{
17 enum object_type type; 17 enum object_type type;
18 unsigned char *buf; 18 unsigned char *buf;
19 unsigned long size, lineno, start, idx; 19 unsigned long size, lineno, start, idx;
20 20
21 type = sha1_object_info(sha1, &size); 21 type = sha1_object_info(sha1, &size);
22 if (type == OBJ_BAD) { 22 if (type == OBJ_BAD) {
23 cgit_print_error(fmt("Bad object name: %s", 23 cgit_print_error(fmt("Bad object name: %s",
24 sha1_to_hex(sha1))); 24 sha1_to_hex(sha1)));
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(fmt("Error reading object %s", 30 cgit_print_error(fmt("Error reading object %s",
31 sha1_to_hex(sha1))); 31 sha1_to_hex(sha1)));
32 return; 32 return;
33 } 33 }
34 34
35 html("<table class='blob'>\n"); 35 html("<table class='blob'>\n");
36 idx = 0; 36 idx = 0;
37 start = 0; 37 start = 0;
38 lineno = 0; 38 lineno = 0;
39 while(idx < size) { 39 while(idx < size) {
40 if (buf[idx] == '\n') { 40 if (buf[idx] == '\n') {
41 buf[idx] = '\0'; 41 buf[idx] = '\0';
42 htmlf("<tr><td class='no'>%d</td><td class='txt'>", 42 htmlf("<tr><td class='no'>%d</td><td class='txt'>",
43 ++lineno); 43 ++lineno);
44 html_txt(buf + start); 44 html_txt(buf + start);
45 html("</td></tr>\n"); 45 html("</td></tr>\n");
46 start = idx + 1; 46 start = idx + 1;
47 } 47 }
48 idx++; 48 idx++;
49 } 49 }
50 html("</table>\n"); 50 html("</table>\n");
51} 51}
52 52
53 53
54static int ls_item(const unsigned char *sha1, const char *base, int baselen, 54static int ls_item(const unsigned char *sha1, const char *base, int baselen,
55 const char *pathname, unsigned int mode, int stage) 55 const char *pathname, unsigned int mode, int stage)
56{ 56{
57 char *name; 57 char *name;
58 char *fullpath; 58 char *fullpath;
59 enum object_type type; 59 enum object_type type;
60 unsigned long size = 0; 60 unsigned long size = 0;
61 char *url, *qry; 61 char *url, *qry;
62 62
63 name = xstrdup(pathname); 63 name = xstrdup(pathname);
64 fullpath = fmt("%s%s%s", cgit_query_path ? cgit_query_path : "", 64 fullpath = fmt("%s%s%s", cgit_query_path ? cgit_query_path : "",
65 cgit_query_path ? "/" : "", name); 65 cgit_query_path ? "/" : "", name);
66 66
67 type = sha1_object_info(sha1, &size); 67 type = sha1_object_info(sha1, &size);
68 if (type == OBJ_BAD && !S_ISDIRLNK(mode)) { 68 if (type == OBJ_BAD && !S_ISDIRLNK(mode)) {
69 htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>", 69 htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>",
70 name, 70 name,
71 sha1_to_hex(sha1)); 71 sha1_to_hex(sha1));
72 return 0; 72 return 0;
73 } 73 }
74 74
75 html("<tr><td class='filemode'>"); 75 html("<tr><td class='ls-mode'>");
76 html_filemode(mode); 76 html_filemode(mode);
77 html("</td><td "); 77 html("</td><td>");
78 if (S_ISDIRLNK(mode)) { 78 if (S_ISDIRLNK(mode)) {
79 htmlf("class='ls-mod'><a href='"); 79 htmlf("<a class='ls-mod' href='");
80 html_attr(fmt(cgit_repo->module_link, 80 html_attr(fmt(cgit_repo->module_link,
81 name, 81 name,
82 sha1_to_hex(sha1))); 82 sha1_to_hex(sha1)));
83 html("'>"); 83 html("'>");
84 html_txt(name); 84 html_txt(name);
85 html("</a>"); 85 html("</a>");
86 } else if (S_ISDIR(mode)) { 86 } else if (S_ISDIR(mode)) {
87 html("class='ls-dir'>"); 87 cgit_tree_link(name, NULL, "ls-dir", cgit_query_head,
88 cgit_tree_link(name, NULL, NULL, cgit_query_head,
89 curr_rev, fullpath); 88 curr_rev, fullpath);
90 } else { 89 } else {
91 html("class='ls-blob'>"); 90 cgit_tree_link(name, NULL, "ls-blob", cgit_query_head,
92 cgit_tree_link(name, NULL, NULL, cgit_query_head,
93 curr_rev, fullpath); 91 curr_rev, fullpath);
94 } 92 }
95 htmlf("</td><td class='filesize'>%li</td>", size); 93 htmlf("</td><td class='ls-size'>%li</td>", size);
96 94
97 html("<td class='links'><a href='"); 95 html("<td><a href='");
98 qry = fmt("h=%s&amp;path=%s%s%s", curr_rev, 96 qry = fmt("h=%s&amp;path=%s%s%s", curr_rev,
99 cgit_query_path ? cgit_query_path : "", 97 cgit_query_path ? cgit_query_path : "",
100 cgit_query_path ? "/" : "", pathname); 98 cgit_query_path ? "/" : "", pathname);
101 url = cgit_pageurl(cgit_query_repo, "log", qry); 99 url = cgit_pageurl(cgit_query_repo, "log", qry);
102 html_attr(url); 100 html_attr(url);
103 html("' class='button'>H</a></td>"); 101 html("' title='Log' class='button'>L</a></td>");
104 html("</tr>\n"); 102 html("</tr>\n");
105 free(name); 103 free(name);
106 return 0; 104 return 0;
107} 105}
108 106
109static void ls_head() 107static void ls_head()
110{ 108{
111 html("<table class='list'>\n"); 109 html("<table class='list'>\n");
112 html("<tr class='nohover'>"); 110 html("<tr class='nohover'>");
113 html("<th class='left'>Mode</th>"); 111 html("<th class='left'>Mode</th>");
114 html("<th class='left'>Name</th>"); 112 html("<th class='left'>Name</th>");
115 html("<th class='right'>Size</th>"); 113 html("<th class='right'>Size</th>");
116 html("<th/>"); 114 html("<th/>");
117 html("</tr>\n"); 115 html("</tr>\n");
118 header = 1; 116 header = 1;
119} 117}
120 118
121static void ls_tail() 119static void ls_tail()
122{ 120{
123 if (!header) 121 if (!header)
124 return; 122 return;
125 html("</table>\n"); 123 html("</table>\n");
126 header = 0; 124 header = 0;
127} 125}
128 126
129static void ls_tree(const unsigned char *sha1, char *path) 127static void ls_tree(const unsigned char *sha1, char *path)
130{ 128{
131 struct tree *tree; 129 struct tree *tree;
132 130
133 tree = parse_tree_indirect(sha1); 131 tree = parse_tree_indirect(sha1);
134 if (!tree) { 132 if (!tree) {
135 cgit_print_error(fmt("Not a tree object: %s", 133 cgit_print_error(fmt("Not a tree object: %s",
136 sha1_to_hex(sha1))); 134 sha1_to_hex(sha1)));
137 return; 135 return;
138 } 136 }
139 137
140 ls_head(); 138 ls_head();
141 read_tree_recursive(tree, "", 0, 1, NULL, ls_item); 139 read_tree_recursive(tree, "", 0, 1, NULL, ls_item);
142 ls_tail(); 140 ls_tail();
143} 141}
144 142
145 143
146static int walk_tree(const unsigned char *sha1, const char *base, int baselen, 144static int walk_tree(const unsigned char *sha1, const char *base, int baselen,
147 const char *pathname, unsigned mode, int stage) 145 const char *pathname, unsigned mode, int stage)
148{ 146{
149 static int state; 147 static int state;
150 static char buffer[PATH_MAX]; 148 static char buffer[PATH_MAX];
151 char *url; 149 char *url;
152 150
153 if (state == 0) { 151 if (state == 0) {
154 memcpy(buffer, base, baselen); 152 memcpy(buffer, base, baselen);
155 strcpy(buffer+baselen, pathname); 153 strcpy(buffer+baselen, pathname);
156 url = cgit_pageurl(cgit_query_repo, "tree", 154 url = cgit_pageurl(cgit_query_repo, "tree",
157 fmt("h=%s&amp;path=%s", curr_rev, buffer)); 155 fmt("h=%s&amp;path=%s", curr_rev, buffer));
158 html("/"); 156 html("/");
159 cgit_tree_link(xstrdup(pathname), NULL, NULL, cgit_query_head, 157 cgit_tree_link(xstrdup(pathname), NULL, NULL, cgit_query_head,
160 curr_rev, buffer); 158 curr_rev, buffer);
161 159
162 if (strcmp(match_path, buffer)) 160 if (strcmp(match_path, buffer))
163 return READ_TREE_RECURSIVE; 161 return READ_TREE_RECURSIVE;
164 162
165 if (S_ISDIR(mode)) { 163 if (S_ISDIR(mode)) {
166 state = 1; 164 state = 1;
167 ls_head(); 165 ls_head();
168 return READ_TREE_RECURSIVE; 166 return READ_TREE_RECURSIVE;
169 } else { 167 } else {
170 print_object(sha1, buffer); 168 print_object(sha1, buffer);
171 return 0; 169 return 0;
172 } 170 }
173 } 171 }
174 ls_item(sha1, base, baselen, pathname, mode, stage); 172 ls_item(sha1, base, baselen, pathname, mode, stage);
175 return 0; 173 return 0;
176} 174}
177 175
178 176
179/* 177/*
180 * Show a tree or a blob 178 * Show a tree or a blob
181 * rev: the commit pointing at the root tree object 179 * rev: the commit pointing at the root tree object
182 * path: path to tree or blob 180 * path: path to tree or blob
183 */ 181 */
184void cgit_print_tree(const char *rev, char *path) 182void cgit_print_tree(const char *rev, char *path)
185{ 183{
186 unsigned char sha1[20]; 184 unsigned char sha1[20];
187 struct commit *commit; 185 struct commit *commit;
188 const char *paths[] = {path, NULL}; 186 const char *paths[] = {path, NULL};
189 187
190 if (!rev) 188 if (!rev)
191 rev = cgit_query_head; 189 rev = cgit_query_head;
192 190
193 curr_rev = xstrdup(rev); 191 curr_rev = xstrdup(rev);
194 if (get_sha1(rev, sha1)) { 192 if (get_sha1(rev, sha1)) {
195 cgit_print_error(fmt("Invalid revision name: %s", rev)); 193 cgit_print_error(fmt("Invalid revision name: %s", rev));
196 return; 194 return;
197 } 195 }
198 commit = lookup_commit_reference(sha1); 196 commit = lookup_commit_reference(sha1);
199 if (!commit || parse_commit(commit)) { 197 if (!commit || parse_commit(commit)) {