diff options
context:
space:
mode:
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Modernize the document head
-rw-r--r--source/ui-shared.c33
1 file changed, 19 insertions, 14 deletions
diff --git a/source/ui-shared.c b/source/ui-shared.c
index 49c9ef0..b776a60 100644
--- a/source/ui-shared.c
+++ b/source/ui-shared.c
@@ -326,7 +326,7 @@ static void print_rel_vcs_link(const char *url)
html_attr(url);
html("' title='");
html_attr(ctx.repo->name);
- html(" Git repository'/>\n");
+ html(" Git repository'>\n");
}
static int emit_css_link(struct string_list_item *item, void *fallback)
@@ -335,7 +335,7 @@ static int emit_css_link(struct string_list_item *item, void *fallback)
if (item && *item->string == '\0')
return 0;
- html("<link rel='stylesheet' type='text/css' href='");
+ html("<link rel='stylesheet' href='");
if (item)
html_attr(item->string);
else
@@ -351,7 +351,7 @@ static int emit_js_link(struct string_list_item *item, void *fallback)
if (item && *item->string == '\0')
return 0;
- html("<script type='text/javascript' src='");
+ html("<script src='");
if (item)
html_attr(item->string);
else
@@ -1143,17 +1143,22 @@ void cgit_print_docstart(void)
html("<!DOCTYPE html>\n");
html("<html lang='en' class='cgit-standalone'>\n");
html("<head>\n");
- html("<meta charset='utf-8'/>\n");
- html("<meta name='viewport' content='width=device-width, initial-scale=1'/>\n");
- html("<meta name='color-scheme' content='light dark'/>\n");
- 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("<meta charset='utf-8'>\n");
+ html("<meta name='viewport' content='width=device-width, initial-scale=1'>\n");
+ html("<meta name='color-scheme' content='light dark'>\n");
+ 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>");
- html_txt(ctx.page.title);
+ // An error page reached before a title was chosen 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);
html("</title>\n");
- htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version);
- if (ctx.cfg.robots && *ctx.cfg.robots)
- htmlf("<meta name='robots' content='%s'/>\n", ctx.cfg.robots);
+ htmlf("<meta name='generator' content='cgit %s'>\n", cgit_version);
+ if (ctx.cfg.robots && *ctx.cfg.robots) {
+ html("<meta name='robots' content='");
+ html_attr(ctx.cfg.robots);
+ html("'>\n");
+ }
if (ctx.cfg.css.items)
for_each_string_list(&ctx.cfg.css, emit_css_link, NULL);
@@ -1168,7 +1173,7 @@ void cgit_print_docstart(void)
if (ctx.cfg.favicon && *ctx.cfg.favicon) {
html("<link rel='icon' href='");
html_attr(ctx.cfg.favicon);
- html("'/>\n");
+ html("'>\n");
}
if (host && ctx.repo && ctx.qry.head) {
char *fileurl;
@@ -1181,7 +1186,7 @@ void cgit_print_docstart(void)
fileurl = cgit_fileurl(ctx.repo->url, "atom", ctx.qry.vpath,
sb.buf);
html_attr(fileurl);
- html("' type='application/atom+xml'/>\n");
+ html("' type='application/atom+xml'>\n");
strbuf_release(&sb);
free(fileurl);
}