-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | add.png | bin | 168 -> 0 bytes | |||
-rw-r--r-- | cgit.css | 21 | ||||
-rw-r--r-- | del.png | bin | 168 -> 0 bytes | |||
-rw-r--r-- | ui-commit.c | 20 |
5 files changed, 27 insertions, 15 deletions
@@ -39,47 +39,46 @@ INITGIT = ./submodules.sh -i endif # # basic build rules # all: cgit cgit: cgit.c cgit.h $(OBJECTS) $(CC) $(CFLAGS) cgit.c -o cgit $(OBJECTS) $(EXTLIBS) $(OBJECTS): cgit.h git/libgit.a git/libgit.a: $(INITGIT) $(MAKE) -C git # # phony targets # install: all clean-cache mkdir -p $(prefix) install cgit $(prefix)/$(CGIT_SCRIPT_NAME) install cgit.css $(prefix)/cgit.css - install add.png del.png $(prefix)/ clean-cgit: rm -f cgit *.o distclean-cgit: clean-cgit git clean -d -x clean-sub: $(MAKE) -C git clean distclean-sub: clean-sub $(shell cd git && git clean -d -x) clean-cache: rm -rf $(CACHE_ROOT)/* clean: clean-cgit clean-sub distclean: distclean-cgit distclean-sub .PHONY: all install clean clean-cgit clean-sub clean-cache \ distclean distclean-cgit distclean-sub diff --git a/add.png b/add.png Binary files differdeleted file mode 100644 index c550388..0000000 --- a/add.png +++ b/dev/null @@ -263,51 +263,68 @@ table.diffstat td { } table.diffstat td span.modechange { padding-left: 1em; color: red; } table.diffstat td.add a { color: green; } table.diffstat td.del a { color: red; } table.diffstat td.upd a { color: blue; } table.diffstat td.graph { width: 75%; vertical-align: center; } -table.diffstat td.graph img { +table.diffstat td.graph table { border: none; - height: 8pt; +} + +table.diffstat td.graph td { + padding: 0px; + border: 0px; + height: 7pt; +} + +table.diffstat td.graph td.add { + background-color: #5c5; +} + +table.diffstat td.graph td.rem { + background-color: #c55; +} + +table.diffstat td.graph td.none { + background-color: none; } div.diffstat-summary { color: #888; padding-top: 0.5em; } table.diff td { font-family: monospace; white-space: pre; } table.diff td div.head { font-weight: bold; padding-top: 1em; } table.diff td div.hunk { color: #009; } table.diff td div.add { color: green; } diff --git a/del.png b/del.png Binary files differdeleted file mode 100644 index 5c73e82..0000000 --- a/del.png +++ b/dev/null diff --git a/ui-commit.c b/ui-commit.c index b6a106f..8011dfc 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -8,49 +8,48 @@ #include "cgit.h" static int files, slots; static int total_adds, total_rems, max_changes; static int lines_added, lines_removed; static struct fileinfo { char status; unsigned char old_sha1[20]; unsigned char new_sha1[20]; unsigned short old_mode; unsigned short new_mode; char *old_path; char *new_path; unsigned int added; unsigned int removed; } *items; void print_fileinfo(struct fileinfo *info) { char *query, *query2; char *class; - double width; switch (info->status) { case DIFF_STATUS_ADDED: class = "add"; break; case DIFF_STATUS_COPIED: class = "cpy"; break; case DIFF_STATUS_DELETED: class = "del"; break; case DIFF_STATUS_MODIFIED: class = "upd"; break; case DIFF_STATUS_RENAMED: class = "mov"; break; case DIFF_STATUS_TYPE_CHANGED: class = "typ"; break; case DIFF_STATUS_UNKNOWN: class = "unk"; break; case DIFF_STATUS_UNMERGED: @@ -75,60 +74,57 @@ void print_fileinfo(struct fileinfo *info) html_filemode(info->old_mode); html("]</span>"); } htmlf("</td><td class='%s'>", class); query = fmt("id=%s&id2=%s&path=%s", sha1_to_hex(info->old_sha1), sha1_to_hex(info->new_sha1), info->new_path); html_link_open(cgit_pageurl(cgit_query_repo, "diff", query), NULL, NULL); if (info->status == DIFF_STATUS_COPIED || info->status == DIFF_STATUS_RENAMED) { html_txt(info->new_path); htmlf("</a> (%s from ", info->status == DIFF_STATUS_COPIED ? "copied" : "renamed"); query2 = fmt("id=%s", sha1_to_hex(info->old_sha1)); html_link_open(cgit_pageurl(cgit_query_repo, "view", query2), NULL, NULL); html_txt(info->old_path); html("</a>)"); } else { html_txt(info->new_path); html("</a>"); } html("</td><td class='right'>"); htmlf("%d", info->added + info->removed); - html("</td><td class='graph'>"); - width = (info->added + info->removed) * 100.0 / max_changes; - if (width < 0.1) - width = 0.1; - html_link_open(cgit_pageurl(cgit_query_repo, "diff", query), - NULL, NULL); - htmlf("<img src='/cgit/add.png' style='width: %.1f%%;'/>", - info->added * width / (info->added + info->removed)); - htmlf("<img src='/cgit/del.png' style='width: %.1f%%;'/>", - info->removed * width / (info->added + info->removed)); - html("</a></td></tr>\n"); + htmlf("<table width='%d%%'><tr>", (max_changes > 100 ? 100 : max_changes)); + htmlf("<td class='add' style='width: %.1f%%;'/>", + info->added * 100.0 / max_changes); + htmlf("<td class='rem' style='width: %.1f%%;'/>", + info->removed * 100.0 / max_changes); + htmlf("<td class='none' style='width: %.1f%%;'/>", + (max_changes - info->removed - info->added) * 100.0 / max_changes); + html("</tr></table></a></td></tr>\n"); } void cgit_count_diff_lines(char *line, int len) { if (line && (len > 0)) { if (line[0] == '+') lines_added++; else if (line[0] == '-') lines_removed++; } } void inspect_filepair(struct diff_filepair *pair) { files++; lines_added = 0; lines_removed = 0; cgit_diff_files(pair->one->sha1, pair->two->sha1, cgit_count_diff_lines); if (files >= slots) { if (slots == 0) slots = 4; else slots = slots * 2; items = xrealloc(items, slots * sizeof(struct fileinfo)); |