diff options
context:
space:
mode:
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Give empty repositories their own page
Diffstat (limited to 'source/ui-shared.c')
-rw-r--r--source/ui-shared.c14
1 file changed, 12 insertions, 2 deletions
diff --git a/source/ui-shared.c b/source/ui-shared.c
index d023243..e53d1e5 100644
--- a/source/ui-shared.c
+++ b/source/ui-shared.c
@@ -1086,7 +1086,9 @@ static void print_header(void)
html_txt(ctx.cfg.root_title);
html("</h1>\n");
- if (ctx.repo && ctx.env.authenticated) {
+ // A repository with no commits has no branches to list, so the
+ // switcher would be an empty select next to a switch button.
+ if (ctx.repo && ctx.env.authenticated && !ctx.empty_repo) {
html("<form class='branch-switch' method='get'>\n");
cgit_add_hidden_formfields(0, 1, ctx.qry.page);
html("<select name='h' aria-label='Branch' data-autosubmit='1'>\n");
@@ -1127,7 +1129,15 @@ void cgit_print_pageheader(void)
if (ctx.env.authenticated)
html("<nav class='tabs'>\n");
- if (ctx.env.authenticated && ctx.repo) {
+ if (ctx.env.authenticated && ctx.repo && ctx.empty_repo) {
+ // Every other tab needs a commit to render, and the search form
+ // has nothing to search, so a repository with no commits gets
+ // summary alone rather than a row of links to the same notice.
+ html("<ul>\n<li>");
+ cgit_summary_link("summary", "Repository summary", hc("summary"),
+ ctx.qry.head);
+ html("</li>\n</ul>\n");
+ } else if (ctx.env.authenticated && ctx.repo) {
const char *vp = ctx.qry.vpath;
html("<ul>\n");
if (ctx.repo->readme.nr) {