summaryrefslogtreecommitdiffabout
path: root/ui-shared.c
Unidiff
Diffstat (limited to 'ui-shared.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-shared.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/ui-shared.c b/ui-shared.c
index 9319881..95dfeb4 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -260,72 +260,78 @@ static void reporevlink(char *page, char *name, char *title, char *class,
260void cgit_summary_link(char *name, char *title, char *class, char *head) 260void cgit_summary_link(char *name, char *title, char *class, char *head)
261{ 261{
262 reporevlink(NULL, name, title, class, head, NULL, NULL); 262 reporevlink(NULL, name, title, class, head, NULL, NULL);
263} 263}
264 264
265void cgit_tag_link(char *name, char *title, char *class, char *head, 265void cgit_tag_link(char *name, char *title, char *class, char *head,
266 char *rev) 266 char *rev)
267{ 267{
268 reporevlink("tag", name, title, class, head, rev, NULL); 268 reporevlink("tag", name, title, class, head, rev, NULL);
269} 269}
270 270
271void cgit_tree_link(char *name, char *title, char *class, char *head, 271void cgit_tree_link(char *name, char *title, char *class, char *head,
272 char *rev, char *path) 272 char *rev, char *path)
273{ 273{
274 reporevlink("tree", name, title, class, head, rev, path); 274 reporevlink("tree", name, title, class, head, rev, path);
275} 275}
276 276
277void cgit_plain_link(char *name, char *title, char *class, char *head, 277void cgit_plain_link(char *name, char *title, char *class, char *head,
278 char *rev, char *path) 278 char *rev, char *path)
279{ 279{
280 reporevlink("plain", name, title, class, head, rev, path); 280 reporevlink("plain", name, title, class, head, rev, path);
281} 281}
282 282
283void cgit_log_link(char *name, char *title, char *class, char *head, 283void cgit_log_link(char *name, char *title, char *class, char *head,
284 char *rev, char *path, int ofs, char *grep, char *pattern) 284 char *rev, char *path, int ofs, char *grep, char *pattern,
285 int showmsg)
285{ 286{
286 char *delim; 287 char *delim;
287 288
288 delim = repolink(title, class, "log", head, path); 289 delim = repolink(title, class, "log", head, path);
289 if (rev && strcmp(rev, ctx.qry.head)) { 290 if (rev && strcmp(rev, ctx.qry.head)) {
290 html(delim); 291 html(delim);
291 html("id="); 292 html("id=");
292 html_url_arg(rev); 293 html_url_arg(rev);
293 delim = "&"; 294 delim = "&";
294 } 295 }
295 if (grep && pattern) { 296 if (grep && pattern) {
296 html(delim); 297 html(delim);
297 html("qt="); 298 html("qt=");
298 html_url_arg(grep); 299 html_url_arg(grep);
299 delim = "&"; 300 delim = "&";
300 html(delim); 301 html(delim);
301 html("q="); 302 html("q=");
302 html_url_arg(pattern); 303 html_url_arg(pattern);
303 } 304 }
304 if (ofs > 0) { 305 if (ofs > 0) {
305 html(delim); 306 html(delim);
306 html("ofs="); 307 html("ofs=");
307 htmlf("%d", ofs); 308 htmlf("%d", ofs);
309 delim = "&";
310 }
311 if (showmsg) {
312 html(delim);
313 html("showmsg=1");
308 } 314 }
309 html("'>"); 315 html("'>");
310 html_txt(name); 316 html_txt(name);
311 html("</a>"); 317 html("</a>");
312} 318}
313 319
314void cgit_commit_link(char *name, char *title, char *class, char *head, 320void cgit_commit_link(char *name, char *title, char *class, char *head,
315 char *rev) 321 char *rev)
316{ 322{
317 if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) { 323 if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) {
318 name[ctx.cfg.max_msg_len] = '\0'; 324 name[ctx.cfg.max_msg_len] = '\0';
319 name[ctx.cfg.max_msg_len - 1] = '.'; 325 name[ctx.cfg.max_msg_len - 1] = '.';
320 name[ctx.cfg.max_msg_len - 2] = '.'; 326 name[ctx.cfg.max_msg_len - 2] = '.';
321 name[ctx.cfg.max_msg_len - 3] = '.'; 327 name[ctx.cfg.max_msg_len - 3] = '.';
322 } 328 }
323 reporevlink("commit", name, title, class, head, rev, NULL); 329 reporevlink("commit", name, title, class, head, rev, NULL);
324} 330}
325 331
326void cgit_refs_link(char *name, char *title, char *class, char *head, 332void cgit_refs_link(char *name, char *title, char *class, char *head,
327 char *rev, char *path) 333 char *rev, char *path)
328{ 334{
329 reporevlink("refs", name, title, class, head, rev, path); 335 reporevlink("refs", name, title, class, head, rev, path);
330} 336}
331 337
@@ -549,48 +555,50 @@ int print_archive_ref(const char *refname, const unsigned char *sha1,
549 html_txt(strlpart(buf, 20)); 555 html_txt(strlpart(buf, 20));
550 html_link_close(); 556 html_link_close();
551 return 0; 557 return 0;
552} 558}
553 559
554void add_hidden_formfields(int incl_head, int incl_search, char *page) 560void add_hidden_formfields(int incl_head, int incl_search, char *page)
555{ 561{
556 char *url; 562 char *url;
557 563
558 if (!ctx.cfg.virtual_root) { 564 if (!ctx.cfg.virtual_root) {
559 url = fmt("%s/%s", ctx.qry.repo, page); 565 url = fmt("%s/%s", ctx.qry.repo, page);
560 if (ctx.qry.path) 566 if (ctx.qry.path)
561 url = fmt("%s/%s", url, ctx.qry.path); 567 url = fmt("%s/%s", url, ctx.qry.path);
562 html_hidden("url", url); 568 html_hidden("url", url);
563 } 569 }
564 570
565 if (incl_head && ctx.qry.head && ctx.repo->defbranch && 571 if (incl_head && ctx.qry.head && ctx.repo->defbranch &&
566 strcmp(ctx.qry.head, ctx.repo->defbranch)) 572 strcmp(ctx.qry.head, ctx.repo->defbranch))
567 html_hidden("h", ctx.qry.head); 573 html_hidden("h", ctx.qry.head);
568 574
569 if (ctx.qry.sha1) 575 if (ctx.qry.sha1)
570 html_hidden("id", ctx.qry.sha1); 576 html_hidden("id", ctx.qry.sha1);
571 if (ctx.qry.sha2) 577 if (ctx.qry.sha2)
572 html_hidden("id2", ctx.qry.sha2); 578 html_hidden("id2", ctx.qry.sha2);
579 if (ctx.qry.showmsg)
580 html_hidden("showmsg", "1");
573 581
574 if (incl_search) { 582 if (incl_search) {
575 if (ctx.qry.grep) 583 if (ctx.qry.grep)
576 html_hidden("qt", ctx.qry.grep); 584 html_hidden("qt", ctx.qry.grep);
577 if (ctx.qry.search) 585 if (ctx.qry.search)
578 html_hidden("q", ctx.qry.search); 586 html_hidden("q", ctx.qry.search);
579 } 587 }
580} 588}
581 589
582char *hc(struct cgit_cmd *cmd, const char *page) 590char *hc(struct cgit_cmd *cmd, const char *page)
583{ 591{
584 return (strcmp(cmd->name, page) ? NULL : "active"); 592 return (strcmp(cmd->name, page) ? NULL : "active");
585} 593}
586 594
587void cgit_print_pageheader(struct cgit_context *ctx) 595void cgit_print_pageheader(struct cgit_context *ctx)
588{ 596{
589 struct cgit_cmd *cmd = cgit_get_cmd(ctx); 597 struct cgit_cmd *cmd = cgit_get_cmd(ctx);
590 598
591 html("<table id='header'>\n"); 599 html("<table id='header'>\n");
592 html("<tr>\n"); 600 html("<tr>\n");
593 html("<td class='logo' rowspan='2'><a href='"); 601 html("<td class='logo' rowspan='2'><a href='");
594 if (ctx->cfg.logo_link) 602 if (ctx->cfg.logo_link)
595 html_attr(ctx->cfg.logo_link); 603 html_attr(ctx->cfg.logo_link);
596 else 604 else
@@ -615,49 +623,49 @@ void cgit_print_pageheader(struct cgit_context *ctx)
615 } else 623 } else
616 html_txt(ctx->cfg.root_title); 624 html_txt(ctx->cfg.root_title);
617 html("</td></tr>\n"); 625 html("</td></tr>\n");
618 626
619 html("<tr><td class='sub'>"); 627 html("<tr><td class='sub'>");
620 if (ctx->repo) { 628 if (ctx->repo) {
621 html_txt(ctx->repo->desc); 629 html_txt(ctx->repo->desc);
622 html("</td><td class='sub right'>"); 630 html("</td><td class='sub right'>");
623 html_txt(ctx->repo->owner); 631 html_txt(ctx->repo->owner);
624 } else { 632 } else {
625 if (ctx->cfg.root_desc) 633 if (ctx->cfg.root_desc)
626 html_txt(ctx->cfg.root_desc); 634 html_txt(ctx->cfg.root_desc);
627 else if (ctx->cfg.index_info) 635 else if (ctx->cfg.index_info)
628 html_include(ctx->cfg.index_info); 636 html_include(ctx->cfg.index_info);
629 } 637 }
630 html("</td></tr></table>\n"); 638 html("</td></tr></table>\n");
631 639
632 html("<table class='tabs'><tr><td>\n"); 640 html("<table class='tabs'><tr><td>\n");
633 if (ctx->repo) { 641 if (ctx->repo) {
634 cgit_summary_link("summary", NULL, hc(cmd, "summary"), 642 cgit_summary_link("summary", NULL, hc(cmd, "summary"),
635 ctx->qry.head); 643 ctx->qry.head);
636 cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head, 644 cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head,
637 ctx->qry.sha1, NULL); 645 ctx->qry.sha1, NULL);
638 cgit_log_link("log", NULL, hc(cmd, "log"), ctx->qry.head, 646 cgit_log_link("log", NULL, hc(cmd, "log"), ctx->qry.head,
639 NULL, NULL, 0, NULL, NULL); 647 NULL, NULL, 0, NULL, NULL, ctx->qry.showmsg);
640 cgit_tree_link("tree", NULL, hc(cmd, "tree"), ctx->qry.head, 648 cgit_tree_link("tree", NULL, hc(cmd, "tree"), ctx->qry.head,
641 ctx->qry.sha1, NULL); 649 ctx->qry.sha1, NULL);
642 cgit_commit_link("commit", NULL, hc(cmd, "commit"), 650 cgit_commit_link("commit", NULL, hc(cmd, "commit"),
643 ctx->qry.head, ctx->qry.sha1); 651 ctx->qry.head, ctx->qry.sha1);
644 cgit_diff_link("diff", NULL, hc(cmd, "diff"), ctx->qry.head, 652 cgit_diff_link("diff", NULL, hc(cmd, "diff"), ctx->qry.head,
645 ctx->qry.sha1, ctx->qry.sha2, NULL); 653 ctx->qry.sha1, ctx->qry.sha2, NULL);
646 if (ctx->repo->readme) 654 if (ctx->repo->readme)
647 reporevlink("about", "about", NULL, 655 reporevlink("about", "about", NULL,
648 hc(cmd, "about"), ctx->qry.head, NULL, 656 hc(cmd, "about"), ctx->qry.head, NULL,
649 NULL); 657 NULL);
650 html("</td><td class='form'>"); 658 html("</td><td class='form'>");
651 html("<form class='right' method='get' action='"); 659 html("<form class='right' method='get' action='");
652 if (ctx->cfg.virtual_root) 660 if (ctx->cfg.virtual_root)
653 html_url_path(cgit_fileurl(ctx->qry.repo, "log", 661 html_url_path(cgit_fileurl(ctx->qry.repo, "log",
654 ctx->qry.path, NULL)); 662 ctx->qry.path, NULL));
655 html("'>\n"); 663 html("'>\n");
656 add_hidden_formfields(1, 0, "log"); 664 add_hidden_formfields(1, 0, "log");
657 html("<select name='qt'>\n"); 665 html("<select name='qt'>\n");
658 html_option("grep", "log msg", ctx->qry.grep); 666 html_option("grep", "log msg", ctx->qry.grep);
659 html_option("author", "author", ctx->qry.grep); 667 html_option("author", "author", ctx->qry.grep);
660 html_option("committer", "committer", ctx->qry.grep); 668 html_option("committer", "committer", ctx->qry.grep);
661 html("</select>\n"); 669 html("</select>\n");
662 html("<input class='txt' type='text' size='10' name='q' value='"); 670 html("<input class='txt' type='text' size='10' name='q' value='");
663 html_attr(ctx->qry.search); 671 html_attr(ctx->qry.search);