diff --git a/cgit.mk b/cgit.mk index 822c729..9c37954 100644 --- a/cgit.mk +++ b/cgit.mk @@ -129,7 +129,7 @@ $(CGIT_PREFIX).depend: $(CGIT_PREFIX)themed/.depend: @mkdir -p $@ -$(CGIT_PREFIX)themed/themed.c: $(CGIT_PREFIX)themed/base.html $(CGIT_PREFIX)themed/index.html $(CGIT_PREFIX)themed/log.html $(CGIT_PREFIX)themed/refs.html +$(CGIT_PREFIX)themed/themed.c: $(CGIT_PREFIX)themed/base.html $(CGIT_PREFIX)themed/index.html $(CGIT_PREFIX)themed/commit.html $(CGIT_PREFIX)themed/log.html $(CGIT_PREFIX)themed/refs.html cd $(CGIT_PREFIX)themed; python -m htmlcc $^ > $@ $(CGIT_PREFIX)themed/themed.css: $(CGIT_PREFIX)themed/themed.in.css diff --git a/cmd.c b/cmd.c index 7f92197..620a389 100644 --- a/cmd.c +++ b/cmd.c @@ -79,7 +79,8 @@ static void blob_fn(void) static void commit_fn(void) { - cgit_print_commit(ctx.qry.oid, ctx.qry.path); + //cgit_print_commit(ctx.qry.oid, ctx.qry.path); + cgit_print_commit(); } static void diff_fn(void) diff --git a/themed/commit.html b/themed/commit.html new file mode 100644 index 0000000..d7fafde --- /dev/null +++ b/themed/commit.html @@ -0,0 +1,65 @@ +{! #include "../ui-diff.h" !} + +{% page cgit_print_commit %} +{! + char *hex = ctx.qry.oid; + if (!hex) { hex = ctx.qry.head; } + + struct object_id oid; + if (repo_get_oid(the_repository, hex, &oid)) { + die("Bad object id"); + } + struct commit *commit = lookup_commit_reference(the_repository, &oid); + if (!commit) { + die("Bad commit reference"); + } + struct commitinfo *info = cgit_parse_commit(commit); + + ctx.page.title = fmtalloc("%s - %s", info->subject, ctx.page.title); +!} +{! page_start(); !} +{! repo_header(); !} +
{# Main content #} +{! repo_description_panel(); !} +{! repo_summary_bar(); !} +
+ {# Commit info box #} + +
+ + {{ info->author }} + {! cgit_print_age(info->committer_date, info->committer_tz, TM_WEEK * 2); !} ago +
+ + {! char short_commit_id[8]; !} + {% for struct commit_list *p = commit->parents; p; p = p->next %} + {! struct commit *parent = lookup_commit_reference(the_repository, &p->item->object.oid); !} + {% if parent %} + {! memcpy(short_commit_id, oid_to_hex(&p->item->object.oid), 7); !} + {! short_commit_id[7] = '\0'; !} + parent item->object.oid) }}" class="font-mono text-blue-500 hover:text-blue-600 hover:underline">{{ short_commit_id }} + · + {% endif %} + {% endfor %} + {! memcpy(short_commit_id, oid_to_hex(&commit->object.oid), 7); !} + {! short_commit_id[7] = '\0'; !} + commit object.oid) }}" class="font-mono text-blue-500 hover:text-blue-600 hover:underline">{{ short_commit_id }} + +
+
+
+ {# Diff panel #} + {! cgit_print_diff(ctx.qry.oid, NULL, NULL, 0, 0); !} +
+
+{! cgit_free_commitinfo(info); !} +{! page_end(); !} +{% endpage %} diff --git a/themed/themed.in.css b/themed/themed.in.css index c1214d3..9ab4c72 100644 --- a/themed/themed.in.css +++ b/themed/themed.in.css @@ -7,3 +7,111 @@ :root { font-size: 11pt; } + +.diff-panel { + a { + @apply text-blue-500 hover:text-blue-600 hover:underline; + } + + /* From cgit.css */ + + div.diffstat-header { + font-weight: bold; + } + + table.diffstat { + border-collapse: collapse; + border: solid 1px #aaa; + background-color: #eee; + } + + table.diffstat th { + font-weight: normal; + text-align: left; + text-decoration: underline; + padding: 0.1em 1em 0.1em 0.1em; + font-size: 100%; + } + + table.diffstat td { + padding: 0.2em 0.2em 0.1em 0.1em; + font-size: 100%; + border: none; + } + + table.diffstat td.mode { + white-space: nowrap; + } + + 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: 500px; + vertical-align: middle; + } + + table.diffstat td.graph table { + border: none; + } + + 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; + } + + div.diffstat-summary { + color: #888; + padding-top: 0.5em; + } + + table.diff { + width: 100%; + } + + table.diff td { + @apply font-mono; + white-space: pre; + } + + table.diff td div.head { + font-weight: bold; + margin-top: 1em; + color: black; + } + + table.diff td div.hunk { + color: #009; + } + + table.diff td div.add { + color: green; + } + + table.diff td div.del { + color: red; + } +} diff --git a/ui-commit.c b/ui-commit.c index 972e9bc..26b8cf7 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -15,7 +15,7 @@ #include "ui-diff.h" #include "ui-log.h" -void cgit_print_commit(char *hex, const char *prefix) +void _orig_cgit_print_commit(char *hex, const char *prefix) { struct commit *commit, *parent; struct commitinfo *info, *parent_info; diff --git a/ui-commit.h b/ui-commit.h index 8198b4b..68ccf4c 100644 --- a/ui-commit.h +++ b/ui-commit.h @@ -1,6 +1,6 @@ #ifndef UI_COMMIT_H #define UI_COMMIT_H -extern void cgit_print_commit(char *hex, const char *prefix); +extern void cgit_print_commit(); #endif /* UI_COMMIT_H */