diff options
author | John Keeping <john@keeping.me.uk> | 2015-04-05 16:54:59 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2015-04-07 15:32:28 +0200 |
commit | ad26c3e7b2cc43b2246ceacad229d9913f6499cd (patch) | |
tree | 4128af9e45267c99b0a4ed86961087f7b9751890 | |
parent | f881828dc4076b125a10978d3fdb669614b7dd23 (diff) | |
download | cgit-ad26c3e7b2cc43b2246ceacad229d9913f6499cd.tar.gz |
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>
-rw-r--r-- | cmd.c | 2 | ||||
-rw-r--r-- | ui-stats.c | 8 |
2 files changed, 7 insertions, 3 deletions
@@ -158,7 +158,7 @@ struct cgit_cmd *cgit_get_cmd(void) def_cmd(refs, 1, 0, 0, 0), def_cmd(repolist, 0, 0, 0, 0), def_cmd(snapshot, 1, 0, 0, 0), - def_cmd(stats, 1, 1, 1, 0), + def_cmd(stats, 1, 0, 1, 0), def_cmd(summary, 1, 1, 0, 0), def_cmd(tag, 1, 1, 0, 0), def_cmd(tree, 1, 1, 1, 0), @@ -372,11 +372,13 @@ void cgit_show_stats(void) i = cgit_find_stats_period(code, &period); if (!i) { - cgit_print_error("Unknown statistics type: %c", code[0]); + cgit_print_error_page(404, "Not found", + "Unknown statistics type: %c", code[0]); return; } if (i > ctx.repo->max_stats) { - cgit_print_error("Statistics type disabled: %s", period->name); + cgit_print_error_page(400, "Bad request", + "Statistics type disabled: %s", period->name); return; } authors = collect_stats(period); @@ -387,6 +389,7 @@ void cgit_show_stats(void) if (!top) top = 10; + cgit_print_layout_start(); html("<div class='cgit-panel'>"); html("<b>stat options</b>"); html("<form method='get' action=''>"); @@ -421,5 +424,6 @@ void cgit_show_stats(void) } html("</h2>"); print_authors(&authors, top, period); + cgit_print_layout_end(); } |