about summary refs log tree commit diff
path: root/ui-stats.c
diff options
context:
space:
mode:
authorJohn Keeping <john@keeping.me.uk>2015-08-14 12:47:17 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2015-08-14 15:46:51 +0200
commit892c5441f4af2f53a3b1906c4d7e458829e0cf0a (patch)
tree5db7624970e2663ccb61cb14c4bbc6cb03024272 /ui-stats.c
parentrefs: move layout to page function (diff)
downloadcgit-pink-892c5441f4af2f53a3b1906c4d7e458829e0cf0a.tar.gz
cgit-pink-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)
 
 	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();
 }