From: john at keeping.me.uk (John Keeping)
Subject: [PATCH] noheader: place branch combo on tabs if no header
Date: Sat, 23 Jun 2018 11:50:10 +0100 [thread overview]
Message-ID: <20180623105010.GE6584@john.keeping.me.uk> (raw)
In-Reply-To: <152950062069.30029.12723213146610945242.stgit@mail.warmcat.com>
On Wed, Jun 20, 2018 at 09:17:00PM +0800, Andy Green wrote:
> 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 at warmcat.com>
This makes noheader=1 a lot more usable!
I wonder if the branch combo should be somewhere to the right of the
main tabs, but I don't feel strongly either way.
Reviewed-by: John Keeping <john at keeping.me.uk>
> ---
> ui-shared.c | 34 ++++++++++++++++++++++++----------
> 1 file changed, 24 insertions(+), 10 deletions(-)
>
> diff --git a/ui-shared.c b/ui-shared.c
> index c9a34fb..082a6f1 100644
> --- a/ui-shared.c
> +++ b/ui-shared.c
> @@ -958,6 +958,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;
> @@ -991,15 +1004,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);
> @@ -1023,8 +1028,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,
> @@ -1081,6 +1093,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"),
next prev parent reply other threads:[~2018-06-23 10:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-20 9:04 repo.desc as raw html? andy
2018-06-20 13:17 ` [PATCH] noheader: place branch combo on tabs if no header andy
2018-06-23 10:50 ` john [this message]
2018-06-21 6:46 ` [PATCH 1/2] config: add root-desc-html and repo.desc-html andy
2018-06-21 6:46 ` [PATCH 2/2] ui-shared: emit root-desc-html and repo.desc-html after their text counterparts andy
2018-06-23 10:28 ` john
2018-06-23 10:33 ` andy
2018-06-23 10:53 ` john
2018-06-23 11:08 ` andy
2018-06-23 16:33 ` john
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180623105010.GE6584@john.keeping.me.uk \
--to=cgit@lists.zx2c4.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).