-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | cgit.css | 11 | ||||
-rw-r--r-- | cgit.h | 7 | ||||
-rw-r--r-- | parsing.c | 25 | ||||
-rw-r--r-- | shared.c | 2 | ||||
-rw-r--r-- | ui-log.c | 21 | ||||
-rw-r--r-- | ui-shared.c | 2 |
7 files changed, 55 insertions, 18 deletions
@@ -20,4 +20,9 @@ OBJECTS = shared.o cache.o parsing.o html.o ui-shared.o ui-repolist.o \ +ifdef NEEDS_LIBICONV + EXTLIBS += -liconv +endif + + .PHONY: all git install clean distclean emptycache force-version get-git @@ -110,5 +110,5 @@ div#sidebar div.infobox { div#sidebar div.infobox h1 { - font-size: 11pt; + font-size: 10pt; font-weight: bold; margin: 0px; @@ -129,8 +129,5 @@ div#sidebar div.infobox a.menu:hover { div#sidebar div.infobox select { width: 100%; - border: solid 1px #aaa; - background-color: #bbb; margin: 2px 0px 0px 0px; - padding: 0px; } @@ -141,16 +138,10 @@ td#branch-dropdown-cell { input#switch-btn { width: 20px; - border: solid 1px #aaa; - background-color: #bbb; margin: 2px 0px 0px 0px; - padding: 0px; } div#sidebar div.infobox input.txt { width: 100%; - border: solid 1px #aaa; - background-color: #bbb; margin: 2px 0px 0px 0px; - padding: 0; } @@ -17,4 +17,5 @@ #include <archive.h> #include <xdiff/xdiff.h> +#include <utf8.h> @@ -49,4 +50,9 @@ +/* + * Default encoding + */ +#define PAGE_ENCODING "UTF-8" + typedef void (*configfn)(const char *name, const char *value); typedef void (*filepair_fn)(struct diff_filepair *pair); @@ -91,4 +97,5 @@ struct commitinfo { char *subject; char *msg; + char *msg_encoding; }; @@ -200,4 +200,5 @@ struct commitinfo *cgit_parse_commit(struct commit *commit) ret->subject = NULL; ret->msg = NULL; + ret->msg_encoding = NULL; if (p == NULL) @@ -234,4 +235,12 @@ struct commitinfo *cgit_parse_commit(struct commit *commit) } + if (!strncmp(p, "encoding ", 9)) { + p += 9; + t = strchr(p, '\n') + 1; + ret->msg_encoding = substr(p, t); + p = t; + } else + ret->msg_encoding = xstrdup(PAGE_ENCODING); + while (*p && (*p != '\n')) p = strchr(p, '\n') + 1; // skip unknown header fields @@ -254,4 +263,20 @@ struct commitinfo *cgit_parse_commit(struct commit *commit) ret->subject = substr(p, p+strlen(p)); + if(strcmp(ret->msg_encoding, PAGE_ENCODING)) { + t = reencode_string(ret->subject, PAGE_ENCODING, + ret->msg_encoding); + if(t) { + free(ret->subject); + ret->subject = t; + } + + t = reencode_string(ret->msg, PAGE_ENCODING, + ret->msg_encoding); + if(t) { + free(ret->msg); + ret->msg = t; + } + } + return ret; } @@ -268,4 +268,6 @@ void *cgit_free_commitinfo(struct commitinfo *info) free(info->committer_email); free(info->subject); + free(info->msg); + free(info->msg_encoding); free(info); return NULL; @@ -9,10 +9,16 @@ #include "cgit.h" -int files, lines; +int files, add_lines, rem_lines; void count_lines(char *line, int size) { - if (size>0 && (line[0] == '+' || line[0] == '-')) - lines++; + if (size <= 0) + return; + + if (line[0] == '+') + add_lines++; + + else if (line[0] == '-') + rem_lines++; } @@ -36,5 +42,6 @@ void print_commit(struct commit *commit) if (cgit_repo->enable_log_filecount) { files = 0; - lines = 0; + add_lines = 0; + rem_lines = 0; cgit_diff_commit(commit, inspect_files); html("</td><td class='right'>"); @@ -42,5 +49,5 @@ void print_commit(struct commit *commit) if (cgit_repo->enable_log_linecount) { html("</td><td class='right'>"); - htmlf("%d", lines); + htmlf("-%d/+%d", rem_lines, add_lines); } } @@ -89,7 +96,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern if (cgit_repo->enable_log_filecount) { - html("<th class='left'>Files</th>"); + html("<th class='right'>Files</th>"); if (cgit_repo->enable_log_linecount) - html("<th class='left'>Lines</th>"); + html("<th class='right'>Lines</th>"); } html("<th class='left'>Author</th></tr>\n"); diff --git a/ui-shared.c b/ui-shared.c index 72a7b44..7c69f60 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -353,5 +353,5 @@ void cgit_print_age(time_t t, time_t max_relative, char *format) void cgit_print_docstart(char *title, struct cacheitem *item) { - html("Content-Type: text/html; charset=utf-8\n"); + html("Content-Type: text/html; charset=" PAGE_ENCODING "\n"); htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); htmlf("Expires: %s\n", http_date(item->st.st_mtime + |