-rw-r--r-- | Makefile | 15 | ||||
-rw-r--r-- | cgit.c | 9 | ||||
-rw-r--r-- | cgit.css | 5 | ||||
-rw-r--r-- | cgit.h | 1 | ||||
-rw-r--r-- | cgitrc.5.txt | 15 | ||||
-rwxr-xr-x | filters/syntax-highlighting.sh | 29 | ||||
-rw-r--r-- | shared.c | 17 | ||||
-rw-r--r-- | ui-repolist.c | 2 | ||||
-rw-r--r-- | ui-shared.c | 11 | ||||
-rw-r--r-- | ui-shared.h | 1 | ||||
-rw-r--r-- | ui-tag.c | 24 | ||||
-rw-r--r-- | ui-tree.c | 6 |
12 files changed, 94 insertions, 41 deletions
@@ -12,4 +12,7 @@ INSTALL = install | |||
12 | # Define NO_STRCASESTR if you don't have strcasestr. | 12 | # Define NO_STRCASESTR if you don't have strcasestr. |
13 | # | 13 | # |
14 | # Define NO_OPENSSL to disable linking with OpenSSL and use bundled SHA1 | ||
15 | # implementation (slower). | ||
16 | # | ||
14 | # Define NEEDS_LIBICONV if linking with libc is not enough (eg. Darwin). | 17 | # Define NEEDS_LIBICONV if linking with libc is not enough (eg. Darwin). |
15 | # | 18 | # |
@@ -69,5 +72,5 @@ endif | |||
69 | 72 | ||
70 | 73 | ||
71 | EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto | 74 | EXTLIBS = git/libgit.a git/xdiff/lib.a -lz |
72 | OBJECTS = | 75 | OBJECTS = |
73 | OBJECTS += cache.o | 76 | OBJECTS += cache.o |
@@ -125,4 +128,10 @@ ifdef NO_STRCASESTR | |||
125 | CFLAGS += -DNO_STRCASESTR | 128 | CFLAGS += -DNO_STRCASESTR |
126 | endif | 129 | endif |
130 | ifdef NO_OPENSSL | ||
131 | CFLAGS += -DNO_OPENSSL | ||
132 | GIT_OPTIONS += NO_OPENSSL=1 | ||
133 | else | ||
134 | EXTLIBS += -lcrypto | ||
135 | endif | ||
127 | 136 | ||
128 | cgit: $(OBJECTS) libgit | 137 | cgit: $(OBJECTS) libgit |
@@ -134,6 +143,6 @@ cgit.o: VERSION | |||
134 | 143 | ||
135 | libgit: | 144 | libgit: |
136 | $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 libgit.a | 145 | $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 $(GIT_OPTIONS) libgit.a |
137 | $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 xdiff/lib.a | 146 | $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 $(GIT_OPTIONS) xdiff/lib.a |
138 | 147 | ||
139 | test: all | 148 | test: all |
@@ -69,7 +69,7 @@ void repo_config(struct cgit_repo *repo, const char *name, const char *value) | |||
69 | else if (!strcmp(name, "readme") && value != NULL) { | 69 | else if (!strcmp(name, "readme") && value != NULL) { |
70 | if (*value == '/') | 70 | if (*value == '/') |
71 | ctx.repo->readme = xstrdup(value); | 71 | repo->readme = xstrdup(value); |
72 | else | 72 | else |
73 | ctx.repo->readme = xstrdup(fmt("%s/%s", ctx.repo->path, value)); | 73 | repo->readme = xstrdup(fmt("%s/%s", repo->path, value)); |
74 | } else if (ctx.cfg.enable_filter_overrides) { | 74 | } else if (ctx.cfg.enable_filter_overrides) { |
75 | if (!strcmp(name, "about-filter")) | 75 | if (!strcmp(name, "about-filter")) |
@@ -166,4 +166,6 @@ void config_cb(const char *name, const char *value) | |||
166 | else if (!strcmp(name, "max-repodesc-length")) | 166 | else if (!strcmp(name, "max-repodesc-length")) |
167 | ctx.cfg.max_repodesc_len = atoi(value); | 167 | ctx.cfg.max_repodesc_len = atoi(value); |
168 | else if (!strcmp(name, "max-blob-size")) | ||
169 | ctx.cfg.max_blob_size = atoi(value); | ||
168 | else if (!strcmp(name, "max-repo-count")) | 170 | else if (!strcmp(name, "max-repo-count")) |
169 | ctx.cfg.max_repo_count = atoi(value); | 171 | ctx.cfg.max_repo_count = atoi(value); |
@@ -212,4 +214,6 @@ static void querystring_cb(const char *name, const char *value) | |||
212 | ctx.qry.page = xstrdup(value); | 214 | ctx.qry.page = xstrdup(value); |
213 | } else if (!strcmp(name, "url")) { | 215 | } else if (!strcmp(name, "url")) { |
216 | if (*value == '/') | ||
217 | value++; | ||
214 | ctx.qry.url = xstrdup(value); | 218 | ctx.qry.url = xstrdup(value); |
215 | cgit_parse_url(value); | 219 | cgit_parse_url(value); |
@@ -273,4 +277,5 @@ static void prepare_context(struct cgit_context *ctx) | |||
273 | ctx->cfg.max_msg_len = 80; | 277 | ctx->cfg.max_msg_len = 80; |
274 | ctx->cfg.max_repodesc_len = 80; | 278 | ctx->cfg.max_repodesc_len = 80; |
279 | ctx->cfg.max_blob_size = 0; | ||
275 | ctx->cfg.max_stats = 0; | 280 | ctx->cfg.max_stats = 0; |
276 | ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s"; | 281 | ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s"; |
@@ -163,4 +163,9 @@ table.list td a { | |||
163 | } | 163 | } |
164 | 164 | ||
165 | table.list td a.ls-dir { | ||
166 | font-weight: bold; | ||
167 | color: #00f; | ||
168 | } | ||
169 | |||
165 | table.list td a:hover { | 170 | table.list td a:hover { |
166 | color: #00f; | 171 | color: #00f; |
@@ -187,4 +187,5 @@ struct cgit_config { | |||
187 | int max_msg_len; | 187 | int max_msg_len; |
188 | int max_repodesc_len; | 188 | int max_repodesc_len; |
189 | int max_blob_size; | ||
189 | int max_stats; | 190 | int max_stats; |
190 | int nocache; | 191 | int nocache; |
diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 252d546..70e4c78 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt | |||
@@ -1,2 +1,5 @@ | |||
1 | :man source: cgit | ||
2 | :man manual: cgit | ||
3 | |||
1 | CGITRC(5) | 4 | CGITRC(5) |
2 | ======== | 5 | ======== |
@@ -175,4 +178,8 @@ max-repodesc-length:: | |||
175 | on the repository index page. Default value: "80". | 178 | on the repository index page. Default value: "80". |
176 | 179 | ||
180 | max-blob-size:: | ||
181 | Specifies the maximum size of a blob to display HTML for in KBytes. | ||
182 | Default value: "0" (limit disabled). | ||
183 | |||
177 | max-stats:: | 184 | max-stats:: |
178 | Set the default maximum statistics period. Valid values are "week", | 185 | Set the default maximum statistics period. Valid values are "week", |
@@ -426,6 +433,6 @@ mimetype.svg=image/svg+xml | |||
426 | ## | 433 | ## |
427 | ## List of repositories. | 434 | ## List of repositories. |
428 | ## PS: Any repositories listed when repo.group is unset will not be | 435 | ## PS: Any repositories listed when section is unset will not be |
429 | ## displayed under a group heading | 436 | ## displayed under a section heading |
430 | ## PPS: This list could be kept in a different file (e.g. '/etc/cgitrepos') | 437 | ## PPS: This list could be kept in a different file (e.g. '/etc/cgitrepos') |
431 | ## and included like this: | 438 | ## and included like this: |
@@ -449,5 +456,5 @@ repo.readme=info/web/about.html | |||
449 | 456 | ||
450 | # The next repositories will be displayed under the 'extras' heading | 457 | # The next repositories will be displayed under the 'extras' heading |
451 | repo.group=extras | 458 | section=extras |
452 | 459 | ||
453 | 460 | ||
@@ -462,5 +469,5 @@ repo.desc=the wizard of foo | |||
462 | 469 | ||
463 | # Add some mirrored repositories | 470 | # Add some mirrored repositories |
464 | repo.group=mirrors | 471 | section=mirrors |
465 | 472 | ||
466 | 473 | ||
diff --git a/filters/syntax-highlighting.sh b/filters/syntax-highlighting.sh index 999ad0c..6b1c576 100755 --- a/filters/syntax-highlighting.sh +++ b/filters/syntax-highlighting.sh | |||
@@ -4,4 +4,8 @@ | |||
4 | # filter options in cgitrc. | 4 | # filter options in cgitrc. |
5 | # | 5 | # |
6 | # This script requires a shell supporting the ${var##pattern} syntax. | ||
7 | # It is supported by at least dash and bash, however busybox environments | ||
8 | # might have to use an external call to sed instead. | ||
9 | # | ||
6 | # Note: the highlight command (http://www.andre-simon.de/) uses css for syntax | 10 | # Note: the highlight command (http://www.andre-simon.de/) uses css for syntax |
7 | # highlighting, so you'll probably want something like the following included | 11 | # highlighting, so you'll probably want something like the following included |
@@ -21,19 +25,10 @@ | |||
21 | # table.blob .kwd { color:#010181; } | 25 | # table.blob .kwd { color:#010181; } |
22 | 26 | ||
23 | case "$1" in | 27 | # store filename and extension in local vars |
24 | *.c) | 28 | BASENAME="$1" |
25 | highlight -f -I -X -S c | 29 | EXTENSION="${BASENAME##*.}" |
26 | ;; | 30 | |
27 | *.h) | 31 | # map Makefile and Makefile.* to .mk |
28 | highlight -f -I -X -S c | 32 | [ "${BASENAME%%.*}" == "Makefile" ] && EXTENSION=mk |
29 | ;; | 33 | |
30 | *.sh) | 34 | exec highlight --force -f -I -X -S $EXTENSION 2>/dev/null |
31 | highlight -f -I -X -S sh | ||
32 | ;; | ||
33 | *.css) | ||
34 | highlight -f -I -X -S css | ||
35 | ;; | ||
36 | *) | ||
37 | highlight -f -I -X -S txt | ||
38 | ;; | ||
39 | esac | ||
@@ -401,5 +401,5 @@ int cgit_close_filter(struct cgit_filter *filter) | |||
401 | int readfile(const char *path, char **buf, size_t *size) | 401 | int readfile(const char *path, char **buf, size_t *size) |
402 | { | 402 | { |
403 | int fd; | 403 | int fd, e; |
404 | struct stat st; | 404 | struct stat st; |
405 | 405 | ||
@@ -407,11 +407,18 @@ int readfile(const char *path, char **buf, size_t *size) | |||
407 | if (fd == -1) | 407 | if (fd == -1) |
408 | return errno; | 408 | return errno; |
409 | if (fstat(fd, &st)) | 409 | if (fstat(fd, &st)) { |
410 | return errno; | 410 | e = errno; |
411 | if (!S_ISREG(st.st_mode)) | 411 | close(fd); |
412 | return e; | ||
413 | } | ||
414 | if (!S_ISREG(st.st_mode)) { | ||
415 | close(fd); | ||
412 | return EISDIR; | 416 | return EISDIR; |
417 | } | ||
413 | *buf = xmalloc(st.st_size + 1); | 418 | *buf = xmalloc(st.st_size + 1); |
414 | *size = read_in_full(fd, *buf, st.st_size); | 419 | *size = read_in_full(fd, *buf, st.st_size); |
420 | e = errno; | ||
415 | (*buf)[*size] = '\0'; | 421 | (*buf)[*size] = '\0'; |
416 | return (*size == st.st_size ? 0 : errno); | 422 | close(fd); |
423 | return (*size == st.st_size ? 0 : e); | ||
417 | } | 424 | } |
diff --git a/ui-repolist.c b/ui-repolist.c index 3ef2e99..0a0b6ca 100644 --- a/ui-repolist.c +++ b/ui-repolist.c | |||
@@ -95,5 +95,5 @@ int is_in_url(struct cgit_repo *repo) | |||
95 | void print_sort_header(const char *title, const char *sort) | 95 | void print_sort_header(const char *title, const char *sort) |
96 | { | 96 | { |
97 | htmlf("<th class='left'><a href='./?s=%s", sort); | 97 | htmlf("<th class='left'><a href='%s?s=%s", cgit_rooturl(), sort); |
98 | if (ctx.qry.search) { | 98 | if (ctx.qry.search) { |
99 | html("&q="); | 99 | html("&q="); |
diff --git a/ui-shared.c b/ui-shared.c index de55eff..08ea003 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -21,5 +21,5 @@ static char *http_date(time_t t) | |||
21 | static char month[][4] = | 21 | static char month[][4] = |
22 | {"Jan", "Feb", "Mar", "Apr", "May", "Jun", | 22 | {"Jan", "Feb", "Mar", "Apr", "May", "Jun", |
23 | "Jul", "Aug", "Sep", "Oct", "Now", "Dec"}; | 23 | "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; |
24 | struct tm *tm = gmtime(&t); | 24 | struct tm *tm = gmtime(&t); |
25 | return fmt("%s, %02d %s %04d %02d:%02d:%02d GMT", day[tm->tm_wday], | 25 | return fmt("%s, %02d %s %04d %02d:%02d:%02d GMT", day[tm->tm_wday], |
@@ -783,11 +783,16 @@ void cgit_print_snapshot_links(const char *repo, const char *head, | |||
783 | { | 783 | { |
784 | const struct cgit_snapshot_format* f; | 784 | const struct cgit_snapshot_format* f; |
785 | char *prefix; | ||
785 | char *filename; | 786 | char *filename; |
787 | unsigned char sha1[20]; | ||
786 | 788 | ||
789 | if (get_sha1(fmt("refs/tags/%s", hex), sha1) == 0 && | ||
790 | (hex[0] == 'v' || hex[0] == 'V') && isdigit(hex[1])) | ||
791 | hex++; | ||
792 | prefix = xstrdup(fmt("%s-%s", cgit_repobasename(repo), hex)); | ||
787 | for (f = cgit_snapshot_formats; f->suffix; f++) { | 793 | for (f = cgit_snapshot_formats; f->suffix; f++) { |
788 | if (!(snapshots & f->bit)) | 794 | if (!(snapshots & f->bit)) |
789 | continue; | 795 | continue; |
790 | filename = fmt("%s-%s%s", cgit_repobasename(repo), hex, | 796 | filename = fmt("%s%s", prefix, f->suffix); |
791 | f->suffix); | ||
792 | cgit_snapshot_link(filename, NULL, NULL, NULL, NULL, filename); | 797 | cgit_snapshot_link(filename, NULL, NULL, NULL, NULL, filename); |
793 | html("<br/>"); | 798 | html("<br/>"); |
diff --git a/ui-shared.h b/ui-shared.h index 166246d..9ebc1f9 100644 --- a/ui-shared.h +++ b/ui-shared.h | |||
@@ -4,4 +4,5 @@ | |||
4 | extern char *cgit_httpscheme(); | 4 | extern char *cgit_httpscheme(); |
5 | extern char *cgit_hosturl(); | 5 | extern char *cgit_hosturl(); |
6 | extern char *cgit_rooturl(); | ||
6 | extern char *cgit_repourl(const char *reponame); | 7 | extern char *cgit_repourl(const char *reponame); |
7 | extern char *cgit_fileurl(const char *reponame, const char *pagename, | 8 | extern char *cgit_fileurl(const char *reponame, const char *pagename, |
@@ -31,4 +31,12 @@ static void print_tag_content(char *buf) | |||
31 | } | 31 | } |
32 | 32 | ||
33 | void print_download_links(char *revname) | ||
34 | { | ||
35 | html("<tr><th>download</th><td class='sha1'>"); | ||
36 | cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head, | ||
37 | revname, ctx.repo->snapshots); | ||
38 | html("</td></tr>"); | ||
39 | } | ||
40 | |||
33 | void cgit_print_tag(char *revname) | 41 | void cgit_print_tag(char *revname) |
34 | { | 42 | { |
@@ -57,14 +65,14 @@ void cgit_print_tag(char *revname) | |||
57 | } | 65 | } |
58 | html("<table class='commit-info'>\n"); | 66 | html("<table class='commit-info'>\n"); |
59 | htmlf("<tr><td>Tag name</td><td>"); | 67 | htmlf("<tr><td>tag name</td><td>"); |
60 | html_txt(revname); | 68 | html_txt(revname); |
61 | htmlf(" (%s)</td></tr>\n", sha1_to_hex(sha1)); | 69 | htmlf(" (%s)</td></tr>\n", sha1_to_hex(sha1)); |
62 | if (info->tagger_date > 0) { | 70 | if (info->tagger_date > 0) { |
63 | html("<tr><td>Tag date</td><td>"); | 71 | html("<tr><td>tag date</td><td>"); |
64 | cgit_print_date(info->tagger_date, FMT_LONGDATE, ctx.cfg.local_time); | 72 | cgit_print_date(info->tagger_date, FMT_LONGDATE, ctx.cfg.local_time); |
65 | html("</td></tr>\n"); | 73 | html("</td></tr>\n"); |
66 | } | 74 | } |
67 | if (info->tagger) { | 75 | if (info->tagger) { |
68 | html("<tr><td>Tagged by</td><td>"); | 76 | html("<tr><td>tagged by</td><td>"); |
69 | html_txt(info->tagger); | 77 | html_txt(info->tagger); |
70 | if (info->tagger_email && !ctx.cfg.noplainemail) { | 78 | if (info->tagger_email && !ctx.cfg.noplainemail) { |
@@ -74,17 +82,21 @@ void cgit_print_tag(char *revname) | |||
74 | html("</td></tr>\n"); | 82 | html("</td></tr>\n"); |
75 | } | 83 | } |
76 | html("<tr><td>Tagged object</td><td>"); | 84 | html("<tr><td>tagged object</td><td class='sha1'>"); |
77 | cgit_object_link(tag->tagged); | 85 | cgit_object_link(tag->tagged); |
78 | html("</td></tr>\n"); | 86 | html("</td></tr>\n"); |
87 | if (ctx.repo->snapshots) | ||
88 | print_download_links(revname); | ||
79 | html("</table>\n"); | 89 | html("</table>\n"); |
80 | print_tag_content(info->msg); | 90 | print_tag_content(info->msg); |
81 | } else { | 91 | } else { |
82 | html("<table class='commit-info'>\n"); | 92 | html("<table class='commit-info'>\n"); |
83 | htmlf("<tr><td>Tag name</td><td>"); | 93 | htmlf("<tr><td>tag name</td><td>"); |
84 | html_txt(revname); | 94 | html_txt(revname); |
85 | html("</td></tr>\n"); | 95 | html("</td></tr>\n"); |
86 | html("<tr><td>Tagged object</td><td>"); | 96 | html("<tr><td>Tagged object</td><td class='sha1'>"); |
87 | cgit_object_link(obj); | 97 | cgit_object_link(obj); |
88 | html("</td></tr>\n"); | 98 | html("</td></tr>\n"); |
99 | if (ctx.repo->snapshots) | ||
100 | print_download_links(revname); | ||
89 | html("</table>\n"); | 101 | html("</table>\n"); |
90 | } | 102 | } |
@@ -108,4 +108,10 @@ static void print_object(const unsigned char *sha1, char *path, const char *base | |||
108 | htmlf(")<br/>blob: %s\n", sha1_to_hex(sha1)); | 108 | htmlf(")<br/>blob: %s\n", sha1_to_hex(sha1)); |
109 | 109 | ||
110 | if (ctx.cfg.max_blob_size && size / 1024 > ctx.cfg.max_blob_size) { | ||
111 | htmlf("<div class='error'>blob size (%dKB) exceeds display size limit (%dKB).</div>", | ||
112 | size / 1024, ctx.cfg.max_blob_size); | ||
113 | return; | ||
114 | } | ||
115 | |||
110 | if (buffer_is_binary(buf, size)) | 116 | if (buffer_is_binary(buf, size)) |
111 | print_binary_buffer(buf, size); | 117 | print_binary_buffer(buf, size); |