about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--cgit.css27
-rw-r--r--cmd.c2
-rw-r--r--html.c8
-rw-r--r--html.h1
-rw-r--r--ui-commit.c10
-rw-r--r--ui-diff.c83
-rw-r--r--ui-diff.h4
-rw-r--r--ui-stats.c51
8 files changed, 124 insertions, 62 deletions
diff --git a/cgit.css b/cgit.css index 1d90057..55afa94 100644 --- a/cgit.css +++ b/cgit.css
@@ -331,6 +331,33 @@ table.commit-info {
331 margin-top: 1.5em; 331 margin-top: 1.5em;
332} 332}
333 333
334div.cgit-panel {
335 float: right;
336 margin-top: 1.5em;
337}
338
339div.cgit-panel table {
340 border-collapse: collapse;
341 border: solid 1px #aaa;
342 background-color: #eee;
343}
344
345div.cgit-panel th {
346 text-align: center;
347}
348
349div.cgit-panel td {
350 padding: 0.25em 0.5em;
351}
352
353div.cgit-panel td.label {
354 padding-right: 0.5em;
355}
356
357div.cgit-panel td.ctrl {
358 padding-left: 0.5em;
359}
360
334table.commit-info th { 361table.commit-info th {
335 text-align: left; 362 text-align: left;
336 font-weight: normal; 363 font-weight: normal;
diff --git a/cmd.c b/cmd.c index d114eb3..5a3d157 100644 --- a/cmd.c +++ b/cmd.c
@@ -56,7 +56,7 @@ static void commit_fn(struct cgit_context *ctx)
56 56
57static void diff_fn(struct cgit_context *ctx) 57static void diff_fn(struct cgit_context *ctx)
58{ 58{
59 cgit_print_diff(ctx->qry.sha1, ctx->qry.sha2, ctx->qry.path); 59 cgit_print_diff(ctx->qry.sha1, ctx->qry.sha2, ctx->qry.path, 1);
60} 60}
61 61
62static void info_fn(struct cgit_context *ctx) 62static void info_fn(struct cgit_context *ctx)
diff --git a/html.c b/html.c index a0f6db4..4a18a57 100644 --- a/html.c +++ b/html.c
@@ -213,6 +213,14 @@ void html_option(const char *value, const char *text, const char *selected_value
213 html("</option>\n"); 213 html("</option>\n");
214} 214}
215 215
216void html_intoption(int value, const char *text, int selected_value)
217{
218 htmlf("<option value='%d'%s>", value,
219 value == selected_value ? " selected='selected'" : "");
220 html_txt(text);
221 html("</option>");
222}
223
216void html_link_open(const char *url, const char *title, const char *class) 224void html_link_open(const char *url, const char *title, const char *class)
217{ 225{
218 html("<a href='"); 226 html("<a href='");
diff --git a/html.h b/html.h index 1135fb8..20e1dc2 100644 --- a/html.h +++ b/html.h
@@ -17,6 +17,7 @@ extern void html_url_path(const char *txt);
17extern void html_url_arg(const char *txt); 17extern void html_url_arg(const char *txt);
18extern void html_hidden(const char *name, const char *value); 18extern void html_hidden(const char *name, const char *value);
19extern void html_option(const char *value, const char *text, const char *selected_value); 19extern void html_option(const char *value, const char *text, const char *selected_value);
20extern void html_intoption(int value, const char *text, int selected_value);
20extern void html_link_open(const char *url, const char *title, const char *class); 21extern void html_link_open(const char *url, const char *title, const char *class);
21extern void html_link_close(void); 22extern void html_link_close(void);
22extern void html_fileperm(unsigned short mode); 23extern void html_fileperm(unsigned short mode);
diff --git a/ui-commit.c b/ui-commit.c index 2da9fcf..a69dec6 100644 --- a/ui-commit.c +++ b/ui-commit.c
@@ -39,7 +39,8 @@ void cgit_print_commit(char *hex, const char *prefix)
39 format_note(NULL, sha1, &notes, PAGE_ENCODING, 0); 39 format_note(NULL, sha1, &notes, PAGE_ENCODING, 0);
40 40
41 load_ref_decorations(DECORATE_FULL_REFS); 41 load_ref_decorations(DECORATE_FULL_REFS);
42 42
43 cgit_print_diff_ctrls();
43 html("<table summary='commit info' class='commit-info'>\n"); 44 html("<table summary='commit info' class='commit-info'>\n");
44 html("<tr><th>author</th><td>"); 45 html("<tr><th>author</th><td>");
45 html_txt(info->author); 46 html_txt(info->author);
@@ -64,11 +65,6 @@ void cgit_print_commit(char *hex, const char *prefix)
64 cgit_commit_link(tmp, NULL, NULL, ctx.qry.head, tmp, prefix, 0); 65 cgit_commit_link(tmp, NULL, NULL, ctx.qry.head, tmp, prefix, 0);
65 html(" ("); 66 html(" (");
66 cgit_patch_link("patch", NULL, NULL, NULL, tmp, prefix); 67 cgit_patch_link("patch", NULL, NULL, NULL, tmp, prefix);
67 html(") (");
68 if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff))
69 cgit_commit_link("unidiff", NULL, NULL, ctx.qry.head, tmp, prefix, 1);
70 else
71 cgit_commit_link("side-by-side diff", NULL, NULL, ctx.qry.head, tmp, prefix, 1);
72 html(")</td></tr>\n"); 68 html(")</td></tr>\n");
73 html("<tr><th>tree</th><td colspan='2' class='sha1'>"); 69 html("<tr><th>tree</th><td colspan='2' class='sha1'>");
74 tmp = xstrdup(hex); 70 tmp = xstrdup(hex);
@@ -139,7 +135,7 @@ void cgit_print_commit(char *hex, const char *prefix)
139 tmp = sha1_to_hex(commit->parents->item->object.sha1); 135 tmp = sha1_to_hex(commit->parents->item->object.sha1);
140 else 136 else
141 tmp = NULL; 137 tmp = NULL;
142 cgit_print_diff(ctx.qry.sha1, tmp, prefix); 138 cgit_print_diff(ctx.qry.sha1, tmp, prefix, 0);
143 } 139 }
144 strbuf_release(&notes); 140 strbuf_release(&notes);
145 cgit_free_commitinfo(info); 141 cgit_free_commitinfo(info);
diff --git a/ui-diff.c b/ui-diff.c index d21541b..868ceec 100644 --- a/ui-diff.c +++ b/ui-diff.c
@@ -167,7 +167,7 @@ static void inspect_filepair(struct diff_filepair *pair)
167void cgit_print_diffstat(const unsigned char *old_sha1, 167void cgit_print_diffstat(const unsigned char *old_sha1,
168 const unsigned char *new_sha1, const char *prefix) 168 const unsigned char *new_sha1, const char *prefix)
169{ 169{
170 int i, save_context = ctx.qry.context; 170 int i;
171 171
172 html("<div class='diffstat-header'>"); 172 html("<div class='diffstat-header'>");
173 cgit_diff_link("Diffstat", NULL, NULL, ctx.qry.head, ctx.qry.sha1, 173 cgit_diff_link("Diffstat", NULL, NULL, ctx.qry.head, ctx.qry.sha1,
@@ -177,19 +177,6 @@ void cgit_print_diffstat(const unsigned char *old_sha1,
177 html_txt(prefix); 177 html_txt(prefix);
178 html("')"); 178 html("')");
179 } 179 }
180 html(" (");
181 ctx.qry.context = (save_context > 0 ? save_context : 3) << 1;
182 cgit_self_link("more", NULL, NULL, &ctx);
183 html("/");
184 ctx.qry.context = (save_context > 3 ? save_context : 3) >> 1;
185 cgit_self_link("less", NULL, NULL, &ctx);
186 ctx.qry.context = save_context;
187 html(" context)");
188 html(" (");
189 ctx.qry.ignorews = (ctx.qry.ignorews + 1) % 2;
190 cgit_self_link(ctx.qry.ignorews ? "ignore" : "show", NULL, NULL, &ctx);
191 ctx.qry.ignorews = (ctx.qry.ignorews + 1) % 2;
192 html(" whitespace changes)");
193 html("</div>"); 180 html("</div>");
194 html("<table summary='diffstat' class='diffstat'>"); 181 html("<table summary='diffstat' class='diffstat'>");
195 max_changes = 0; 182 max_changes = 0;
@@ -278,19 +265,6 @@ static void header(unsigned char *sha1, char *path1, int mode1,
278 html("</div>"); 265 html("</div>");
279} 266}
280 267
281static void print_ssdiff_link()
282{
283 if (!strcmp(ctx.qry.page, "diff")) {
284 if (use_ssdiff)
285 cgit_diff_link("Unidiff", NULL, NULL, ctx.qry.head,
286 ctx.qry.sha1, ctx.qry.sha2, ctx.qry.path, 1);
287 else
288 cgit_diff_link("Side-by-side diff", NULL, NULL,
289 ctx.qry.head, ctx.qry.sha1,
290 ctx.qry.sha2, ctx.qry.path, 1);
291 }
292}
293
294static void filepair_cb(struct diff_filepair *pair) 268static void filepair_cb(struct diff_filepair *pair)
295{ 269{
296 unsigned long old_size = 0; 270 unsigned long old_size = 0;
@@ -330,7 +304,56 @@ static void filepair_cb(struct diff_filepair *pair)
330 cgit_ssdiff_footer(); 304 cgit_ssdiff_footer();
331} 305}
332 306
333void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefix) 307void cgit_print_diff_ctrls()
308{
309 int i, curr;
310
311 html("<div class='cgit-panel'>");
312 html("<b>diff options</b>");
313 html("<form method='get' action='.'>");
314 cgit_add_hidden_formfields(1, 0, ctx.qry.page);
315 html("<table>");
316 html("<tr><td colspan='2'/></tr>");
317 html("<tr>");
318 html("<td class='label'>context:</td>");
319 html("<td class='ctrl'>");
320 html("<select name='context' onchange='this.form.submit();'>");
321 curr = ctx.qry.context;
322 if (!curr)
323 curr = 3;
324 for (i = 1; i <= 10; i++)
325 html_intoption(i, fmt("%d", i), curr);
326 for (i = 15; i <= 40; i += 5)
327 html_intoption(i, fmt("%d", i), curr);
328 html("</select>");
329 html("</td>");
330 html("</tr><tr>");
331 html("<td class='label'>space:</td>");
332 html("<td class='ctrl'>");
333 html("<select name='ignorews' onchange='this.form.submit();'>");
334 html_intoption(0, "include", ctx.qry.ignorews);
335 html_intoption(1, "ignore", ctx.qry.ignorews);
336 html("</select>");
337 html("</td>");
338 html("</tr><tr>");
339 html("<td class='label'>mode:</td>");
340 html("<td class='ctrl'>");
341 html("<select name='ss' onchange='this.form.submit();'>");
342 curr = ctx.qry.ssdiff;
343 if (!curr && ctx.cfg.ssdiff)
344 curr = 1;
345 html_intoption(0, "unified", curr);
346 html_intoption(1, "ssdiff", curr);
347 html("</select></td></tr>");
348 html("<tr><td/><td class='ctrl'>");
349 html("<noscript><input type='submit' value='reload'/></noscript>");
350 html("</td></tr></table>");
351 html("</form>");
352 html("</div>");
353}
354
355void cgit_print_diff(const char *new_rev, const char *old_rev,
356 const char *prefix, int show_ctrls)
334{ 357{
335 enum object_type type; 358 enum object_type type;
336 unsigned long size; 359 unsigned long size;
@@ -373,7 +396,9 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefi
373 if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff)) 396 if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff))
374 use_ssdiff = 1; 397 use_ssdiff = 1;
375 398
376 print_ssdiff_link(); 399 if (show_ctrls)
400 cgit_print_diff_ctrls();
401
377 cgit_print_diffstat(old_rev_sha1, new_rev_sha1, prefix); 402 cgit_print_diffstat(old_rev_sha1, new_rev_sha1, prefix);
378 403
379 if (use_ssdiff) { 404 if (use_ssdiff) {
diff --git a/ui-diff.h b/ui-diff.h index 12d0c62..0161ffb 100644 --- a/ui-diff.h +++ b/ui-diff.h
@@ -1,11 +1,13 @@
1#ifndef UI_DIFF_H 1#ifndef UI_DIFF_H
2#define UI_DIFF_H 2#define UI_DIFF_H
3 3
4extern void cgit_print_diff_ctrls();
5
4extern void cgit_print_diffstat(const unsigned char *old_sha1, 6extern void cgit_print_diffstat(const unsigned char *old_sha1,
5 const unsigned char *new_sha1); 7 const unsigned char *new_sha1);
6 8
7extern void cgit_print_diff(const char *new_hex, const char *old_hex, 9extern void cgit_print_diff(const char *new_hex, const char *old_hex,
8 const char *prefix); 10 const char *prefix, int show_ctrls);
9 11
10extern struct diff_filespec *cgit_get_current_old_file(void); 12extern struct diff_filespec *cgit_get_current_old_file(void);
11extern struct diff_filespec *cgit_get_current_new_file(void); 13extern struct diff_filespec *cgit_get_current_new_file(void);
diff --git a/ui-stats.c b/ui-stats.c index 2a0c174..36e17d9 100644 --- a/ui-stats.c +++ b/ui-stats.c
@@ -386,6 +386,33 @@ void cgit_show_stats(struct cgit_context *ctx)
386 top = ctx->qry.ofs; 386 top = ctx->qry.ofs;
387 if (!top) 387 if (!top)
388 top = 10; 388 top = 10;
389
390 html("<div class='cgit-panel'>");
391 html("<b>stat options</b>");
392 html("<form method='get' action=''>");
393 cgit_add_hidden_formfields(1, 0, "stats");
394 html("<table><tr><td colspan='2'/></tr>");
395 if (ctx->repo->max_stats > 1) {
396 html("<tr><td class='label'>Period:</td>");
397 html("<td class='ctrl'><select name='period' onchange='this.form.submit();'>");
398 for (i = 0; i < ctx->repo->max_stats; i++)
399 html_option(fmt("%c", periods[i].code),
400 periods[i].name, fmt("%c", period->code));
401 html("</select></td></tr>");
402 }
403 html("<tr><td class='label'>Authors:</td>");
404 html("<td class='ctrl'><select name='ofs' onchange='this.form.submit();'>");
405 html_intoption(10, "10", top);
406 html_intoption(25, "25", top);
407 html_intoption(50, "50", top);
408 html_intoption(100, "100", top);
409 html_intoption(-1, "all", top);
410 html("</select></td><tr>");
411 html("<tr><td/><td class='ctrl'>");
412 html("<noscript><input type='submit' value='Reload'/></noscript>");
413 html("</td></tr></table>");
414 html("</form>");
415 html("</div>");
389 htmlf("<h2>Commits per author per %s", period->name); 416 htmlf("<h2>Commits per author per %s", period->name);
390 if (ctx->qry.path) { 417 if (ctx->qry.path) {
391 html(" (path '"); 418 html(" (path '");
@@ -393,30 +420,6 @@ void cgit_show_stats(struct cgit_context *ctx)
393 html("')"); 420 html("')");
394 } 421 }
395 html("</h2>"); 422 html("</h2>");
396
397 html("<form method='get' action='' style='float: right; text-align: right;'>");
398 cgit_add_hidden_formfields(1, 0, "stats");
399 if (ctx->repo->max_stats > 1) {
400 html("Period: ");
401 html("<select name='period' onchange='this.form.submit();'>");
402 for (i = 0; i < ctx->repo->max_stats; i++)
403 htmlf("<option value='%c'%s>%s</option>",
404 periods[i].code,
405 period == &periods[i] ? " selected" : "",
406 periods[i].name);
407 html("</select><br/><br/>");
408 }
409 html("Authors: ");
410 html("");
411 html("<select name='ofs' onchange='this.form.submit();'>");
412 htmlf("<option value='10'%s>10</option>", top == 10 ? " selected" : "");
413 htmlf("<option value='25'%s>25</option>", top == 25 ? " selected" : "");
414 htmlf("<option value='50'%s>50</option>", top == 50 ? " selected" : "");
415 htmlf("<option value='100'%s>100</option>", top == 100 ? " selected" : "");
416 htmlf("<option value='-1'%s>All</option>", top == -1 ? " selected" : "");
417 html("</select>");
418 html("<noscript>&nbsp;&nbsp;<input type='submit' value='Reload'/></noscript>");
419 html("</form>");
420 print_authors(&authors, top, period); 423 print_authors(&authors, top, period);
421} 424}
422 425