diff options
author | Jason A. Donenfeld | 2012-07-11 04:24:01 +0200 |
---|---|---|
committer | Jason A. Donenfeld | 2012-07-12 20:01:46 +0200 |
commit | b56be4ba3a942dd1978fe4bfecd9afc35aab0027 (patch) | |
tree | 1f193f16b3b54e92d1a23a42ed3a9eced13acc0f | |
parent | 45555512ba63b823c6340875254563ea05737668 (diff) | |
download | cgit-b56be4ba3a942dd1978fe4bfecd9afc35aab0027.tar.gz cgit-b56be4ba3a942dd1978fe4bfecd9afc35aab0027.tar.bz2 cgit-b56be4ba3a942dd1978fe4bfecd9afc35aab0027.zip |
scan-tree: Support gitweb.description.
Use gitweb.description instead of description file to determine
description, if option is enabled.
-rw-r--r-- | cgit.c | 3 | ||||
-rw-r--r-- | cgit.h | 1 | ||||
-rw-r--r-- | cgitrc.5.txt | 7 | ||||
-rw-r--r-- | scan-tree.c | 24 |
4 files changed, 28 insertions, 7 deletions
@@ -163,6 +163,8 @@ void config_cb(const char *name, const char *value) | |||
163 | ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); | 163 | ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); |
164 | else if (!strcmp(name, "enable-filter-overrides")) | 164 | else if (!strcmp(name, "enable-filter-overrides")) |
165 | ctx.cfg.enable_filter_overrides = atoi(value); | 165 | ctx.cfg.enable_filter_overrides = atoi(value); |
166 | else if (!strcmp(name, "enable-gitweb-desc")) | ||
167 | ctx.cfg.enable_gitweb_desc = atoi(value); | ||
166 | else if (!strcmp(name, "enable-gitweb-owner")) | 168 | else if (!strcmp(name, "enable-gitweb-owner")) |
167 | ctx.cfg.enable_gitweb_owner = atoi(value); | 169 | ctx.cfg.enable_gitweb_owner = atoi(value); |
168 | else if (!strcmp(name, "enable-http-clone")) | 170 | else if (!strcmp(name, "enable-http-clone")) |
@@ -336,6 +338,7 @@ static void prepare_context(struct cgit_context *ctx) | |||
336 | ctx->cfg.css = "/cgit.css"; | 338 | ctx->cfg.css = "/cgit.css"; |
337 | ctx->cfg.logo = "/cgit.png"; | 339 | ctx->cfg.logo = "/cgit.png"; |
338 | ctx->cfg.local_time = 0; | 340 | ctx->cfg.local_time = 0; |
341 | ctx->cfg.enable_gitweb_desc = 1; | ||
339 | ctx->cfg.enable_gitweb_owner = 1; | 342 | ctx->cfg.enable_gitweb_owner = 1; |
340 | ctx->cfg.enable_http_clone = 1; | 343 | ctx->cfg.enable_http_clone = 1; |
341 | ctx->cfg.enable_tree_linenumbers = 1; | 344 | ctx->cfg.enable_tree_linenumbers = 1; |
@@ -199,6 +199,7 @@ struct cgit_config { | |||
199 | int embedded; | 199 | int embedded; |
200 | int enable_filter_overrides; | 200 | int enable_filter_overrides; |
201 | int enable_gitweb_owner; | 201 | int enable_gitweb_owner; |
202 | int enable_gitweb_desc; | ||
202 | int enable_http_clone; | 203 | int enable_http_clone; |
203 | int enable_index_links; | 204 | int enable_index_links; |
204 | int enable_commit_graph; | 205 | int enable_commit_graph; |
diff --git a/cgitrc.5.txt b/cgitrc.5.txt index a72241f..86a19a9 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt | |||
@@ -106,6 +106,13 @@ enable-filter-overrides:: | |||
106 | Flag which, when set to "1", allows all filter settings to be | 106 | Flag which, when set to "1", allows all filter settings to be |
107 | overridden in repository-specific cgitrc files. Default value: none. | 107 | overridden in repository-specific cgitrc files. Default value: none. |
108 | 108 | ||
109 | enable-gitweb-desc:: | ||
110 | If set to "1" and scan-path is enabled, we first check each repository | ||
111 | for the git config value "gitweb.description" to determine the owner. | ||
112 | Otherwise, the description is read from a file titled "description" | ||
113 | inside of the repository directory. | ||
114 | Default value: "1". See also: scan-path. | ||
115 | |||
109 | enable-gitweb-owner:: | 116 | enable-gitweb-owner:: |
110 | If set to "1" and scan-path is enabled, we first check each repository | 117 | If set to "1" and scan-path is enabled, we first check each repository |
111 | for the git config value "gitweb.owner" to determine the owner. | 118 | for the git config value "gitweb.owner" to determine the owner. |
diff --git a/scan-tree.c b/scan-tree.c index 378d795..3d4e417 100644 --- a/scan-tree.c +++ b/scan-tree.c | |||
@@ -48,19 +48,24 @@ static int is_git_dir(const char *path) | |||
48 | struct cgit_repo *repo; | 48 | struct cgit_repo *repo; |
49 | repo_config_fn config_fn; | 49 | repo_config_fn config_fn; |
50 | char *owner; | 50 | char *owner; |
51 | char *desc; | ||
51 | 52 | ||
52 | static void repo_config(const char *name, const char *value) | 53 | static void repo_config(const char *name, const char *value) |
53 | { | 54 | { |
54 | config_fn(repo, name, value); | 55 | config_fn(repo, name, value); |
55 | } | 56 | } |
56 | 57 | ||
57 | static int git_owner_config(const char *key, const char *value, void *cb) | 58 | static int gitweb_config(const char *key, const char *value, void *cb) |
58 | { | 59 | { |
59 | if (!strcmp(key, "gitweb.owner")) | 60 | if (ctx.cfg.enable_gitweb_owner && !strcmp(key, "gitweb.owner")) |
60 | owner = xstrdup(value); | 61 | owner = xstrdup(value); |
62 | else if (ctx.cfg.enable_gitweb_desc && !strcmp(key, "gitweb.description")) | ||
63 | desc = xstrdup(value); | ||
61 | return 0; | 64 | return 0; |
62 | } | 65 | } |
63 | 66 | ||
67 | |||
68 | |||
64 | static char *xstrrchr(char *s, char *from, int c) | 69 | static char *xstrrchr(char *s, char *from, int c) |
65 | { | 70 | { |
66 | while (from >= s && *from != c) | 71 | while (from >= s && *from != c) |
@@ -89,8 +94,9 @@ static void add_repo(const char *base, const char *path, repo_config_fn fn) | |||
89 | return; | 94 | return; |
90 | 95 | ||
91 | owner = NULL; | 96 | owner = NULL; |
92 | if (ctx.cfg.enable_gitweb_owner) | 97 | desc = NULL; |
93 | git_config_from_file(git_owner_config, fmt("%s/config", path), NULL); | 98 | git_config_from_file(gitweb_config, fmt("%s/config", path), NULL); |
99 | |||
94 | if (base == path) | 100 | if (base == path) |
95 | rel = xstrdup(fmt("%s", path)); | 101 | rel = xstrdup(fmt("%s", path)); |
96 | else | 102 | else |
@@ -118,9 +124,13 @@ static void add_repo(const char *base, const char *path, repo_config_fn fn) | |||
118 | } | 124 | } |
119 | repo->owner = owner; | 125 | repo->owner = owner; |
120 | 126 | ||
121 | p = fmt("%s/description", path); | 127 | if (desc) |
122 | if (!stat(p, &st)) | 128 | repo->desc = desc; |
123 | readfile(p, &repo->desc, &size); | 129 | else { |
130 | p = fmt("%s/description", path); | ||
131 | if (!stat(p, &st)) | ||
132 | readfile(p, &repo->desc, &size); | ||
133 | } | ||
124 | 134 | ||
125 | if (!repo->readme) { | 135 | if (!repo->readme) { |
126 | p = fmt("%s/README.html", path); | 136 | p = fmt("%s/README.html", path); |