Fix colspan values

This fixes a couple of minor oversights in previous commits and adjusts
all cells using colspan to use the correct width.

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2013-03-05 15:42:14 +01:00 committed by Jason A. Donenfeld
parent 6d7e3596eb
commit ef8a97d9c6
3 changed files with 28 additions and 14 deletions

View File

@ -98,14 +98,14 @@ next:
static void print_commit(struct commit *commit, struct rev_info *revs) static void print_commit(struct commit *commit, struct rev_info *revs)
{ {
struct commitinfo *info; struct commitinfo *info;
int cols = revs->graph ? 3 : 2; int columns = revs->graph ? 4 : 3;
struct strbuf graphbuf = STRBUF_INIT; struct strbuf graphbuf = STRBUF_INIT;
struct strbuf msgbuf = STRBUF_INIT; struct strbuf msgbuf = STRBUF_INIT;
if (ctx.repo->enable_log_filecount) if (ctx.repo->enable_log_filecount)
cols++; columns++;
if (ctx.repo->enable_log_linecount) if (ctx.repo->enable_log_linecount)
cols++; columns++;
if (revs->graph) { if (revs->graph) {
/* Advance graph until current commit */ /* Advance graph until current commit */
@ -113,7 +113,7 @@ static void print_commit(struct commit *commit, struct rev_info *revs)
/* Print graph segment in otherwise empty table row */ /* Print graph segment in otherwise empty table row */
html("<tr class='nohover'><td class='commitgraph'>"); html("<tr class='nohover'><td class='commitgraph'>");
html(graphbuf.buf); html(graphbuf.buf);
htmlf("</td><td colspan='%d' /></tr>\n", cols); htmlf("</td><td colspan='%d' /></tr>\n", columns);
strbuf_setlen(&graphbuf, 0); strbuf_setlen(&graphbuf, 0);
} }
/* Current commit's graph segment is now ready in graphbuf */ /* Current commit's graph segment is now ready in graphbuf */
@ -232,7 +232,7 @@ static void print_commit(struct commit *commit, struct rev_info *revs)
html("<td/>"); /* Empty 'Age' column */ html("<td/>"); /* Empty 'Age' column */
/* Print msgbuf into remainder of table row */ /* Print msgbuf into remainder of table row */
htmlf("<td colspan='%d'%s>\n", cols, htmlf("<td colspan='%d'%s>\n", columns - (revs->graph ? 1 : 0),
ctx.qry.showmsg ? " class='logmsg'" : ""); ctx.qry.showmsg ? " class='logmsg'" : "");
html_txt(msgbuf.buf); html_txt(msgbuf.buf);
html("</td></tr>\n"); html("</td></tr>\n");
@ -283,7 +283,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern
struct rev_info rev; struct rev_info rev;
struct commit *commit; struct commit *commit;
struct vector vec = VECTOR_INIT(char *); struct vector vec = VECTOR_INIT(char *);
int i, columns = 3; int i, columns = commit_graph ? 4 : 3;
char *arg; char *arg;
/* First argv is NULL */ /* First argv is NULL */
@ -421,7 +421,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern
} }
html("</div>"); html("</div>");
} else if ((commit = get_revision(&rev)) != NULL) { } else if ((commit = get_revision(&rev)) != NULL) {
html("<tr class='nohover'><td colspan='3'>"); htmlf("<tr class='nohover'><td colspan='%d'>", columns);
cgit_log_link("[...]", NULL, NULL, ctx.qry.head, NULL, cgit_log_link("[...]", NULL, NULL, ctx.qry.head, NULL,
ctx.qry.vpath, 0, NULL, NULL, ctx.qry.showmsg); ctx.qry.vpath, 0, NULL, NULL, ctx.qry.showmsg);
html("</td></tr>\n"); html("</td></tr>\n");

View File

@ -177,7 +177,7 @@ static int print_tag(struct refinfo *ref)
static void print_refs_link(char *path) static void print_refs_link(char *path)
{ {
html("<tr class='nohover'><td colspan='4'>"); html("<tr class='nohover'><td colspan='5'>");
cgit_refs_link("[...]", NULL, NULL, ctx.qry.head, NULL, path); cgit_refs_link("[...]", NULL, NULL, ctx.qry.head, NULL, path);
html("</td></tr>"); html("</td></tr>");
} }
@ -252,7 +252,7 @@ void cgit_print_refs()
cgit_print_tags(0); cgit_print_tags(0);
else { else {
cgit_print_branches(0); cgit_print_branches(0);
html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>"); html("<tr class='nohover'><td colspan='5'>&nbsp;</td></tr>");
cgit_print_tags(0); cgit_print_tags(0);
} }
html("</table>"); html("</table>");

View File

@ -17,15 +17,22 @@ int urls = 0;
static void print_url(char *base, char *suffix) static void print_url(char *base, char *suffix)
{ {
int columns = 3;
if (ctx.repo->enable_log_filecount)
columns++;
if (ctx.repo->enable_log_linecount)
columns++;
if (!base || !*base) if (!base || !*base)
return; return;
if (urls++ == 0) { if (urls++ == 0) {
html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>"); htmlf("<tr class='nohover'><td colspan='%d'>&nbsp;</td></tr>", columns);
html("<tr><th class='left' colspan='4'>Clone</th></tr>\n"); htmlf("<tr><th class='left' colspan='%d'>Clone</th></tr>\n", columns);
} }
if (suffix && *suffix) if (suffix && *suffix)
base = fmt("%s/%s", base, suffix); base = fmt("%s/%s", base, suffix);
html("<tr><td colspan='4'><a href='"); htmlf("<tr><td colspan='%d'><a href='", columns);
html_url_path(base); html_url_path(base);
html("'>"); html("'>");
html_txt(base); html_txt(base);
@ -52,12 +59,19 @@ static void print_urls(char *txt, char *suffix)
void cgit_print_summary() void cgit_print_summary()
{ {
int columns = 3;
if (ctx.repo->enable_log_filecount)
columns++;
if (ctx.repo->enable_log_linecount)
columns++;
html("<table summary='repository info' class='list nowrap'>"); html("<table summary='repository info' class='list nowrap'>");
cgit_print_branches(ctx.cfg.summary_branches); cgit_print_branches(ctx.cfg.summary_branches);
html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>"); htmlf("<tr class='nohover'><td colspan='%d'>&nbsp;</td></tr>", columns);
cgit_print_tags(ctx.cfg.summary_tags); cgit_print_tags(ctx.cfg.summary_tags);
if (ctx.cfg.summary_log > 0) { if (ctx.cfg.summary_log > 0) {
html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>"); htmlf("<tr class='nohover'><td colspan='%d'>&nbsp;</td></tr>", columns);
cgit_print_log(ctx.qry.head, 0, ctx.cfg.summary_log, NULL, cgit_print_log(ctx.qry.head, 0, ctx.cfg.summary_log, NULL,
NULL, NULL, 0, 0, 0); NULL, NULL, 0, 0, 0);
} }