aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Green <andy@warmcat.com>2018-06-20 21:03:14 +0800
committerAndy Green <andy@warmcat.com>2018-06-29 07:53:21 +0800
commite633a42223fc4ab7d74df90e47d7c2a7e5c79377 (patch)
tree997820bfc0d74a7eed2a14a6e6a051fd4d0f7959
parentmd2html: change css name to not conflict with highlight (diff)
downloadcgit-e633a42223fc4ab7d74df90e47d7c2a7e5c79377.tar.xz
cgit-e633a42223fc4ab7d74df90e47d7c2a7e5c79377.zip
noheader: place branch combo on tabs if no header
noheader=1 stops the static page header from being emitted by cgit, but along with that, the small form that lets the user change branch context on the page is also lost. This isn't actually static since it contains a dynamic list of branches; it can't be reproduced on the user's external header static html. So it seems it doesn't belong to the set of header things that should be disabled. This patch relocates the branch selection combo and form on the left of the tabs line if noheader=1. It doesn't change anything if noheader is not set. Signed-off-by: Andy Green <andy@warmcat.com> Reviewed-by: John Keeping <john@keeping.me.uk>
-rw-r--r--ui-shared.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/ui-shared.c b/ui-shared.c
index 2327570..74ace10 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -969,6 +969,19 @@ static void cgit_print_path_crumbs(char *path)
ctx.qry.path = old_path;
}
+static void print_branch_combo_form(void)
+{
+ html("<form method='get'>\n");
+ cgit_add_hidden_formfields(0, 1, ctx.qry.page);
+ html("<select name='h' onchange='this.form.submit();'>\n");
+ for_each_branch_ref(print_branch_option, ctx.qry.head);
+ if (ctx.repo->enable_remote_branches)
+ for_each_remote_ref(print_branch_option, ctx.qry.head);
+ html("</select> ");
+ html("<input type='submit' value='switch'/>");
+ html("</form>");
+}
+
static void print_header(void)
{
char *logo = NULL, *logo_link = NULL;
@@ -1002,15 +1015,7 @@ static void print_header(void)
cgit_summary_link(ctx.repo->name, ctx.repo->name, NULL, NULL);
if (ctx.env.authenticated) {
html("</td><td class='form'>");
- html("<form method='get'>\n");
- cgit_add_hidden_formfields(0, 1, ctx.qry.page);
- html("<select name='h' onchange='this.form.submit();'>\n");
- for_each_branch_ref(print_branch_option, ctx.qry.head);
- if (ctx.repo->enable_remote_branches)
- for_each_remote_ref(print_branch_option, ctx.qry.head);
- html("</select> ");
- html("<input type='submit' value='switch'/>");
- html("</form>");
+ print_branch_combo_form();
}
} else
html_txt(ctx.cfg.root_title);
@@ -1034,8 +1039,15 @@ void cgit_print_pageheader(void)
if (!ctx.env.authenticated || !ctx.cfg.noheader)
print_header();
- html("<table class='tabs'><tr><td>\n");
+ html("<table class='tabs'><tr>\n");
if (ctx.env.authenticated && ctx.repo) {
+ if (ctx.cfg.noheader) {
+ html("<td class='form' style='text-align:left'>");
+ print_branch_combo_form();
+ html("</td><td style='text-align:center'>");
+ }
+ html("<td>");
+
if (ctx.repo->readme.nr)
reporevlink("about", "about", NULL,
hc("about"), ctx.qry.head, NULL,
@@ -1092,6 +1104,8 @@ void cgit_print_pageheader(void)
html("</form>\n");
} else if (ctx.env.authenticated) {
char *currenturl = cgit_currenturl();
+
+ html("<td>");
site_link(NULL, "index", NULL, hc("repolist"), NULL, NULL, 0, 1);
if (ctx.cfg.root_readme)
site_link("about", "about", NULL, hc("about"),