summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c2
-rw-r--r--cgit.h1
-rw-r--r--ui-shared.c20
3 files changed, 16 insertions, 7 deletions
diff --git a/cgit.c b/cgit.c
index 2aef44d..38f0fdd 100644
--- a/cgit.c
+++ b/cgit.c
@@ -40,24 +40,26 @@ void config_cb(const char *name, const char *value)
40 else if (!strcmp(name, "index-info")) 40 else if (!strcmp(name, "index-info"))
41 ctx.cfg.index_info = xstrdup(value); 41 ctx.cfg.index_info = xstrdup(value);
42 else if (!strcmp(name, "logo-link")) 42 else if (!strcmp(name, "logo-link"))
43 ctx.cfg.logo_link = xstrdup(value); 43 ctx.cfg.logo_link = xstrdup(value);
44 else if (!strcmp(name, "module-link")) 44 else if (!strcmp(name, "module-link"))
45 ctx.cfg.module_link = xstrdup(value); 45 ctx.cfg.module_link = xstrdup(value);
46 else if (!strcmp(name, "virtual-root")) { 46 else if (!strcmp(name, "virtual-root")) {
47 ctx.cfg.virtual_root = trim_end(value, '/'); 47 ctx.cfg.virtual_root = trim_end(value, '/');
48 if (!ctx.cfg.virtual_root && (!strcmp(value, "/"))) 48 if (!ctx.cfg.virtual_root && (!strcmp(value, "/")))
49 ctx.cfg.virtual_root = ""; 49 ctx.cfg.virtual_root = "";
50 } else if (!strcmp(name, "nocache")) 50 } else if (!strcmp(name, "nocache"))
51 ctx.cfg.nocache = atoi(value); 51 ctx.cfg.nocache = atoi(value);
52 else if (!strcmp(name, "noheader"))
53 ctx.cfg.noheader = atoi(value);
52 else if (!strcmp(name, "snapshots")) 54 else if (!strcmp(name, "snapshots"))
53 ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); 55 ctx.cfg.snapshots = cgit_parse_snapshots_mask(value);
54 else if (!strcmp(name, "enable-index-links")) 56 else if (!strcmp(name, "enable-index-links"))
55 ctx.cfg.enable_index_links = atoi(value); 57 ctx.cfg.enable_index_links = atoi(value);
56 else if (!strcmp(name, "enable-log-filecount")) 58 else if (!strcmp(name, "enable-log-filecount"))
57 ctx.cfg.enable_log_filecount = atoi(value); 59 ctx.cfg.enable_log_filecount = atoi(value);
58 else if (!strcmp(name, "enable-log-linecount")) 60 else if (!strcmp(name, "enable-log-linecount"))
59 ctx.cfg.enable_log_linecount = atoi(value); 61 ctx.cfg.enable_log_linecount = atoi(value);
60 else if (!strcmp(name, "max-stats")) 62 else if (!strcmp(name, "max-stats"))
61 ctx.cfg.max_stats = cgit_find_stats_period(value, NULL); 63 ctx.cfg.max_stats = cgit_find_stats_period(value, NULL);
62 else if (!strcmp(name, "cache-size")) 64 else if (!strcmp(name, "cache-size"))
63 ctx.cfg.cache_size = atoi(value); 65 ctx.cfg.cache_size = atoi(value);
diff --git a/cgit.h b/cgit.h
index 73d7208..1056231 100644
--- a/cgit.h
+++ b/cgit.h
@@ -163,24 +163,25 @@ struct cgit_config {
163 int max_commit_count; 163 int max_commit_count;
164 int max_lock_attempts; 164 int max_lock_attempts;
165 int max_msg_len; 165 int max_msg_len;
166 int max_repodesc_len; 166 int max_repodesc_len;
167 int max_stats; 167 int max_stats;
168 int nocache; 168 int nocache;
169 int renamelimit; 169 int renamelimit;
170 int snapshots; 170 int snapshots;
171 int summary_branches; 171 int summary_branches;
172 int summary_log; 172 int summary_log;
173 int summary_tags; 173 int summary_tags;
174 int embedded; 174 int embedded;
175 int noheader;
175}; 176};
176 177
177struct cgit_page { 178struct cgit_page {
178 time_t modified; 179 time_t modified;
179 time_t expires; 180 time_t expires;
180 size_t size; 181 size_t size;
181 char *mimetype; 182 char *mimetype;
182 char *charset; 183 char *charset;
183 char *filename; 184 char *filename;
184 char *title; 185 char *title;
185}; 186};
186 187
diff --git a/ui-shared.c b/ui-shared.c
index f18b2c7..5e03a7a 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -602,32 +602,26 @@ void cgit_add_hidden_formfields(int incl_head, int incl_search, char *page)
602 if (ctx.qry.search) 602 if (ctx.qry.search)
603 html_hidden("q", ctx.qry.search); 603 html_hidden("q", ctx.qry.search);
604 } 604 }
605} 605}
606 606
607const char *fallback_cmd = "repolist"; 607const char *fallback_cmd = "repolist";
608 608
609char *hc(struct cgit_cmd *cmd, const char *page) 609char *hc(struct cgit_cmd *cmd, const char *page)
610{ 610{
611 return (strcmp(cmd ? cmd->name : fallback_cmd, page) ? NULL : "active"); 611 return (strcmp(cmd ? cmd->name : fallback_cmd, page) ? NULL : "active");
612} 612}
613 613
614void cgit_print_pageheader(struct cgit_context *ctx) 614static void print_header(struct cgit_context *ctx)
615{ 615{
616 struct cgit_cmd *cmd = cgit_get_cmd(ctx);
617
618 if (!cmd && ctx->repo)
619 fallback_cmd = "summary";
620
621 html("<div id='cgit'>");
622 html("<table id='header'>\n"); 616 html("<table id='header'>\n");
623 html("<tr>\n"); 617 html("<tr>\n");
624 html("<td class='logo' rowspan='2'><a href='"); 618 html("<td class='logo' rowspan='2'><a href='");
625 if (ctx->cfg.logo_link) 619 if (ctx->cfg.logo_link)
626 html_attr(ctx->cfg.logo_link); 620 html_attr(ctx->cfg.logo_link);
627 else 621 else
628 html_attr(cgit_rooturl()); 622 html_attr(cgit_rooturl());
629 html("'><img src='"); 623 html("'><img src='");
630 html_attr(ctx->cfg.logo); 624 html_attr(ctx->cfg.logo);
631 html("' alt='cgit logo'/></a></td>\n"); 625 html("' alt='cgit logo'/></a></td>\n");
632 626
633 html("<td class='main'>"); 627 html("<td class='main'>");
@@ -650,24 +644,36 @@ void cgit_print_pageheader(struct cgit_context *ctx)
650 html("<tr><td class='sub'>"); 644 html("<tr><td class='sub'>");
651 if (ctx->repo) { 645 if (ctx->repo) {
652 html_txt(ctx->repo->desc); 646 html_txt(ctx->repo->desc);
653 html("</td><td class='sub right'>"); 647 html("</td><td class='sub right'>");
654 html_txt(ctx->repo->owner); 648 html_txt(ctx->repo->owner);
655 } else { 649 } else {
656 if (ctx->cfg.root_desc) 650 if (ctx->cfg.root_desc)
657 html_txt(ctx->cfg.root_desc); 651 html_txt(ctx->cfg.root_desc);
658 else if (ctx->cfg.index_info) 652 else if (ctx->cfg.index_info)
659 html_include(ctx->cfg.index_info); 653 html_include(ctx->cfg.index_info);
660 } 654 }
661 html("</td></tr></table>\n"); 655 html("</td></tr></table>\n");
656}
657
658void cgit_print_pageheader(struct cgit_context *ctx)
659{
660 struct cgit_cmd *cmd = cgit_get_cmd(ctx);
661
662 if (!cmd && ctx->repo)
663 fallback_cmd = "summary";
664
665 html("<div id='cgit'>");
666 if (!ctx->cfg.noheader)
667 print_header(ctx);
662 668
663 html("<table class='tabs'><tr><td>\n"); 669 html("<table class='tabs'><tr><td>\n");
664 if (ctx->repo) { 670 if (ctx->repo) {
665 cgit_summary_link("summary", NULL, hc(cmd, "summary"), 671 cgit_summary_link("summary", NULL, hc(cmd, "summary"),
666 ctx->qry.head); 672 ctx->qry.head);
667 cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head, 673 cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head,
668 ctx->qry.sha1, NULL); 674 ctx->qry.sha1, NULL);
669 cgit_log_link("log", NULL, hc(cmd, "log"), ctx->qry.head, 675 cgit_log_link("log", NULL, hc(cmd, "log"), ctx->qry.head,
670 NULL, NULL, 0, NULL, NULL, ctx->qry.showmsg); 676 NULL, NULL, 0, NULL, NULL, ctx->qry.showmsg);
671 cgit_tree_link("tree", NULL, hc(cmd, "tree"), ctx->qry.head, 677 cgit_tree_link("tree", NULL, hc(cmd, "tree"), ctx->qry.head,
672 ctx->qry.sha1, NULL); 678 ctx->qry.sha1, NULL);
673 cgit_commit_link("commit", NULL, hc(cmd, "commit"), 679 cgit_commit_link("commit", NULL, hc(cmd, "commit"),