From: Lars Hjemli Date: Sun, 9 Aug 2009 11:45:36 +0000 (+0200) Subject: Merge branch 'lh/mimetypes' X-Git-Url: https://gitweb.ps.run/ps-cgit/commitdiff_plain/17e3ff42646f182911fd0e5d872082977538db9e?hp=-c Merge branch 'lh/mimetypes' --- 17e3ff42646f182911fd0e5d872082977538db9e diff --combined cgit.c index f6bb0c7,4f414c3..aa1107a --- a/cgit.c +++ b/cgit.c @@@ -17,6 -17,14 +17,14 @@@ const char *cgit_version = CGIT_VERSION; + void add_mimetype(const char *name, const char *value) + { + struct string_list_item *item; + + item = string_list_insert(xstrdup(name), &ctx.cfg.mimetypes); + item->util = xstrdup(value); + } + void config_cb(const char *name, const char *value) { if (!strcmp(name, "root-title")) @@@ -51,8 -59,6 +59,8 @@@ ctx.cfg.virtual_root = ""; } else if (!strcmp(name, "nocache")) ctx.cfg.nocache = atoi(value); + else if (!strcmp(name, "noplainemail")) + ctx.cfg.noplainemail = atoi(value); else if (!strcmp(name, "noheader")) ctx.cfg.noheader = atoi(value); else if (!strcmp(name, "snapshots")) @@@ -103,6 -109,8 +111,8 @@@ ctx.cfg.clone_prefix = xstrdup(value); else if (!strcmp(name, "local-time")) ctx.cfg.local_time = atoi(value); + else if (!prefixcmp(name, "mimetype.")) + add_mimetype(name + 9, value); else if (!strcmp(name, "repo.group")) ctx.cfg.repo_group = xstrdup(value); else if (!strcmp(name, "repo.url")) @@@ -215,6 -223,7 +225,7 @@@ static void prepare_context(struct cgit ctx->page.modified = time(NULL); ctx->page.expires = ctx->page.modified; ctx->page.etag = NULL; + memset(&ctx->cfg.mimetypes, 0, sizeof(struct string_list)); } struct refmatch { diff --combined cgit.h index acb5e8f,9259f33..1194eb0 --- a/cgit.h +++ b/cgit.h @@@ -15,6 -15,7 +15,7 @@@ #include #include #include + #include #include #include #include @@@ -168,13 -169,13 +169,14 @@@ struct cgit_config int max_repodesc_len; int max_stats; int nocache; + int noplainemail; int noheader; int renamelimit; int snapshots; int summary_branches; int summary_log; int summary_tags; + struct string_list mimetypes; }; struct cgit_page { diff --combined cgitrc.5.txt index 7754923,7256ec0..0412f64 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@@ -147,6 -147,10 +147,10 @@@ max-stats: "month", "quarter" and "year". If unspecified, statistics are disabled. Default value: none. See also: "repo.max-stats". + mimetype.:: + Set the mimetype for the specified filename extension. This is used + by the `plain` command when returning blob content. + module-link:: Text which will be used as the formatstring for a hyperlink when a submodule is printed in a directory listing. The arguments for the @@@ -158,10 -162,6 +162,10 @@@ nocache: deprecated, and will not be honored starting with cgit-1.0. Default value: "0". +noplainemail:: + If set to "1" showing full author email adresses will be disabled. + Default value: "0". + noheader:: Flag which, when set to "1", will make cgit omit the standard header on all pages. Default value: none. See also: "embedded". @@@ -328,6 -328,19 +332,19 @@@ root-readme=/var/www/htdocs/about.htm snapshots=tar.gz tar.bz2 zip + ## + ## List of common mimetypes + ## + + mimetype.git=image/git + mimetype.html=text/html + mimetype.jpg=image/jpeg + mimetype.jpeg=image/jpeg + mimetype.pdf=application/pdf + mimetype.png=image/png + mimetype.svg=image/svg+xml + + ## ## List of repositories. ## PS: Any repositories listed when repo.group is unset will not be