Merge branch 'lh/about'

Conflicts:
	cgit.h
This commit is contained in:
Lars Hjemli 2009-08-09 13:46:34 +02:00
commit db8b8cb946
8 changed files with 48 additions and 10 deletions

4
cgit.c
View File

@ -100,6 +100,8 @@ void config_cb(const char *name, const char *value)
ctx.cfg.cache_static_ttl = atoi(value); ctx.cfg.cache_static_ttl = atoi(value);
else if (!strcmp(name, "cache-dynamic-ttl")) else if (!strcmp(name, "cache-dynamic-ttl"))
ctx.cfg.cache_dynamic_ttl = atoi(value); ctx.cfg.cache_dynamic_ttl = atoi(value);
else if (!strcmp(name, "about-filter"))
ctx.cfg.about_filter = new_filter(value, 0);
else if (!strcmp(name, "commit-filter")) else if (!strcmp(name, "commit-filter"))
ctx.cfg.commit_filter = new_filter(value, 0); ctx.cfg.commit_filter = new_filter(value, 0);
else if (!strcmp(name, "embedded")) else if (!strcmp(name, "embedded"))
@ -158,6 +160,8 @@ void config_cb(const char *name, const char *value)
ctx.repo->max_stats = cgit_find_stats_period(value, NULL); ctx.repo->max_stats = cgit_find_stats_period(value, NULL);
else if (ctx.repo && !strcmp(name, "repo.module-link")) else if (ctx.repo && !strcmp(name, "repo.module-link"))
ctx.repo->module_link= xstrdup(value); ctx.repo->module_link= xstrdup(value);
else if (ctx.repo && !strcmp(name, "repo.about-filter"))
ctx.repo->about_filter = new_filter(value, 0);
else if (ctx.repo && !strcmp(name, "repo.commit-filter")) else if (ctx.repo && !strcmp(name, "repo.commit-filter"))
ctx.repo->commit_filter = new_filter(value, 0); ctx.repo->commit_filter = new_filter(value, 0);
else if (ctx.repo && !strcmp(name, "repo.source-filter")) else if (ctx.repo && !strcmp(name, "repo.source-filter"))

2
cgit.h
View File

@ -74,6 +74,7 @@ struct cgit_repo {
int enable_log_linecount; int enable_log_linecount;
int max_stats; int max_stats;
time_t mtime; time_t mtime;
struct cgit_filter *about_filter;
struct cgit_filter *commit_filter; struct cgit_filter *commit_filter;
struct cgit_filter *source_filter; struct cgit_filter *source_filter;
}; };
@ -188,6 +189,7 @@ struct cgit_config {
int summary_log; int summary_log;
int summary_tags; int summary_tags;
struct string_list mimetypes; struct string_list mimetypes;
struct cgit_filter *about_filter;
struct cgit_filter *commit_filter; struct cgit_filter *commit_filter;
struct cgit_filter *source_filter; struct cgit_filter *source_filter;
}; };

View File

@ -16,6 +16,13 @@ lines, and lines starting with '#', are ignored.
GLOBAL SETTINGS GLOBAL SETTINGS
--------------- ---------------
about-filter::
Specifies a command which will be invoked to format the content of
about pages (both top-level and for each repository). The command will
get the content of the about-file on its STDIN, and the STDOUT from the
command will be included verbatim on the about page. Default value:
none.
agefile:: agefile::
Specifies a path, relative to each repository path, which can be used Specifies a path, relative to each repository path, which can be used
to specify the date and time of the youngest commit in the repository. to specify the date and time of the youngest commit in the repository.
@ -242,6 +249,9 @@ virtual-root::
REPOSITORY SETTINGS REPOSITORY SETTINGS
------------------- -------------------
repo.about-filter::
Override the default about-filter. Default value: <about-filter>.
repo.clone-url:: repo.clone-url::
A list of space-separated urls which can be used to clone this repo. A list of space-separated urls which can be used to clone this repo.
Default value: none. Default value: none.

2
cmd.c
View File

@ -39,7 +39,7 @@ static void atom_fn(struct cgit_context *ctx)
static void about_fn(struct cgit_context *ctx) static void about_fn(struct cgit_context *ctx)
{ {
if (ctx->repo) if (ctx->repo)
cgit_print_repo_readme(); cgit_print_repo_readme(ctx->qry.path);
else else
cgit_print_site_readme(); cgit_print_site_readme();
} }

View File

@ -62,6 +62,7 @@ struct cgit_repo *cgit_add_repo(const char *url)
ret->module_link = ctx.cfg.module_link; ret->module_link = ctx.cfg.module_link;
ret->readme = NULL; ret->readme = NULL;
ret->mtime = -1; ret->mtime = -1;
ret->about_filter = ctx.cfg.about_filter;
ret->commit_filter = ctx.cfg.commit_filter; ret->commit_filter = ctx.cfg.commit_filter;
ret->source_filter = ctx.cfg.source_filter; ret->source_filter = ctx.cfg.source_filter;
return ret; return ret;

View File

@ -273,6 +273,11 @@ void cgit_print_repolist()
void cgit_print_site_readme() void cgit_print_site_readme()
{ {
if (ctx.cfg.root_readme) if (!ctx.cfg.root_readme)
return;
if (ctx.cfg.about_filter)
cgit_open_filter(ctx.cfg.about_filter);
html_include(ctx.cfg.root_readme); html_include(ctx.cfg.root_readme);
if (ctx.cfg.about_filter)
cgit_close_filter(ctx.cfg.about_filter);
} }

View File

@ -66,11 +66,27 @@ void cgit_print_summary()
html("</table>"); html("</table>");
} }
void cgit_print_repo_readme() void cgit_print_repo_readme(char *path)
{ {
if (ctx.repo->readme) { char *slash, *tmp;
if (!ctx.repo->readme)
return;
if (path) {
slash = strrchr(ctx.repo->readme, '/');
if (!slash)
return;
tmp = xmalloc(slash - ctx.repo->readme + 1 + strlen(path) + 1);
strncpy(tmp, ctx.repo->readme, slash - ctx.repo->readme + 1);
strcpy(tmp + (slash - ctx.repo->readme + 1), path);
} else
tmp = ctx.repo->readme;
html("<div id='summary'>"); html("<div id='summary'>");
html_include(ctx.repo->readme); if (ctx.repo->about_filter)
cgit_open_filter(ctx.repo->about_filter);
html_include(tmp);
if (ctx.repo->about_filter)
cgit_close_filter(ctx.repo->about_filter);
html("</div>"); html("</div>");
}
} }

View File

@ -2,6 +2,6 @@
#define UI_SUMMARY_H #define UI_SUMMARY_H
extern void cgit_print_summary(); extern void cgit_print_summary();
extern void cgit_print_repo_readme(); extern void cgit_print_repo_readme(char *path);
#endif /* UI_SUMMARY_H */ #endif /* UI_SUMMARY_H */