diff options
| author | John Keeping | 2015-08-14 12:47:17 +0100 |
|---|---|---|
| committer | Jason A. Donenfeld | 2015-08-14 15:46:51 +0200 |
| commit | 892c5441f4af2f53a3b1906c4d7e458829e0cf0a (patch) | |
| tree | 5db7624970e2663ccb61cb14c4bbc6cb03024272 /ui-stats.c | |
| parent | 6d39dd1914dd0a904c606b079e8ef0f1643f2266 (diff) | |
| download | cgit-892c5441f4af2f53a3b1906c4d7e458829e0cf0a.tar.gz cgit-892c5441f4af2f53a3b1906c4d7e458829e0cf0a.tar.bz2 cgit-892c5441f4af2f53a3b1906c4d7e458829e0cf0a.zip | |
stats: move layout into page function
This also allows us to return proper HTTP error codes for invalid
requests.
Signed-off-by: John Keeping <john@keeping.me.uk>
Diffstat (limited to 'ui-stats.c')
| -rw-r--r-- | ui-stats.c | 8 |
1 files changed, 6 insertions, 2 deletions
| @@ -372,11 +372,13 @@ void cgit_show_stats(void) | |||
| 372 | 372 | ||
| 373 | i = cgit_find_stats_period(code, &period); | 373 | i = cgit_find_stats_period(code, &period); |
| 374 | if (!i) { | 374 | if (!i) { |
| 375 | cgit_print_error("Unknown statistics type: %c", code[0]); | 375 | cgit_print_error_page(404, "Not found", |
| 376 | "Unknown statistics type: %c", code[0]); | ||
| 376 | return; | 377 | return; |
| 377 | } | 378 | } |
| 378 | if (i > ctx.repo->max_stats) { | 379 | if (i > ctx.repo->max_stats) { |
| 379 | cgit_print_error("Statistics type disabled: %s", period->name); | 380 | cgit_print_error_page(400, "Bad request", |
| 381 | "Statistics type disabled: %s", period->name); | ||
| 380 | return; | 382 | return; |
| 381 | } | 383 | } |
| 382 | authors = collect_stats(period); | 384 | authors = collect_stats(period); |
| @@ -387,6 +389,7 @@ void cgit_show_stats(void) | |||
| 387 | if (!top) | 389 | if (!top) |
| 388 | top = 10; | 390 | top = 10; |
| 389 | 391 | ||
| 392 | cgit_print_layout_start(); | ||
| 390 | html("<div class='cgit-panel'>"); | 393 | html("<div class='cgit-panel'>"); |
| 391 | html("<b>stat options</b>"); | 394 | html("<b>stat options</b>"); |
| 392 | html("<form method='get' action=''>"); | 395 | html("<form method='get' action=''>"); |
| @@ -421,5 +424,6 @@ void cgit_show_stats(void) | |||
| 421 | } | 424 | } |
| 422 | html("</h2>"); | 425 | html("</h2>"); |
| 423 | print_authors(&authors, top, period); | 426 | print_authors(&authors, top, period); |
| 427 | cgit_print_layout_end(); | ||
| 424 | } | 428 | } |
| 425 | 429 | ||
