List for cgit developers and users
 help / color / mirror / Atom feed
From: Jason at zx2c4.com (Jason A. Donenfeld)
Subject: [PATCH 2/2] cmd: redirect empty about/ to homepage or summary
Date: Mon, 22 Feb 2016 16:39:50 +0100	[thread overview]
Message-ID: <1456155590-9342-2-git-send-email-Jason@zx2c4.com> (raw)
In-Reply-To: <1456155590-9342-1-git-send-email-Jason@zx2c4.com>

Signed-off-by: Jason A. Donenfeld <Jason at zx2c4.com>
---
 cmd.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/cmd.c b/cmd.c
index 3093c62..0375c5a 100644
--- a/cmd.c
+++ b/cmd.c
@@ -47,8 +47,17 @@ static void about_fn(void)
 			cgit_redirect(redirect, true);
 			free(currenturl);
 			free(redirect);
-		} else
+		} else if (ctx.repo->readme.nr)
 			cgit_print_repo_readme(ctx.qry.path);
+		else if (ctx.repo->homepage)
+			cgit_redirect(ctx.repo->homepage, false);
+		else {
+			char *currenturl = cgit_currenturl();
+			char *redirect = fmtalloc("%s../", currenturl);
+			cgit_redirect(redirect, false);
+			free(currenturl);
+			free(redirect);
+		}
 	} else
 		cgit_print_site_readme();
 }
-- 
2.7.1



  reply	other threads:[~2016-02-22 15:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-22 15:39 [PATCH 1/2] ui-shared: add homepage to tabs Jason
2016-02-22 15:39 ` Jason [this message]
2016-02-22 15:42 ` Jason
2016-02-22 17:03   ` john
2016-02-22 17:12     ` Jason
2016-02-22 17:29       ` Jason
2016-02-23  6:49   ` peter
2016-02-23 14:26     ` Jason
2016-02-23 14:32       ` john
2016-02-23 14:36         ` Jason

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=1456155590-9342-2-git-send-email-Jason@zx2c4.com \
    --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).