author | Lars Hjemli <hjemli@gmail.com> | 2010-08-21 13:08:01 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2010-08-22 11:35:47 (UTC) |
commit | 515edb0da3b9156e07e269621d7474cdea82acaf (patch) (unidiff) | |
tree | e5fed5e83f29166c23216437386e10070e1d258d | |
parent | 6d7552bc072599313ef423d69156d824c075572a (diff) | |
download | cgit-515edb0da3b9156e07e269621d7474cdea82acaf.zip cgit-515edb0da3b9156e07e269621d7474cdea82acaf.tar.gz cgit-515edb0da3b9156e07e269621d7474cdea82acaf.tar.bz2 |
Add support for "readme" option
The value of this option is used as the default value for repo.readme.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | cgit.c | 8 | ||||
-rw-r--r-- | cgit.h | 1 | ||||
-rw-r--r-- | cgitrc.5.txt | 6 | ||||
-rw-r--r-- | scan-tree.c | 8 | ||||
-rw-r--r-- | shared.c | 2 | ||||
-rw-r--r-- | ui-summary.c | 42 |
6 files changed, 43 insertions, 24 deletions
@@ -59,57 +59,55 @@ void repo_config(struct cgit_repo *repo, const char *name, const char *value) | |||
59 | repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); | 59 | repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); |
60 | else if (!strcmp(name, "enable-log-filecount")) | 60 | else if (!strcmp(name, "enable-log-filecount")) |
61 | repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value); | 61 | repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value); |
62 | else if (!strcmp(name, "enable-log-linecount")) | 62 | else if (!strcmp(name, "enable-log-linecount")) |
63 | repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); | 63 | repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); |
64 | else if (!strcmp(name, "enable-remote-branches")) | 64 | else if (!strcmp(name, "enable-remote-branches")) |
65 | repo->enable_remote_branches = atoi(value); | 65 | repo->enable_remote_branches = atoi(value); |
66 | else if (!strcmp(name, "enable-subject-links")) | 66 | else if (!strcmp(name, "enable-subject-links")) |
67 | repo->enable_subject_links = atoi(value); | 67 | repo->enable_subject_links = atoi(value); |
68 | else if (!strcmp(name, "max-stats")) | 68 | else if (!strcmp(name, "max-stats")) |
69 | repo->max_stats = cgit_find_stats_period(value, NULL); | 69 | repo->max_stats = cgit_find_stats_period(value, NULL); |
70 | else if (!strcmp(name, "module-link")) | 70 | else if (!strcmp(name, "module-link")) |
71 | repo->module_link= xstrdup(value); | 71 | repo->module_link= xstrdup(value); |
72 | else if (!strcmp(name, "section")) | 72 | else if (!strcmp(name, "section")) |
73 | repo->section = xstrdup(value); | 73 | repo->section = xstrdup(value); |
74 | else if (!strcmp(name, "readme") && value != NULL) { | 74 | else if (!strcmp(name, "readme") && value != NULL) { |
75 | char *colon; | 75 | repo->readme = xstrdup(value); |
76 | if (*value == '/' || ((colon = strchr(value, ':')) != NULL && colon != value && *(colon + 1) != '\0')) | ||
77 | repo->readme = xstrdup(value); | ||
78 | else | ||
79 | repo->readme = xstrdup(fmt("%s/%s", repo->path, value)); | ||
80 | } else if (ctx.cfg.enable_filter_overrides) { | 76 | } else if (ctx.cfg.enable_filter_overrides) { |
81 | if (!strcmp(name, "about-filter")) | 77 | if (!strcmp(name, "about-filter")) |
82 | repo->about_filter = new_filter(value, 0); | 78 | repo->about_filter = new_filter(value, 0); |
83 | else if (!strcmp(name, "commit-filter")) | 79 | else if (!strcmp(name, "commit-filter")) |
84 | repo->commit_filter = new_filter(value, 0); | 80 | repo->commit_filter = new_filter(value, 0); |
85 | else if (!strcmp(name, "source-filter")) | 81 | else if (!strcmp(name, "source-filter")) |
86 | repo->source_filter = new_filter(value, 1); | 82 | repo->source_filter = new_filter(value, 1); |
87 | } | 83 | } |
88 | } | 84 | } |
89 | 85 | ||
90 | void config_cb(const char *name, const char *value) | 86 | void config_cb(const char *name, const char *value) |
91 | { | 87 | { |
92 | if (!strcmp(name, "section") || !strcmp(name, "repo.group")) | 88 | if (!strcmp(name, "section") || !strcmp(name, "repo.group")) |
93 | ctx.cfg.section = xstrdup(value); | 89 | ctx.cfg.section = xstrdup(value); |
94 | else if (!strcmp(name, "repo.url")) | 90 | else if (!strcmp(name, "repo.url")) |
95 | ctx.repo = cgit_add_repo(value); | 91 | ctx.repo = cgit_add_repo(value); |
96 | else if (ctx.repo && !strcmp(name, "repo.path")) | 92 | else if (ctx.repo && !strcmp(name, "repo.path")) |
97 | ctx.repo->path = trim_end(value, '/'); | 93 | ctx.repo->path = trim_end(value, '/'); |
98 | else if (ctx.repo && !prefixcmp(name, "repo.")) | 94 | else if (ctx.repo && !prefixcmp(name, "repo.")) |
99 | repo_config(ctx.repo, name + 5, value); | 95 | repo_config(ctx.repo, name + 5, value); |
96 | else if (!strcmp(name, "readme")) | ||
97 | ctx.cfg.readme = xstrdup(value); | ||
100 | else if (!strcmp(name, "root-title")) | 98 | else if (!strcmp(name, "root-title")) |
101 | ctx.cfg.root_title = xstrdup(value); | 99 | ctx.cfg.root_title = xstrdup(value); |
102 | else if (!strcmp(name, "root-desc")) | 100 | else if (!strcmp(name, "root-desc")) |
103 | ctx.cfg.root_desc = xstrdup(value); | 101 | ctx.cfg.root_desc = xstrdup(value); |
104 | else if (!strcmp(name, "root-readme")) | 102 | else if (!strcmp(name, "root-readme")) |
105 | ctx.cfg.root_readme = xstrdup(value); | 103 | ctx.cfg.root_readme = xstrdup(value); |
106 | else if (!strcmp(name, "css")) | 104 | else if (!strcmp(name, "css")) |
107 | ctx.cfg.css = xstrdup(value); | 105 | ctx.cfg.css = xstrdup(value); |
108 | else if (!strcmp(name, "favicon")) | 106 | else if (!strcmp(name, "favicon")) |
109 | ctx.cfg.favicon = xstrdup(value); | 107 | ctx.cfg.favicon = xstrdup(value); |
110 | else if (!strcmp(name, "footer")) | 108 | else if (!strcmp(name, "footer")) |
111 | ctx.cfg.footer = xstrdup(value); | 109 | ctx.cfg.footer = xstrdup(value); |
112 | else if (!strcmp(name, "head-include")) | 110 | else if (!strcmp(name, "head-include")) |
113 | ctx.cfg.head_include = xstrdup(value); | 111 | ctx.cfg.head_include = xstrdup(value); |
114 | else if (!strcmp(name, "header")) | 112 | else if (!strcmp(name, "header")) |
115 | ctx.cfg.header = xstrdup(value); | 113 | ctx.cfg.header = xstrdup(value); |
@@ -155,32 +155,33 @@ struct cgit_query { | |||
155 | 155 | ||
156 | struct cgit_config { | 156 | struct cgit_config { |
157 | char *agefile; | 157 | char *agefile; |
158 | char *cache_root; | 158 | char *cache_root; |
159 | char *clone_prefix; | 159 | char *clone_prefix; |
160 | char *css; | 160 | char *css; |
161 | char *favicon; | 161 | char *favicon; |
162 | char *footer; | 162 | char *footer; |
163 | char *head_include; | 163 | char *head_include; |
164 | char *header; | 164 | char *header; |
165 | char *index_header; | 165 | char *index_header; |
166 | char *index_info; | 166 | char *index_info; |
167 | char *logo; | 167 | char *logo; |
168 | char *logo_link; | 168 | char *logo_link; |
169 | char *module_link; | 169 | char *module_link; |
170 | char *project_list; | 170 | char *project_list; |
171 | char *readme; | ||
171 | char *robots; | 172 | char *robots; |
172 | char *root_title; | 173 | char *root_title; |
173 | char *root_desc; | 174 | char *root_desc; |
174 | char *root_readme; | 175 | char *root_readme; |
175 | char *script_name; | 176 | char *script_name; |
176 | char *section; | 177 | char *section; |
177 | char *virtual_root; | 178 | char *virtual_root; |
178 | int cache_size; | 179 | int cache_size; |
179 | int cache_dynamic_ttl; | 180 | int cache_dynamic_ttl; |
180 | int cache_max_create_time; | 181 | int cache_max_create_time; |
181 | int cache_repo_ttl; | 182 | int cache_repo_ttl; |
182 | int cache_root_ttl; | 183 | int cache_root_ttl; |
183 | int cache_scanrc_ttl; | 184 | int cache_scanrc_ttl; |
184 | int cache_static_ttl; | 185 | int cache_static_ttl; |
185 | int embedded; | 186 | int embedded; |
186 | int enable_filter_overrides; | 187 | int enable_filter_overrides; |
diff --git a/cgitrc.5.txt b/cgitrc.5.txt index c643fae..187031a 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt | |||
@@ -221,32 +221,36 @@ nocache:: | |||
221 | deprecated, and will not be honored starting with cgit-1.0. Default | 221 | deprecated, and will not be honored starting with cgit-1.0. Default |
222 | value: "0". | 222 | value: "0". |
223 | 223 | ||
224 | noplainemail:: | 224 | noplainemail:: |
225 | If set to "1" showing full author email adresses will be disabled. | 225 | If set to "1" showing full author email adresses will be disabled. |
226 | Default value: "0". | 226 | Default value: "0". |
227 | 227 | ||
228 | noheader:: | 228 | noheader:: |
229 | Flag which, when set to "1", will make cgit omit the standard header | 229 | Flag which, when set to "1", will make cgit omit the standard header |
230 | on all pages. Default value: none. See also: "embedded". | 230 | on all pages. Default value: none. See also: "embedded". |
231 | 231 | ||
232 | project-list:: | 232 | project-list:: |
233 | A list of subdirectories inside of scan-path, relative to it, that | 233 | A list of subdirectories inside of scan-path, relative to it, that |
234 | should loaded as git repositories. This must be defined prior to | 234 | should loaded as git repositories. This must be defined prior to |
235 | scan-path. Default value: none. See also: scan-path. | 235 | scan-path. Default value: none. See also: scan-path. |
236 | 236 | ||
237 | readme:: | ||
238 | Text which will be used as default value for "repo.readme". Default | ||
239 | value: none. | ||
240 | |||
237 | remove-suffix:: | 241 | remove-suffix:: |
238 | If set to "1" and scan-path is enabled, if any repositories are found | 242 | If set to "1" and scan-path is enabled, if any repositories are found |
239 | with a suffix of ".git", this suffix will be removed for the url and | 243 | with a suffix of ".git", this suffix will be removed for the url and |
240 | name. Default value: "0". See also: scan-path. | 244 | name. Default value: "0". See also: scan-path. |
241 | 245 | ||
242 | renamelimit:: | 246 | renamelimit:: |
243 | Maximum number of files to consider when detecting renames. The value | 247 | Maximum number of files to consider when detecting renames. The value |
244 | "-1" uses the compiletime value in git (for further info, look at | 248 | "-1" uses the compiletime value in git (for further info, look at |
245 | `man git-diff`). Default value: "-1". | 249 | `man git-diff`). Default value: "-1". |
246 | 250 | ||
247 | repo.group:: | 251 | repo.group:: |
248 | Legacy alias for "section". This option is deprecated and will not be | 252 | Legacy alias for "section". This option is deprecated and will not be |
249 | supported in cgit-1.0. | 253 | supported in cgit-1.0. |
250 | 254 | ||
251 | robots:: | 255 | robots:: |
252 | Text used as content for the "robots" meta-tag. Default value: | 256 | Text used as content for the "robots" meta-tag. Default value: |
@@ -360,33 +364,33 @@ repo.max-stats:: | |||
360 | 364 | ||
361 | repo.name:: | 365 | repo.name:: |
362 | The value to show as repository name. Default value: <repo.url>. | 366 | The value to show as repository name. Default value: <repo.url>. |
363 | 367 | ||
364 | repo.owner:: | 368 | repo.owner:: |
365 | A value used to identify the owner of the repository. Default value: | 369 | A value used to identify the owner of the repository. Default value: |
366 | none. | 370 | none. |
367 | 371 | ||
368 | repo.path:: | 372 | repo.path:: |
369 | An absolute path to the repository directory. For non-bare repositories | 373 | An absolute path to the repository directory. For non-bare repositories |
370 | this is the .git-directory. Default value: none. | 374 | this is the .git-directory. Default value: none. |
371 | 375 | ||
372 | repo.readme:: | 376 | repo.readme:: |
373 | A path (relative to <repo.path>) which specifies a file to include | 377 | A path (relative to <repo.path>) which specifies a file to include |
374 | verbatim as the "About" page for this repo. You may also specify a | 378 | verbatim as the "About" page for this repo. You may also specify a |
375 | git refspec by head or by hash by prepending the refspec followed by | 379 | git refspec by head or by hash by prepending the refspec followed by |
376 | a colon. For example, "master:docs/readme.mkd" Default value: none. | 380 | a colon. For example, "master:docs/readme.mkd" Default value: <readme>. |
377 | 381 | ||
378 | repo.snapshots:: | 382 | repo.snapshots:: |
379 | A mask of allowed snapshot-formats for this repo, restricted by the | 383 | A mask of allowed snapshot-formats for this repo, restricted by the |
380 | "snapshots" global setting. Default value: <snapshots>. | 384 | "snapshots" global setting. Default value: <snapshots>. |
381 | 385 | ||
382 | repo.section:: | 386 | repo.section:: |
383 | Override the current section name for this repository. Default value: | 387 | Override the current section name for this repository. Default value: |
384 | none. | 388 | none. |
385 | 389 | ||
386 | repo.source-filter:: | 390 | repo.source-filter:: |
387 | Override the default source-filter. Default value: none. See also: | 391 | Override the default source-filter. Default value: none. See also: |
388 | "enable-filter-overrides". | 392 | "enable-filter-overrides". |
389 | 393 | ||
390 | repo.url:: | 394 | repo.url:: |
391 | The relative url used to access the repository. This must be the first | 395 | The relative url used to access the repository. This must be the first |
392 | setting specified for each repo. Default value: none. | 396 | setting specified for each repo. Default value: none. |
diff --git a/scan-tree.c b/scan-tree.c index e987824..780d405 100644 --- a/scan-tree.c +++ b/scan-tree.c | |||
@@ -97,35 +97,37 @@ static void add_repo(const char *base, const char *path, repo_config_fn fn) | |||
97 | if ((pwd = getpwuid(st.st_uid)) == NULL) { | 97 | if ((pwd = getpwuid(st.st_uid)) == NULL) { |
98 | fprintf(stderr, "Error reading owner-info for %s: %s (%d)\n", | 98 | fprintf(stderr, "Error reading owner-info for %s: %s (%d)\n", |
99 | path, strerror(errno), errno); | 99 | path, strerror(errno), errno); |
100 | break; | 100 | break; |
101 | } | 101 | } |
102 | if (pwd->pw_gecos) | 102 | if (pwd->pw_gecos) |
103 | if ((p = strchr(pwd->pw_gecos, ','))) | 103 | if ((p = strchr(pwd->pw_gecos, ','))) |
104 | *p = '\0'; | 104 | *p = '\0'; |
105 | owner = xstrdup(pwd->pw_gecos ? pwd->pw_gecos : pwd->pw_name); | 105 | owner = xstrdup(pwd->pw_gecos ? pwd->pw_gecos : pwd->pw_name); |
106 | } | 106 | } |
107 | repo->owner = owner; | 107 | repo->owner = owner; |
108 | 108 | ||
109 | p = fmt("%s/description", path); | 109 | p = fmt("%s/description", path); |
110 | if (!stat(p, &st)) | 110 | if (!stat(p, &st)) |
111 | readfile(p, &repo->desc, &size); | 111 | readfile(p, &repo->desc, &size); |
112 | 112 | ||
113 | p = fmt("%s/README.html", path); | 113 | if (!repo->readme) { |
114 | if (!stat(p, &st)) | 114 | p = fmt("%s/README.html", path); |
115 | repo->readme = "README.html"; | 115 | if (!stat(p, &st)) |
116 | repo->readme = "README.html"; | ||
117 | } | ||
116 | 118 | ||
117 | p = fmt("%s/cgitrc", path); | 119 | p = fmt("%s/cgitrc", path); |
118 | if (!stat(p, &st)) { | 120 | if (!stat(p, &st)) { |
119 | config_fn = fn; | 121 | config_fn = fn; |
120 | parse_configfile(xstrdup(p), &repo_config); | 122 | parse_configfile(xstrdup(p), &repo_config); |
121 | } | 123 | } |
122 | } | 124 | } |
123 | 125 | ||
124 | static void scan_path(const char *base, const char *path, repo_config_fn fn) | 126 | static void scan_path(const char *base, const char *path, repo_config_fn fn) |
125 | { | 127 | { |
126 | DIR *dir; | 128 | DIR *dir; |
127 | struct dirent *ent; | 129 | struct dirent *ent; |
128 | char *buf; | 130 | char *buf; |
129 | struct stat st; | 131 | struct stat st; |
130 | 132 | ||
131 | if (is_git_dir(path)) { | 133 | if (is_git_dir(path)) { |
@@ -49,33 +49,33 @@ struct cgit_repo *cgit_add_repo(const char *url) | |||
49 | ret = &cgit_repolist.repos[cgit_repolist.count-1]; | 49 | ret = &cgit_repolist.repos[cgit_repolist.count-1]; |
50 | memset(ret, 0, sizeof(struct cgit_repo)); | 50 | memset(ret, 0, sizeof(struct cgit_repo)); |
51 | ret->url = trim_end(url, '/'); | 51 | ret->url = trim_end(url, '/'); |
52 | ret->name = ret->url; | 52 | ret->name = ret->url; |
53 | ret->path = NULL; | 53 | ret->path = NULL; |
54 | ret->desc = "[no description]"; | 54 | ret->desc = "[no description]"; |
55 | ret->owner = NULL; | 55 | ret->owner = NULL; |
56 | ret->section = ctx.cfg.section; | 56 | ret->section = ctx.cfg.section; |
57 | ret->defbranch = "master"; | 57 | ret->defbranch = "master"; |
58 | ret->snapshots = ctx.cfg.snapshots; | 58 | ret->snapshots = ctx.cfg.snapshots; |
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->enable_remote_branches = ctx.cfg.enable_remote_branches; | 61 | ret->enable_remote_branches = ctx.cfg.enable_remote_branches; |
62 | ret->enable_subject_links = ctx.cfg.enable_subject_links; | 62 | ret->enable_subject_links = ctx.cfg.enable_subject_links; |
63 | ret->max_stats = ctx.cfg.max_stats; | 63 | ret->max_stats = ctx.cfg.max_stats; |
64 | ret->module_link = ctx.cfg.module_link; | 64 | ret->module_link = ctx.cfg.module_link; |
65 | ret->readme = NULL; | 65 | ret->readme = ctx.cfg.readme; |
66 | ret->mtime = -1; | 66 | ret->mtime = -1; |
67 | ret->about_filter = ctx.cfg.about_filter; | 67 | ret->about_filter = ctx.cfg.about_filter; |
68 | ret->commit_filter = ctx.cfg.commit_filter; | 68 | ret->commit_filter = ctx.cfg.commit_filter; |
69 | ret->source_filter = ctx.cfg.source_filter; | 69 | ret->source_filter = ctx.cfg.source_filter; |
70 | return ret; | 70 | return ret; |
71 | } | 71 | } |
72 | 72 | ||
73 | struct cgit_repo *cgit_get_repoinfo(const char *url) | 73 | struct cgit_repo *cgit_get_repoinfo(const char *url) |
74 | { | 74 | { |
75 | int i; | 75 | int i; |
76 | struct cgit_repo *repo; | 76 | struct cgit_repo *repo; |
77 | 77 | ||
78 | for (i=0; i<cgit_repolist.count; i++) { | 78 | for (i=0; i<cgit_repolist.count; i++) { |
79 | repo = &cgit_repolist.repos[i]; | 79 | repo = &cgit_repolist.repos[i]; |
80 | if (!strcmp(repo->url, url)) | 80 | if (!strcmp(repo->url, url)) |
81 | return repo; | 81 | return repo; |
diff --git a/ui-summary.c b/ui-summary.c index 02f191e..b203bcc 100644 --- a/ui-summary.c +++ b/ui-summary.c | |||
@@ -57,54 +57,68 @@ void cgit_print_summary() | |||
57 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); | 57 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); |
58 | cgit_print_tags(ctx.cfg.summary_tags); | 58 | cgit_print_tags(ctx.cfg.summary_tags); |
59 | if (ctx.cfg.summary_log > 0) { | 59 | if (ctx.cfg.summary_log > 0) { |
60 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); | 60 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); |
61 | cgit_print_log(ctx.qry.head, 0, ctx.cfg.summary_log, NULL, | 61 | cgit_print_log(ctx.qry.head, 0, ctx.cfg.summary_log, NULL, |
62 | NULL, NULL, 0); | 62 | NULL, NULL, 0); |
63 | } | 63 | } |
64 | if (ctx.repo->clone_url) | 64 | if (ctx.repo->clone_url) |
65 | print_urls(ctx.repo->clone_url, NULL); | 65 | print_urls(ctx.repo->clone_url, NULL); |
66 | else if (ctx.cfg.clone_prefix) | 66 | else if (ctx.cfg.clone_prefix) |
67 | print_urls(ctx.cfg.clone_prefix, ctx.repo->url); | 67 | print_urls(ctx.cfg.clone_prefix, ctx.repo->url); |
68 | html("</table>"); | 68 | html("</table>"); |
69 | } | 69 | } |
70 | 70 | ||
71 | void cgit_print_repo_readme(char *path) | 71 | void cgit_print_repo_readme(char *path) |
72 | { | 72 | { |
73 | char *slash, *tmp, *colon, *ref = 0; | 73 | char *slash, *tmp, *colon, *ref; |
74 | 74 | ||
75 | if (!ctx.repo->readme) | 75 | if (!ctx.repo->readme || !(*ctx.repo->readme)) |
76 | return; | 76 | return; |
77 | 77 | ||
78 | ref = NULL; | ||
79 | |||
80 | /* Check if the readme is tracked in the git repo. */ | ||
81 | colon = strchr(ctx.repo->readme, ':'); | ||
82 | if (colon && strlen(colon) > 1) { | ||
83 | *colon = '\0'; | ||
84 | ref = ctx.repo->readme; | ||
85 | ctx.repo->readme = colon + 1; | ||
86 | if (!(*ctx.repo->readme)) | ||
87 | return; | ||
88 | } | ||
89 | |||
90 | /* Prepend repo path to relative readme path unless tracked. */ | ||
91 | if (!ref && *ctx.repo->readme != '/') | ||
92 | ctx.repo->readme = xstrdup(fmt("%s/%s", ctx.repo->path, | ||
93 | ctx.repo->readme)); | ||
94 | |||
95 | /* If a subpath is specified for the about page, make it relative | ||
96 | * to the directory containing the configured readme. | ||
97 | */ | ||
78 | if (path) { | 98 | if (path) { |
79 | slash = strrchr(ctx.repo->readme, '/'); | 99 | slash = strrchr(ctx.repo->readme, '/'); |
80 | if (!slash) { | 100 | if (!slash) { |
81 | slash = strchr(ctx.repo->readme, ':'); | 101 | if (!colon) |
82 | if (!slash) | ||
83 | return; | 102 | return; |
103 | slash = colon; | ||
84 | } | 104 | } |
85 | tmp = xmalloc(slash - ctx.repo->readme + 1 + strlen(path) + 1); | 105 | tmp = xmalloc(slash - ctx.repo->readme + 1 + strlen(path) + 1); |
86 | strncpy(tmp, ctx.repo->readme, slash - ctx.repo->readme + 1); | 106 | strncpy(tmp, ctx.repo->readme, slash - ctx.repo->readme + 1); |
87 | strcpy(tmp + (slash - ctx.repo->readme + 1), path); | 107 | strcpy(tmp + (slash - ctx.repo->readme + 1), path); |
88 | } else | 108 | } else |
89 | tmp = ctx.repo->readme; | 109 | tmp = ctx.repo->readme; |
90 | colon = strchr(tmp, ':'); | 110 | |
91 | if (colon && strlen(colon) > 1) { | 111 | /* Print the calculated readme, either from the git repo or from the |
92 | *colon = '\0'; | 112 | * filesystem, while applying the about-filter. |
93 | ref = tmp; | 113 | */ |
94 | tmp = colon + 1; | ||
95 | while ((*tmp == '/' || *tmp == ':') && *tmp != '\0') | ||
96 | ++tmp; | ||
97 | if (!(*tmp)) | ||
98 | return; | ||
99 | } | ||
100 | html("<div id='summary'>"); | 114 | html("<div id='summary'>"); |
101 | if (ctx.repo->about_filter) | 115 | if (ctx.repo->about_filter) |
102 | cgit_open_filter(ctx.repo->about_filter); | 116 | cgit_open_filter(ctx.repo->about_filter); |
103 | if (ref) | 117 | if (ref) |
104 | cgit_print_file(tmp, ref); | 118 | cgit_print_file(tmp, ref); |
105 | else | 119 | else |
106 | html_include(tmp); | 120 | html_include(tmp); |
107 | if (ctx.repo->about_filter) | 121 | if (ctx.repo->about_filter) |
108 | cgit_close_filter(ctx.repo->about_filter); | 122 | cgit_close_filter(ctx.repo->about_filter); |
109 | html("</div>"); | 123 | html("</div>"); |
110 | } | 124 | } |