From f86a23ff537258d36bf8f1876fa7a4bede6673d8 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Sat, 6 Dec 2008 17:38:19 +0100 Subject: Add a 'stats' page to each repo This new page, which is disabled by default, can be used to print some statistics about the number of commits per period in the repository, where period can be either weeks, months, quarters or years. The function can be activated globally by setting 'enable-stats=1' in cgitrc and disabled for individual repos by setting 'repo.enable-stats=0'. Signed-off-by: Lars Hjemli --- ui-shared.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'ui-shared.c') diff --git a/ui-shared.c b/ui-shared.c index 224e5f3..0e688a0 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -641,6 +641,9 @@ void cgit_print_pageheader(struct cgit_context *ctx) ctx->qry.head, ctx->qry.sha1); cgit_diff_link("diff", NULL, hc(cmd, "diff"), ctx->qry.head, ctx->qry.sha1, ctx->qry.sha2, NULL); + if (ctx->repo->enable_stats) + reporevlink("stats", "stats", NULL, hc(cmd, "stats"), + ctx->qry.head, NULL, NULL); if (ctx->repo->readme) reporevlink("about", "about", NULL, hc(cmd, "about"), ctx->qry.head, NULL, -- cgit v1.2.1 From fb2f3f6c29bad733723152893c5246a756e4cada Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Sun, 7 Dec 2008 13:17:21 +0100 Subject: ui-stats: replace 'enable-stats' setting with 'max-stats' The new 'max-stats' and 'repo.max-stats' settings makes it possible to define the maximum statistics period, both globally and per repo. Hence, it is now feasible to allow statistics on repositories with a high commit frequency, like linux-2.6, by setting repo.max-stats to e.g. 'month'. Signed-off-by: Lars Hjemli --- ui-shared.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui-shared.c') diff --git a/ui-shared.c b/ui-shared.c index 0e688a0..97b9d46 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -641,7 +641,7 @@ void cgit_print_pageheader(struct cgit_context *ctx) ctx->qry.head, ctx->qry.sha1); cgit_diff_link("diff", NULL, hc(cmd, "diff"), ctx->qry.head, ctx->qry.sha1, ctx->qry.sha2, NULL); - if (ctx->repo->enable_stats) + if (ctx->repo->max_stats) reporevlink("stats", "stats", NULL, hc(cmd, "stats"), ctx->qry.head, NULL, NULL); if (ctx->repo->readme) -- cgit v1.2.1 From eaf2d25c162534efe7566119cf4b1cbeab217b51 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Sun, 7 Dec 2008 13:34:16 +0100 Subject: ui-shared: add and use cgit_stats_link() Signed-off-by: Lars Hjemli --- ui-shared.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'ui-shared.c') diff --git a/ui-shared.c b/ui-shared.c index 97b9d46..a5eb25f 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -363,6 +363,12 @@ void cgit_patch_link(char *name, char *title, char *class, char *head, reporevlink("patch", name, title, class, head, rev, NULL); } +void cgit_stats_link(char *name, char *title, char *class, char *head, + char *path) +{ + reporevlink("stats", name, title, class, head, NULL, path); +} + void cgit_object_link(struct object *obj) { char *page, *rev, *name; @@ -642,8 +648,8 @@ void cgit_print_pageheader(struct cgit_context *ctx) cgit_diff_link("diff", NULL, hc(cmd, "diff"), ctx->qry.head, ctx->qry.sha1, ctx->qry.sha2, NULL); if (ctx->repo->max_stats) - reporevlink("stats", "stats", NULL, hc(cmd, "stats"), - ctx->qry.head, NULL, NULL); + cgit_stats_link("stats", NULL, hc(cmd, "stats"), + ctx->qry.head, NULL); if (ctx->repo->readme) reporevlink("about", "about", NULL, hc(cmd, "about"), ctx->qry.head, NULL, -- cgit v1.2.1 From c3c925f4eca3e863bedaae4cfe237c3ad52092b6 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Sun, 7 Dec 2008 15:52:35 +0100 Subject: ui-shared: externalize add_hidden_formfields() This function will be reused by ui-stats.c in the next commit. Signed-off-by: Lars Hjemli --- ui-shared.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ui-shared.c') diff --git a/ui-shared.c b/ui-shared.c index a5eb25f..1bb30c2 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -555,7 +555,7 @@ int print_archive_ref(const char *refname, const unsigned char *sha1, return 0; } -void add_hidden_formfields(int incl_head, int incl_search, char *page) +void cgit_add_hidden_formfields(int incl_head, int incl_search, char *page) { char *url; @@ -610,7 +610,7 @@ void cgit_print_pageheader(struct cgit_context *ctx) cgit_summary_link(ctx->repo->name, ctx->repo->name, NULL, NULL); html(""); html("
\n"); - add_hidden_formfields(0, 1, ctx->qry.page); + cgit_add_hidden_formfields(0, 1, ctx->qry.page); html(" "); @@ -660,7 +660,7 @@ void cgit_print_pageheader(struct cgit_context *ctx) html_url_path(cgit_fileurl(ctx->qry.repo, "log", ctx->qry.path, NULL)); html("'>\n"); - add_hidden_formfields(1, 0, "log"); + cgit_add_hidden_formfields(1, 0, "log"); html("