about summary refs log tree commit diff stats
path: root/ui-stats.c
diff options
context:
space:
mode:
authorJohn Keeping2015-08-14 12:47:17 +0100
committerJason A. Donenfeld2015-08-14 15:46:51 +0200
commit892c5441f4af2f53a3b1906c4d7e458829e0cf0a (patch)
tree5db7624970e2663ccb61cb14c4bbc6cb03024272 /ui-stats.c
parentrefs: move layout to page function (diff)
downloadcgit-892c5441f4af2f53a3b1906c4d7e458829e0cf0a.tar.gz
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.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/ui-stats.c b/ui-stats.c index 9cd8247..74ce0f7 100644 --- a/ui-stats.c +++ b/ui-stats.c
@@ -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