summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2007-02-08 13:47:56 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2007-02-08 13:47:56 (UTC)
commitac70cb4795c90db02917db63d169b0fadfe9fb99 (patch) (side-by-side diff)
treebf7a5c4c8c2789cda2dd511f0a180df279a0b389
parentab2ab95f09994560f62fd631f07d3b6e3577aa6e (diff)
downloadcgit-ac70cb4795c90db02917db63d169b0fadfe9fb99.zip
cgit-ac70cb4795c90db02917db63d169b0fadfe9fb99.tar.gz
cgit-ac70cb4795c90db02917db63d169b0fadfe9fb99.tar.bz2
Make snapshot feature configurable
Snapshots can now be enabled/disabled by default for all repositories in cgitrc with param "snapshots". Additionally, any repo can override the default setting with param "repo.snapshots". By default, no snapshotting is enabled. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c3
-rw-r--r--cgit.h2
-rw-r--r--cgitrc5
-rw-r--r--shared.c6
-rw-r--r--ui-commit.c12
5 files changed, 22 insertions, 6 deletions
diff --git a/cgit.c b/cgit.c
index 2795ecc..7b7afba 100644
--- a/cgit.c
+++ b/cgit.c
@@ -81,3 +81,4 @@ static void cgit_print_repo_page(struct cacheitem *item)
- 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",
diff --git a/cgit.h b/cgit.h
index 03c2fdb..6e95673 100644
--- a/cgit.h
+++ b/cgit.h
@@ -23,2 +23,3 @@ struct repoinfo {
char *owner;
+ int snapshots;
};
@@ -63,2 +64,3 @@ extern char *cgit_cache_root;
extern int cgit_nocache;
+extern int cgit_snapshots;
extern int cgit_max_lock_attempts;
diff --git a/cgitrc b/cgitrc
index d45f9c2..3bae642 100644
--- a/cgitrc
+++ b/cgitrc
@@ -10,2 +10,6 @@
+## 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
@@ -79 +83,2 @@
#repo.owner=Lars Hjemli
+#repo.snapshots=1 # override a sitewide snapshot-setting
diff --git a/shared.c b/shared.c
index 5757d0c..531d8c0 100644
--- a/shared.c
+++ b/shared.c
@@ -22,2 +22,3 @@ char *cgit_cache_root = "/var/cache/cgit";
int cgit_nocache = 0;
+int cgit_snapshots = 0;
int cgit_max_lock_attempts = 5;
@@ -85,2 +86,3 @@ struct repoinfo *add_repo(const char *url)
ret->owner = NULL;
+ ret->snapshots = cgit_snapshots;
return ret;
@@ -102,2 +104,4 @@ void cgit_global_config_cb(const char *name, const char *value)
cgit_nocache = atoi(value);
+ else if (!strcmp(name, "snapshots"))
+ cgit_snapshots = atoi(value);
else if (!strcmp(name, "cache-root"))
@@ -124,2 +128,4 @@ void cgit_global_config_cb(const char *name, const char *value)
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
@@ -171,7 +171,9 @@ void cgit_print_commit(const char *hex)
}
- htmlf("<tr><th>download</th><td colspan='2' class='sha1'><a href='");
- filename = fmt("%s-%s.zip", cgit_query_repo, hex);
- html_attr(cgit_pageurl(cgit_query_repo, "snapshot",
- fmt("id=%s&name=%s", hex, filename)));
- htmlf("'>%s</a></td></tr>", filename);
+ 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);
+ html_attr(cgit_pageurl(cgit_query_repo, "snapshot",
+ fmt("id=%s&name=%s", hex, filename)));
+ htmlf("'>%s</a></td></tr>", filename);
+ }