author | Lars Hjemli <hjemli@gmail.com> | 2009-08-09 11:46:34 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2009-08-09 11:46:34 (UTC) |
commit | db8b8cb9467625cb8d9ecb67863aa67590e59cc0 (patch) (unidiff) | |
tree | d27644fc1b98ec6365e74f3ba40c19f78f8a287f | |
parent | db6303b58883c4417f5bcc0c1ee34fed6553dca3 (diff) | |
parent | 537c05f138d59c1eb3ac8e2d8b0dca3a38aa5dd4 (diff) | |
download | cgit-db8b8cb9467625cb8d9ecb67863aa67590e59cc0.zip cgit-db8b8cb9467625cb8d9ecb67863aa67590e59cc0.tar.gz cgit-db8b8cb9467625cb8d9ecb67863aa67590e59cc0.tar.bz2 |
Merge branch 'lh/about'
Conflicts:
cgit.h
-rw-r--r-- | cgit.c | 4 | ||||
-rw-r--r-- | cgit.h | 2 | ||||
-rw-r--r-- | cgitrc.5.txt | 10 | ||||
-rw-r--r-- | cmd.c | 2 | ||||
-rw-r--r-- | shared.c | 1 | ||||
-rw-r--r-- | ui-repolist.c | 9 | ||||
-rw-r--r-- | ui-summary.c | 28 | ||||
-rw-r--r-- | ui-summary.h | 2 |
8 files changed, 48 insertions, 10 deletions
@@ -97,12 +97,14 @@ void config_cb(const char *name, const char *value) | |||
97 | else if (!strcmp(name, "cache-repo-ttl")) | 97 | else if (!strcmp(name, "cache-repo-ttl")) |
98 | ctx.cfg.cache_repo_ttl = atoi(value); | 98 | ctx.cfg.cache_repo_ttl = atoi(value); |
99 | else if (!strcmp(name, "cache-static-ttl")) | 99 | else if (!strcmp(name, "cache-static-ttl")) |
100 | ctx.cfg.cache_static_ttl = atoi(value); | 100 | ctx.cfg.cache_static_ttl = atoi(value); |
101 | else if (!strcmp(name, "cache-dynamic-ttl")) | 101 | else if (!strcmp(name, "cache-dynamic-ttl")) |
102 | ctx.cfg.cache_dynamic_ttl = atoi(value); | 102 | ctx.cfg.cache_dynamic_ttl = atoi(value); |
103 | else if (!strcmp(name, "about-filter")) | ||
104 | ctx.cfg.about_filter = new_filter(value, 0); | ||
103 | else if (!strcmp(name, "commit-filter")) | 105 | else if (!strcmp(name, "commit-filter")) |
104 | ctx.cfg.commit_filter = new_filter(value, 0); | 106 | ctx.cfg.commit_filter = new_filter(value, 0); |
105 | else if (!strcmp(name, "embedded")) | 107 | else if (!strcmp(name, "embedded")) |
106 | ctx.cfg.embedded = atoi(value); | 108 | ctx.cfg.embedded = atoi(value); |
107 | else if (!strcmp(name, "max-message-length")) | 109 | else if (!strcmp(name, "max-message-length")) |
108 | ctx.cfg.max_msg_len = atoi(value); | 110 | ctx.cfg.max_msg_len = atoi(value); |
@@ -155,12 +157,14 @@ void config_cb(const char *name, const char *value) | |||
155 | else if (ctx.repo && !strcmp(name, "repo.enable-log-linecount")) | 157 | else if (ctx.repo && !strcmp(name, "repo.enable-log-linecount")) |
156 | ctx.repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); | 158 | ctx.repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); |
157 | else if (ctx.repo && !strcmp(name, "repo.max-stats")) | 159 | else if (ctx.repo && !strcmp(name, "repo.max-stats")) |
158 | ctx.repo->max_stats = cgit_find_stats_period(value, NULL); | 160 | ctx.repo->max_stats = cgit_find_stats_period(value, NULL); |
159 | else if (ctx.repo && !strcmp(name, "repo.module-link")) | 161 | else if (ctx.repo && !strcmp(name, "repo.module-link")) |
160 | ctx.repo->module_link= xstrdup(value); | 162 | ctx.repo->module_link= xstrdup(value); |
163 | else if (ctx.repo && !strcmp(name, "repo.about-filter")) | ||
164 | ctx.repo->about_filter = new_filter(value, 0); | ||
161 | else if (ctx.repo && !strcmp(name, "repo.commit-filter")) | 165 | else if (ctx.repo && !strcmp(name, "repo.commit-filter")) |
162 | ctx.repo->commit_filter = new_filter(value, 0); | 166 | ctx.repo->commit_filter = new_filter(value, 0); |
163 | else if (ctx.repo && !strcmp(name, "repo.source-filter")) | 167 | else if (ctx.repo && !strcmp(name, "repo.source-filter")) |
164 | ctx.repo->source_filter = new_filter(value, 1); | 168 | ctx.repo->source_filter = new_filter(value, 1); |
165 | else if (ctx.repo && !strcmp(name, "repo.readme") && value != NULL) { | 169 | else if (ctx.repo && !strcmp(name, "repo.readme") && value != NULL) { |
166 | if (*value == '/') | 170 | if (*value == '/') |
@@ -71,12 +71,13 @@ struct cgit_repo { | |||
71 | char *clone_url; | 71 | char *clone_url; |
72 | int snapshots; | 72 | int snapshots; |
73 | int enable_log_filecount; | 73 | int enable_log_filecount; |
74 | int enable_log_linecount; | 74 | int enable_log_linecount; |
75 | int max_stats; | 75 | int max_stats; |
76 | time_t mtime; | 76 | time_t mtime; |
77 | struct cgit_filter *about_filter; | ||
77 | struct cgit_filter *commit_filter; | 78 | struct cgit_filter *commit_filter; |
78 | struct cgit_filter *source_filter; | 79 | struct cgit_filter *source_filter; |
79 | }; | 80 | }; |
80 | 81 | ||
81 | struct cgit_repolist { | 82 | struct cgit_repolist { |
82 | int length; | 83 | int length; |
@@ -185,12 +186,13 @@ struct cgit_config { | |||
185 | int renamelimit; | 186 | int renamelimit; |
186 | int snapshots; | 187 | int snapshots; |
187 | int summary_branches; | 188 | int summary_branches; |
188 | int summary_log; | 189 | int summary_log; |
189 | int summary_tags; | 190 | int summary_tags; |
190 | struct string_list mimetypes; | 191 | struct string_list mimetypes; |
192 | struct cgit_filter *about_filter; | ||
191 | struct cgit_filter *commit_filter; | 193 | struct cgit_filter *commit_filter; |
192 | struct cgit_filter *source_filter; | 194 | struct cgit_filter *source_filter; |
193 | }; | 195 | }; |
194 | 196 | ||
195 | struct cgit_page { | 197 | struct cgit_page { |
196 | time_t modified; | 198 | time_t modified; |
diff --git a/cgitrc.5.txt b/cgitrc.5.txt index dc63637..4d656fe 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt | |||
@@ -13,12 +13,19 @@ Cgitrc contains all runtime settings for cgit, including the list of git | |||
13 | repositories, formatted as a line-separated list of NAME=VALUE pairs. Blank | 13 | repositories, formatted as a line-separated list of NAME=VALUE pairs. Blank |
14 | lines, and lines starting with '#', are ignored. | 14 | lines, and lines starting with '#', are ignored. |
15 | 15 | ||
16 | 16 | ||
17 | GLOBAL SETTINGS | 17 | GLOBAL SETTINGS |
18 | --------------- | 18 | --------------- |
19 | about-filter:: | ||
20 | Specifies a command which will be invoked to format the content of | ||
21 | about pages (both top-level and for each repository). The command will | ||
22 | get the content of the about-file on its STDIN, and the STDOUT from the | ||
23 | command will be included verbatim on the about page. Default value: | ||
24 | none. | ||
25 | |||
19 | agefile:: | 26 | agefile:: |
20 | Specifies a path, relative to each repository path, which can be used | 27 | Specifies a path, relative to each repository path, which can be used |
21 | to specify the date and time of the youngest commit in the repository. | 28 | to specify the date and time of the youngest commit in the repository. |
22 | The first line in the file is used as input to the "parse_date" | 29 | The first line in the file is used as input to the "parse_date" |
23 | function in libgit. Recommended timestamp-format is "yyyy-mm-dd | 30 | function in libgit. Recommended timestamp-format is "yyyy-mm-dd |
24 | hh:mm:ss". Default value: "info/web/last-modified". | 31 | hh:mm:ss". Default value: "info/web/last-modified". |
@@ -239,12 +246,15 @@ virtual-root:: | |||
239 | value: none. | 246 | value: none. |
240 | NOTE: cgit has recently learned how to use PATH_INFO to achieve the | 247 | NOTE: cgit has recently learned how to use PATH_INFO to achieve the |
241 | same kind of virtual urls, so this option will probably be deprecated. | 248 | same kind of virtual urls, so this option will probably be deprecated. |
242 | 249 | ||
243 | REPOSITORY SETTINGS | 250 | REPOSITORY SETTINGS |
244 | ------------------- | 251 | ------------------- |
252 | repo.about-filter:: | ||
253 | Override the default about-filter. Default value: <about-filter>. | ||
254 | |||
245 | repo.clone-url:: | 255 | repo.clone-url:: |
246 | A list of space-separated urls which can be used to clone this repo. | 256 | A list of space-separated urls which can be used to clone this repo. |
247 | Default value: none. | 257 | Default value: none. |
248 | 258 | ||
249 | repo.commit-filter:: | 259 | repo.commit-filter:: |
250 | Override the default commit-filter. Default value: <commit-filter>. | 260 | Override the default commit-filter. Default value: <commit-filter>. |
@@ -36,13 +36,13 @@ static void atom_fn(struct cgit_context *ctx) | |||
36 | cgit_print_atom(ctx->qry.head, ctx->qry.path, 10); | 36 | cgit_print_atom(ctx->qry.head, ctx->qry.path, 10); |
37 | } | 37 | } |
38 | 38 | ||
39 | static void about_fn(struct cgit_context *ctx) | 39 | static void about_fn(struct cgit_context *ctx) |
40 | { | 40 | { |
41 | if (ctx->repo) | 41 | if (ctx->repo) |
42 | cgit_print_repo_readme(); | 42 | cgit_print_repo_readme(ctx->qry.path); |
43 | else | 43 | else |
44 | cgit_print_site_readme(); | 44 | cgit_print_site_readme(); |
45 | } | 45 | } |
46 | 46 | ||
47 | static void blob_fn(struct cgit_context *ctx) | 47 | static void blob_fn(struct cgit_context *ctx) |
48 | { | 48 | { |
@@ -59,12 +59,13 @@ struct cgit_repo *cgit_add_repo(const char *url) | |||
59 | ret->enable_log_filecount = ctx.cfg.enable_log_filecount; | 59 | ret->enable_log_filecount = ctx.cfg.enable_log_filecount; |
60 | ret->enable_log_linecount = ctx.cfg.enable_log_linecount; | 60 | ret->enable_log_linecount = ctx.cfg.enable_log_linecount; |
61 | ret->max_stats = ctx.cfg.max_stats; | 61 | ret->max_stats = ctx.cfg.max_stats; |
62 | ret->module_link = ctx.cfg.module_link; | 62 | ret->module_link = ctx.cfg.module_link; |
63 | ret->readme = NULL; | 63 | ret->readme = NULL; |
64 | ret->mtime = -1; | 64 | ret->mtime = -1; |
65 | ret->about_filter = ctx.cfg.about_filter; | ||
65 | ret->commit_filter = ctx.cfg.commit_filter; | 66 | ret->commit_filter = ctx.cfg.commit_filter; |
66 | ret->source_filter = ctx.cfg.source_filter; | 67 | ret->source_filter = ctx.cfg.source_filter; |
67 | return ret; | 68 | return ret; |
68 | } | 69 | } |
69 | 70 | ||
70 | struct cgit_repo *cgit_get_repoinfo(const char *url) | 71 | struct cgit_repo *cgit_get_repoinfo(const char *url) |
diff --git a/ui-repolist.c b/ui-repolist.c index 2c13d50..25f076f 100644 --- a/ui-repolist.c +++ b/ui-repolist.c | |||
@@ -270,9 +270,14 @@ void cgit_print_repolist() | |||
270 | print_pager(hits, ctx.cfg.max_repo_count, ctx.qry.search); | 270 | print_pager(hits, ctx.cfg.max_repo_count, ctx.qry.search); |
271 | cgit_print_docend(); | 271 | cgit_print_docend(); |
272 | } | 272 | } |
273 | 273 | ||
274 | void cgit_print_site_readme() | 274 | void cgit_print_site_readme() |
275 | { | 275 | { |
276 | if (ctx.cfg.root_readme) | 276 | if (!ctx.cfg.root_readme) |
277 | html_include(ctx.cfg.root_readme); | 277 | return; |
278 | if (ctx.cfg.about_filter) | ||
279 | cgit_open_filter(ctx.cfg.about_filter); | ||
280 | html_include(ctx.cfg.root_readme); | ||
281 | if (ctx.cfg.about_filter) | ||
282 | cgit_close_filter(ctx.cfg.about_filter); | ||
278 | } | 283 | } |
diff --git a/ui-summary.c b/ui-summary.c index ede4a62..a2c018e 100644 --- a/ui-summary.c +++ b/ui-summary.c | |||
@@ -63,14 +63,30 @@ void cgit_print_summary() | |||
63 | print_urls(ctx.repo->clone_url, NULL); | 63 | print_urls(ctx.repo->clone_url, NULL); |
64 | else if (ctx.cfg.clone_prefix) | 64 | else if (ctx.cfg.clone_prefix) |
65 | print_urls(ctx.cfg.clone_prefix, ctx.repo->url); | 65 | print_urls(ctx.cfg.clone_prefix, ctx.repo->url); |
66 | html("</table>"); | 66 | html("</table>"); |
67 | } | 67 | } |
68 | 68 | ||
69 | void cgit_print_repo_readme() | 69 | void cgit_print_repo_readme(char *path) |
70 | { | 70 | { |
71 | if (ctx.repo->readme) { | 71 | char *slash, *tmp; |
72 | html("<div id='summary'>"); | 72 | |
73 | html_include(ctx.repo->readme); | 73 | if (!ctx.repo->readme) |
74 | html("</div>"); | 74 | return; |
75 | } | 75 | |
76 | if (path) { | ||
77 | slash = strrchr(ctx.repo->readme, '/'); | ||
78 | if (!slash) | ||
79 | return; | ||
80 | tmp = xmalloc(slash - ctx.repo->readme + 1 + strlen(path) + 1); | ||
81 | strncpy(tmp, ctx.repo->readme, slash - ctx.repo->readme + 1); | ||
82 | strcpy(tmp + (slash - ctx.repo->readme + 1), path); | ||
83 | } else | ||
84 | tmp = ctx.repo->readme; | ||
85 | html("<div id='summary'>"); | ||
86 | if (ctx.repo->about_filter) | ||
87 | cgit_open_filter(ctx.repo->about_filter); | ||
88 | html_include(tmp); | ||
89 | if (ctx.repo->about_filter) | ||
90 | cgit_close_filter(ctx.repo->about_filter); | ||
91 | html("</div>"); | ||
76 | } | 92 | } |
diff --git a/ui-summary.h b/ui-summary.h index 3e13039..c01f560 100644 --- a/ui-summary.h +++ b/ui-summary.h | |||
@@ -1,7 +1,7 @@ | |||
1 | #ifndef UI_SUMMARY_H | 1 | #ifndef UI_SUMMARY_H |
2 | #define UI_SUMMARY_H | 2 | #define UI_SUMMARY_H |
3 | 3 | ||
4 | extern void cgit_print_summary(); | 4 | extern void cgit_print_summary(); |
5 | extern void cgit_print_repo_readme(); | 5 | extern void cgit_print_repo_readme(char *path); |
6 | 6 | ||
7 | #endif /* UI_SUMMARY_H */ | 7 | #endif /* UI_SUMMARY_H */ |