Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Lead an error page's title with the error
The config error page had a title of its own, in the reverse order,
and now takes the same one as any other 404, since its message
already says the repository failed to open.
Diffstat (limited to 'source')
| -rw-r--r-- | source/cgit.c | 3 | |
| -rw-r--r-- | source/ui-shared.c | 10 |
2 files changed, 8 insertions, 5 deletions
diff --git a/source/cgit.c b/source/cgit.c index 39e8ab8..dc483ee 100644 --- a/source/cgit.c +++ b/source/cgit.c @@ -1182,8 +1182,6 @@ static int prepare_repo_cmd(int nongit, int err, int clone) strbuf_reset(&title); if (nongit) { const char *name = ctx.repo->name; - strbuf_addf(&title, "%s - %s", ctx.cfg.root_title, "config error"); - ctx.page.title = title.buf; ctx.repo = NULL; cgit_print_error_page( 404, "Not Found", "Failed to open %s: %s", name, @@ -1268,7 +1266,6 @@ static void process_request(void) // branch switcher needs the head resolved first. if (ctx.repo && prepare_repo_cmd(nongit, err, 0)) return; - ctx.page.title = "cgit error"; cgit_print_error_page(404, "Not Found", "Invalid request"); return; } diff --git a/source/ui-shared.c b/source/ui-shared.c index 0865ffa..e346cbd 100644 --- a/source/ui-shared.c +++ b/source/ui-shared.c @@ -1457,8 +1457,8 @@ static void print_docstart(void) html("<meta name='theme-color' media='(prefers-color-scheme: light)' content='#ffffff'>\n"); html("<meta name='theme-color' media='(prefers-color-scheme: dark)' content='#1b1b1b'>\n"); html("<title>"); - // An error page reached before a title was chosen still has to name - // itself, since an empty title element is not valid. + // A page that chose no title still has to name itself, since an empty + // title element is not valid. html_txt(ctx.page.title ? ctx.page.title : ctx.cfg.root_title); // The auth page goes out before the repository is opened, when // pinned_oid cannot resolve anything yet. @@ -1542,6 +1542,12 @@ void cgit_print_error_page(int code, const char *msg, const char *fmt, ...) } ctx.page.status = code; ctx.page.statusmsg = msg; + // The error stands where a page would name itself, ahead of the + // repository and the site. + if (ctx.repo) + ctx.page.title = xstrfmt("%s - %s - %s", msg, ctx.repo->name, ctx.cfg.root_title); + else + ctx.page.title = xstrfmt("%s - %s", msg, ctx.cfg.root_title); // A page that had already chosen another type, such as an image // served through the about page, still answers its error as html. ctx.page.mimetype = "text/html"; |
