all repos — cgit @ 1649afdc9b2febe9ab7e1abe1956c5dcaff93aa1

a hyperfast web frontend for git written in c

ui-tree: link to blame UI if enabled

Create links to the blame page.

Signed-off-by: Jeff Smith <whydoubt@gmail.com>
Reviewed-by: John Keeping <john@keeping.me.uk>
Jeff Smith whydoubt@gmail.com
Sun, 01 Oct 2017 23:39:09 -0500
commit

1649afdc9b2febe9ab7e1abe1956c5dcaff93aa1

parent

c1cd290d1f83d3d1c2d081d734e8d213f12cc06b

3 files changed, 29 insertions(+), 4 deletions(-)

jump to
M ui-shared.cui-shared.c

@@ -1,6 +1,6 @@

/* ui-shared.c: common web output functions * - * Copyright (C) 2006-2014 cgit Development Team <cgit@lists.zx2c4.com> + * Copyright (C) 2006-2017 cgit Development Team <cgit@lists.zx2c4.com> * * Licensed under GNU General Public License v2 * (see COPYING for full license text)

@@ -304,6 +304,12 @@ {

reporevlink("plain", name, title, class, head, rev, path); } +void cgit_blame_link(const char *name, const char *title, const char *class, + const char *head, const char *rev, const char *path) +{ + reporevlink("blame", name, title, class, head, rev, path); +} + void cgit_log_link(const char *name, const char *title, const char *class, const char *head, const char *rev, const char *path, int ofs, const char *grep, const char *pattern, int showmsg,

@@ -476,6 +482,10 @@ ctx.qry.has_sha1 ? ctx.qry.sha1 : NULL,

ctx.qry.path); else if (!strcmp(ctx.qry.page, "plain")) cgit_plain_link(name, title, class, ctx.qry.head, + ctx.qry.has_sha1 ? ctx.qry.sha1 : NULL, + ctx.qry.path); + else if (!strcmp(ctx.qry.page, "blame")) + cgit_blame_link(name, title, class, ctx.qry.head, ctx.qry.has_sha1 ? ctx.qry.sha1 : NULL, ctx.qry.path); else if (!strcmp(ctx.qry.page, "log"))

@@ -983,8 +993,12 @@ ctx.qry.sha1, NULL);

cgit_log_link("log", NULL, hc("log"), ctx.qry.head, NULL, ctx.qry.vpath, 0, NULL, NULL, ctx.qry.showmsg, ctx.qry.follow); - cgit_tree_link("tree", NULL, hc("tree"), ctx.qry.head, - ctx.qry.sha1, ctx.qry.vpath); + if (ctx.qry.page && !strcmp(ctx.qry.page, "blame")) + cgit_blame_link("blame", NULL, hc("blame"), ctx.qry.head, + ctx.qry.sha1, ctx.qry.vpath); + else + cgit_tree_link("tree", NULL, hc("tree"), ctx.qry.head, + ctx.qry.sha1, ctx.qry.vpath); cgit_commit_link("commit", NULL, hc("commit"), ctx.qry.head, ctx.qry.sha1, ctx.qry.vpath); cgit_diff_link("diff", NULL, hc("diff"), ctx.qry.head,
M ui-shared.hui-shared.h

@@ -26,6 +26,9 @@ const char *rev, const char *path);

extern void cgit_plain_link(const char *name, const char *title, const char *class, const char *head, const char *rev, const char *path); +extern void cgit_blame_link(const char *name, const char *title, + const char *class, const char *head, + const char *rev, const char *path); extern void cgit_log_link(const char *name, const char *title, const char *class, const char *head, const char *rev, const char *path, int ofs, const char *grep,
M ui-tree.cui-tree.c

@@ -1,6 +1,6 @@

/* ui-tree.c: functions for tree output * - * Copyright (C) 2006-2014 cgit Development Team <cgit@lists.zx2c4.com> + * Copyright (C) 2006-2017 cgit Development Team <cgit@lists.zx2c4.com> * * Licensed under GNU General Public License v2 * (see COPYING for full license text)

@@ -110,6 +110,11 @@ cgit_print_layout_start();

htmlf("blob: %s (", sha1_to_hex(sha1)); cgit_plain_link("plain", NULL, NULL, ctx.qry.head, rev, path); + if (ctx.cfg.enable_blame) { + html(") ("); + cgit_blame_link("blame", NULL, NULL, ctx.qry.head, + rev, path); + } html(")\n"); if (ctx.cfg.max_blob_size && size / 1024 > ctx.cfg.max_blob_size) {

@@ -243,6 +248,9 @@ cgit_stats_link("stats", NULL, "button", ctx.qry.head,

fullpath.buf); if (!S_ISGITLINK(mode)) cgit_plain_link("plain", NULL, "button", ctx.qry.head, + walk_tree_ctx->curr_rev, fullpath.buf); + if (!S_ISDIR(mode) && ctx.cfg.enable_blame) + cgit_blame_link("blame", NULL, "button", ctx.qry.head, walk_tree_ctx->curr_rev, fullpath.buf); html("</td></tr>\n"); free(name);