aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile5
-rw-r--r--cgit.css11
-rw-r--r--cgit.h7
-rw-r--r--parsing.c25
-rw-r--r--shared.c2
-rw-r--r--ui-log.c21
-rw-r--r--ui-shared.c2
7 files changed, 55 insertions, 18 deletions
diff --git a/Makefile b/Makefile
index 27e966d..685e662 100644
--- a/Makefile
+++ b/Makefile
@@ -19,6 +19,11 @@ OBJECTS = shared.o cache.o parsing.o html.o ui-shared.o ui-repolist.o \
ui-snapshot.o ui-blob.o ui-tag.o ui-refs.o
+ifdef NEEDS_LIBICONV
+ EXTLIBS += -liconv
+endif
+
+
.PHONY: all git install clean distclean emptycache force-version get-git
all: cgit git
diff --git a/cgit.css b/cgit.css
index 1b2e9d6..f1003b4 100644
--- a/cgit.css
+++ b/cgit.css
@@ -109,7 +109,7 @@ div#sidebar div.infobox {
}
div#sidebar div.infobox h1 {
- font-size: 11pt;
+ font-size: 10pt;
font-weight: bold;
margin: 0px;
}
@@ -128,10 +128,7 @@ 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;
}
td#branch-dropdown-cell {
@@ -140,18 +137,12 @@ 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;
}
table#grid {
diff --git a/cgit.h b/cgit.h
index 163f355..6291c58 100644
--- a/cgit.h
+++ b/cgit.h
@@ -16,6 +16,7 @@
#include <log-tree.h>
#include <archive.h>
#include <xdiff/xdiff.h>
+#include <utf8.h>
/*
@@ -48,6 +49,11 @@
#define TM_MONTH (TM_YEAR / 12.0)
+/*
+ * Default encoding
+ */
+#define PAGE_ENCODING "UTF-8"
+
typedef void (*configfn)(const char *name, const char *value);
typedef void (*filepair_fn)(struct diff_filepair *pair);
typedef void (*linediff_fn)(char *line, int len);
@@ -90,6 +96,7 @@ struct commitinfo {
unsigned long committer_date;
char *subject;
char *msg;
+ char *msg_encoding;
};
struct taginfo {
diff --git a/parsing.c b/parsing.c
index 30e7648..e8c7ab9 100644
--- a/parsing.c
+++ b/parsing.c
@@ -199,6 +199,7 @@ struct commitinfo *cgit_parse_commit(struct commit *commit)
ret->committer_email = NULL;
ret->subject = NULL;
ret->msg = NULL;
+ ret->msg_encoding = NULL;
if (p == NULL)
return ret;
@@ -233,6 +234,14 @@ struct commitinfo *cgit_parse_commit(struct commit *commit)
p = strchr(t, '\n') + 1;
}
+ 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
@@ -253,6 +262,22 @@ struct commitinfo *cgit_parse_commit(struct commit *commit)
} else
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;
}
diff --git a/shared.c b/shared.c
index 6117f5c..8cb4808 100644
--- a/shared.c
+++ b/shared.c
@@ -267,6 +267,8 @@ void *cgit_free_commitinfo(struct commitinfo *info)
free(info->committer);
free(info->committer_email);
free(info->subject);
+ free(info->msg);
+ free(info->msg_encoding);
free(info);
return NULL;
}
diff --git a/ui-log.c b/ui-log.c
index 9f5fdf6..e5f3c57 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -8,12 +8,18 @@
#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++;
}
void inspect_files(struct diff_filepair *pair)
@@ -35,13 +41,14 @@ void print_commit(struct commit *commit)
sha1_to_hex(commit->object.sha1));
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'>");
htmlf("%d", files);
if (cgit_repo->enable_log_linecount) {
html("</td><td class='right'>");
- htmlf("%d", lines);
+ htmlf("-%d/+%d", rem_lines, add_lines);
}
}
html("</td><td>");
@@ -88,9 +95,9 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern
"<th class='left'>Message</th>");
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
@@ -352,7 +352,7 @@ 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 +
ttl_seconds(item->ttl)));