-rw-r--r-- | cgit.c | 3 | ||||
-rw-r--r-- | cgit.h | 2 | ||||
-rw-r--r-- | cgitrc | 5 | ||||
-rw-r--r-- | shared.c | 6 | ||||
-rw-r--r-- | ui-commit.c | 2 |
5 files changed, 17 insertions, 1 deletions
@@ -80,5 +80,6 @@ static void cgit_print_repo_page(struct cacheitem *item) setenv("GIT_DIR", cgit_repo->path, 1); - if (cgit_query_page && !strcmp(cgit_query_page, "snapshot")) { + if (cgit_repo->snapshots && cgit_query_page && + !strcmp(cgit_query_page, "snapshot")) { cgit_print_snapshot(item, cgit_query_sha1, "zip", cgit_repo->url, cgit_query_name); @@ -22,4 +22,5 @@ struct repoinfo { char *desc; char *owner; + int snapshots; }; @@ -62,4 +63,5 @@ extern char *cgit_cache_root; extern int cgit_nocache; +extern int cgit_snapshots; extern int cgit_max_lock_attempts; extern int cgit_cache_root_ttl; @@ -9,4 +9,8 @@ +## Enable/disable snapshots by default. This can be overridden per repo +#snapshots=0 + + ## Specify a root for virtual urls. This makes cgit generate urls like ## @@ -78,2 +82,3 @@ #repo.path=/pub/git/cgit #repo.owner=Lars Hjemli +#repo.snapshots=1 # override a sitewide snapshot-setting @@ -21,4 +21,5 @@ char *cgit_cache_root = "/var/cache/cgit"; int cgit_nocache = 0; +int cgit_snapshots = 0; int cgit_max_lock_attempts = 5; int cgit_cache_root_ttl = 5; @@ -84,4 +85,5 @@ struct repoinfo *add_repo(const char *url) ret->desc = NULL; ret->owner = NULL; + ret->snapshots = cgit_snapshots; return ret; } @@ -101,4 +103,6 @@ void cgit_global_config_cb(const char *name, const char *value) else if (!strcmp(name, "nocache")) cgit_nocache = atoi(value); + else if (!strcmp(name, "snapshots")) + cgit_snapshots = atoi(value); else if (!strcmp(name, "cache-root")) cgit_cache_root = xstrdup(value); @@ -123,4 +127,6 @@ void cgit_global_config_cb(const char *name, const char *value) else if (cgit_repo && !strcmp(name, "repo.owner")) cgit_repo->owner = xstrdup(value); + else if (cgit_repo && !strcmp(name, "repo.snapshots")) + cgit_repo->snapshots = atoi(value); } diff --git a/ui-commit.c b/ui-commit.c index de3f2cf..3618800 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -170,4 +170,5 @@ void cgit_print_commit(const char *hex) sha1_to_hex(p->item->object.sha1)); } + if (cgit_repo->snapshots) { htmlf("<tr><th>download</th><td colspan='2' class='sha1'><a href='"); filename = fmt("%s-%s.zip", cgit_query_repo, hex); @@ -175,4 +176,5 @@ void cgit_print_commit(const char *hex) fmt("id=%s&name=%s", hex, filename))); htmlf("'>%s</a></td></tr>", filename); + } html("</table>\n"); |