author | Lars Hjemli <hjemli@gmail.com> | 2007-02-08 13:47:56 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-02-08 13:47:56 (UTC) |
commit | ac70cb4795c90db02917db63d169b0fadfe9fb99 (patch) (unidiff) | |
tree | bf7a5c4c8c2789cda2dd511f0a180df279a0b389 | |
parent | ab2ab95f09994560f62fd631f07d3b6e3577aa6e (diff) | |
download | cgit-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>
-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 | 12 |
5 files changed, 22 insertions, 6 deletions
@@ -81,3 +81,4 @@ static void cgit_print_repo_page(struct cacheitem *item) | |||
81 | 81 | ||
82 | if (cgit_query_page && !strcmp(cgit_query_page, "snapshot")) { | 82 | if (cgit_repo->snapshots && cgit_query_page && |
83 | !strcmp(cgit_query_page, "snapshot")) { | ||
83 | cgit_print_snapshot(item, cgit_query_sha1, "zip", | 84 | cgit_print_snapshot(item, cgit_query_sha1, "zip", |
@@ -23,2 +23,3 @@ struct repoinfo { | |||
23 | char *owner; | 23 | char *owner; |
24 | int snapshots; | ||
24 | }; | 25 | }; |
@@ -63,2 +64,3 @@ extern char *cgit_cache_root; | |||
63 | extern int cgit_nocache; | 64 | extern int cgit_nocache; |
65 | extern int cgit_snapshots; | ||
64 | extern int cgit_max_lock_attempts; | 66 | extern int cgit_max_lock_attempts; |
@@ -10,2 +10,6 @@ | |||
10 | 10 | ||
11 | ## Enable/disable snapshots by default. This can be overridden per repo | ||
12 | #snapshots=0 | ||
13 | |||
14 | |||
11 | ## Specify a root for virtual urls. This makes cgit generate urls like | 15 | ## Specify a root for virtual urls. This makes cgit generate urls like |
@@ -79 +83,2 @@ | |||
79 | #repo.owner=Lars Hjemli | 83 | #repo.owner=Lars Hjemli |
84 | #repo.snapshots=1 # override a sitewide snapshot-setting | ||
@@ -22,2 +22,3 @@ char *cgit_cache_root = "/var/cache/cgit"; | |||
22 | int cgit_nocache = 0; | 22 | int cgit_nocache = 0; |
23 | int cgit_snapshots = 0; | ||
23 | int cgit_max_lock_attempts = 5; | 24 | int cgit_max_lock_attempts = 5; |
@@ -85,2 +86,3 @@ struct repoinfo *add_repo(const char *url) | |||
85 | ret->owner = NULL; | 86 | ret->owner = NULL; |
87 | ret->snapshots = cgit_snapshots; | ||
86 | return ret; | 88 | return ret; |
@@ -102,2 +104,4 @@ void cgit_global_config_cb(const char *name, const char *value) | |||
102 | cgit_nocache = atoi(value); | 104 | cgit_nocache = atoi(value); |
105 | else if (!strcmp(name, "snapshots")) | ||
106 | cgit_snapshots = atoi(value); | ||
103 | else if (!strcmp(name, "cache-root")) | 107 | else if (!strcmp(name, "cache-root")) |
@@ -124,2 +128,4 @@ void cgit_global_config_cb(const char *name, const char *value) | |||
124 | cgit_repo->owner = xstrdup(value); | 128 | cgit_repo->owner = xstrdup(value); |
129 | else if (cgit_repo && !strcmp(name, "repo.snapshots")) | ||
130 | cgit_repo->snapshots = atoi(value); | ||
125 | } | 131 | } |
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) | |||
171 | } | 171 | } |
172 | htmlf("<tr><th>download</th><td colspan='2' class='sha1'><a href='"); | 172 | if (cgit_repo->snapshots) { |
173 | filename = fmt("%s-%s.zip", cgit_query_repo, hex); | 173 | htmlf("<tr><th>download</th><td colspan='2' class='sha1'><a href='"); |
174 | html_attr(cgit_pageurl(cgit_query_repo, "snapshot", | 174 | filename = fmt("%s-%s.zip", cgit_query_repo, hex); |
175 | fmt("id=%s&name=%s", hex, filename))); | 175 | html_attr(cgit_pageurl(cgit_query_repo, "snapshot", |
176 | htmlf("'>%s</a></td></tr>", filename); | 176 | fmt("id=%s&name=%s", hex, filename))); |
177 | htmlf("'>%s</a></td></tr>", filename); | ||
178 | } | ||
177 | 179 | ||