summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--cgit.c13
-rw-r--r--cgit.h3
-rw-r--r--cgitrc.5.txt21
-rw-r--r--ui-atom.c2
-rw-r--r--ui-commit.c4
-rw-r--r--ui-patch.c6
-rw-r--r--ui-plain.c12
-rw-r--r--ui-tag.c2
-rw-r--r--ui-tree.c8
9 files changed, 66 insertions, 5 deletions
diff --git a/cgit.c b/cgit.c
index b3a98c1..dbec196 100644
--- a/cgit.c
+++ b/cgit.c
@@ -18,4 +18,12 @@
18const char *cgit_version = CGIT_VERSION; 18const char *cgit_version = CGIT_VERSION;
19 19
20void add_mimetype(const char *name, const char *value)
21{
22 struct string_list_item *item;
23
24 item = string_list_insert(xstrdup(name), &ctx.cfg.mimetypes);
25 item->util = xstrdup(value);
26}
27
20struct cgit_filter *new_filter(const char *cmd, int extra_args) 28struct cgit_filter *new_filter(const char *cmd, int extra_args)
21{ 29{
@@ -67,4 +75,6 @@ void config_cb(const char *name, const char *value)
67 } else if (!strcmp(name, "nocache")) 75 } else if (!strcmp(name, "nocache"))
68 ctx.cfg.nocache = atoi(value); 76 ctx.cfg.nocache = atoi(value);
77 else if (!strcmp(name, "noplainemail"))
78 ctx.cfg.noplainemail = atoi(value);
69 else if (!strcmp(name, "noheader")) 79 else if (!strcmp(name, "noheader"))
70 ctx.cfg.noheader = atoi(value); 80 ctx.cfg.noheader = atoi(value);
@@ -121,4 +131,6 @@ void config_cb(const char *name, const char *value)
121 else if (!strcmp(name, "local-time")) 131 else if (!strcmp(name, "local-time"))
122 ctx.cfg.local_time = atoi(value); 132 ctx.cfg.local_time = atoi(value);
133 else if (!prefixcmp(name, "mimetype."))
134 add_mimetype(name + 9, value);
123 else if (!strcmp(name, "repo.group")) 135 else if (!strcmp(name, "repo.group"))
124 ctx.cfg.repo_group = xstrdup(value); 136 ctx.cfg.repo_group = xstrdup(value);
@@ -237,4 +249,5 @@ static void prepare_context(struct cgit_context *ctx)
237 ctx->page.expires = ctx->page.modified; 249 ctx->page.expires = ctx->page.modified;
238 ctx->page.etag = NULL; 250 ctx->page.etag = NULL;
251 memset(&ctx->cfg.mimetypes, 0, sizeof(struct string_list));
239} 252}
240 253
diff --git a/cgit.h b/cgit.h
index f10ba05..b8557ac 100644
--- a/cgit.h
+++ b/cgit.h
@@ -16,4 +16,5 @@
16#include <log-tree.h> 16#include <log-tree.h>
17#include <archive.h> 17#include <archive.h>
18#include <string-list.h>
18#include <xdiff-interface.h> 19#include <xdiff-interface.h>
19#include <xdiff/xdiff.h> 20#include <xdiff/xdiff.h>
@@ -180,4 +181,5 @@ struct cgit_config {
180 int max_stats; 181 int max_stats;
181 int nocache; 182 int nocache;
183 int noplainemail;
182 int noheader; 184 int noheader;
183 int renamelimit; 185 int renamelimit;
@@ -186,4 +188,5 @@ struct cgit_config {
186 int summary_log; 188 int summary_log;
187 int summary_tags; 189 int summary_tags;
190 struct string_list mimetypes;
188 struct cgit_filter *commit_filter; 191 struct cgit_filter *commit_filter;
189 struct cgit_filter *source_filter; 192 struct cgit_filter *source_filter;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index ffb3e0f..dc63637 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -154,4 +154,8 @@ max-stats::
154 disabled. Default value: none. See also: "repo.max-stats". 154 disabled. Default value: none. See also: "repo.max-stats".
155 155
156mimetype.<ext>::
157 Set the mimetype for the specified filename extension. This is used
158 by the `plain` command when returning blob content.
159
156module-link:: 160module-link::
157 Text which will be used as the formatstring for a hyperlink when a 161 Text which will be used as the formatstring for a hyperlink when a
@@ -165,4 +169,8 @@ nocache::
165 value: "0". 169 value: "0".
166 170
171noplainemail::
172 If set to "1" showing full author email adresses will be disabled.
173 Default value: "0".
174
167noheader:: 175noheader::
168 Flag which, when set to "1", will make cgit omit the standard header 176 Flag which, when set to "1", will make cgit omit the standard header
@@ -346,4 +354,17 @@ snapshots=tar.gz tar.bz2 zip
346 354
347## 355##
356## List of common mimetypes
357##
358
359mimetype.git=image/git
360mimetype.html=text/html
361mimetype.jpg=image/jpeg
362mimetype.jpeg=image/jpeg
363mimetype.pdf=application/pdf
364mimetype.png=image/png
365mimetype.svg=image/svg+xml
366
367
368##
348## List of repositories. 369## List of repositories.
349## PS: Any repositories listed when repo.group is unset will not be 370## PS: Any repositories listed when repo.group is unset will not be
diff --git a/ui-atom.c b/ui-atom.c
index e5c31d9..808b2d0 100644
--- a/ui-atom.c
+++ b/ui-atom.c
@@ -33,5 +33,5 @@ void add_entry(struct commit *commit, char *host)
33 html("</name>\n"); 33 html("</name>\n");
34 } 34 }
35 if (info->author_email) { 35 if (info->author_email && !ctx.cfg.noplainemail) {
36 mail = xstrdup(info->author_email); 36 mail = xstrdup(info->author_email);
37 t = strchr(mail, '<'); 37 t = strchr(mail, '<');
diff --git a/ui-commit.c b/ui-commit.c
index 5815b58..d6b73ee 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -41,6 +41,8 @@ void cgit_print_commit(char *hex)
41 html("<tr><th>author</th><td>"); 41 html("<tr><th>author</th><td>");
42 html_txt(info->author); 42 html_txt(info->author);
43 if (!ctx.cfg.noplainemail) {
43 html(" "); 44 html(" ");
44 html_txt(info->author_email); 45 html_txt(info->author_email);
46 }
45 html("</td><td class='right'>"); 47 html("</td><td class='right'>");
46 cgit_print_date(info->author_date, FMT_LONGDATE, ctx.cfg.local_time); 48 cgit_print_date(info->author_date, FMT_LONGDATE, ctx.cfg.local_time);
@@ -48,6 +50,8 @@ void cgit_print_commit(char *hex)
48 html("<tr><th>committer</th><td>"); 50 html("<tr><th>committer</th><td>");
49 html_txt(info->committer); 51 html_txt(info->committer);
52 if (!ctx.cfg.noplainemail) {
50 html(" "); 53 html(" ");
51 html_txt(info->committer_email); 54 html_txt(info->committer_email);
55 }
52 html("</td><td class='right'>"); 56 html("</td><td class='right'>");
53 cgit_print_date(info->committer_date, FMT_LONGDATE, ctx.cfg.local_time); 57 cgit_print_date(info->committer_date, FMT_LONGDATE, ctx.cfg.local_time);
diff --git a/ui-patch.c b/ui-patch.c
index 5d665d3..2a8f7a5 100644
--- a/ui-patch.c
+++ b/ui-patch.c
@@ -109,5 +109,9 @@ void cgit_print_patch(char *hex)
109 cgit_print_http_headers(&ctx); 109 cgit_print_http_headers(&ctx);
110 htmlf("From %s Mon Sep 17 00:00:00 2001\n", sha1_to_hex(sha1)); 110 htmlf("From %s Mon Sep 17 00:00:00 2001\n", sha1_to_hex(sha1));
111 htmlf("From: %s %s\n", info->author, info->author_email); 111 htmlf("From: %s", info->author);
112 if (!ctx.cfg.noplainemail) {
113 htmlf(" %s", info->author_email);
114 }
115 html("\n");
112 html("Date: "); 116 html("Date: ");
113 cgit_print_date(info->author_date, "%a, %d %b %Y %H:%M:%S %z%n", ctx.cfg.local_time); 117 cgit_print_date(info->author_date, "%a, %d %b %Y %H:%M:%S %z%n", ctx.cfg.local_time);
diff --git a/ui-plain.c b/ui-plain.c
index 93a3a05..27c6dae 100644
--- a/ui-plain.c
+++ b/ui-plain.c
@@ -18,6 +18,7 @@ static void print_object(const unsigned char *sha1, const char *path)
18{ 18{
19 enum object_type type; 19 enum object_type type;
20 char *buf; 20 char *buf, *ext;
21 unsigned long size; 21 unsigned long size;
22 struct string_list_item *mime;
22 23
23 type = sha1_object_info(sha1, &size); 24 type = sha1_object_info(sha1, &size);
@@ -32,8 +33,17 @@ static void print_object(const unsigned char *sha1, const char *path)
32 return; 33 return;
33 } 34 }
35 ctx.page.mimetype = NULL;
36 ext = strrchr(path, '.');
37 if (ext && *(++ext)) {
38 mime = string_list_lookup(ext, &ctx.cfg.mimetypes);
39 if (mime)
40 ctx.page.mimetype = (char *)mime->util;
41 }
42 if (!ctx.page.mimetype) {
34 if (buffer_is_binary(buf, size)) 43 if (buffer_is_binary(buf, size))
35 ctx.page.mimetype = "application/octet-stream"; 44 ctx.page.mimetype = "application/octet-stream";
36 else 45 else
37 ctx.page.mimetype = "text/plain"; 46 ctx.page.mimetype = "text/plain";
47 }
38 ctx.page.filename = fmt("%s", path); 48 ctx.page.filename = fmt("%s", path);
39 ctx.page.size = size; 49 ctx.page.size = size;
diff --git a/ui-tag.c b/ui-tag.c
index 0e056e0..a9c8670 100644
--- a/ui-tag.c
+++ b/ui-tag.c
@@ -65,5 +65,5 @@ void cgit_print_tag(char *revname)
65 html("<tr><td>Tagged by</td><td>"); 65 html("<tr><td>Tagged by</td><td>");
66 html_txt(info->tagger); 66 html_txt(info->tagger);
67 if (info->tagger_email) { 67 if (info->tagger_email && !ctx.cfg.noplainemail) {
68 html(" "); 68 html(" ");
69 html_txt(info->tagger_email); 69 html_txt(info->tagger_email);
diff --git a/ui-tree.c b/ui-tree.c
index caf6a9e..c608754 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -114,4 +114,5 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen,
114 char *name; 114 char *name;
115 char *fullpath; 115 char *fullpath;
116 char *class;
116 enum object_type type; 117 enum object_type type;
117 unsigned long size = 0; 118 unsigned long size = 0;
@@ -146,5 +147,10 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen,
146 curr_rev, fullpath); 147 curr_rev, fullpath);
147 } else { 148 } else {
148 cgit_tree_link(name, NULL, "ls-blob", ctx.qry.head, 149 class = strrchr(name, '.');
150 if (class != NULL) {
151 class = fmt("ls-blob %s", class + 1);
152 } else
153 class = "ls-blob";
154 cgit_tree_link(name, NULL, class, ctx.qry.head,
149 curr_rev, fullpath); 155 curr_rev, fullpath);
150 } 156 }