Diffstat (limited to 'ui-shared.c')
| -rw-r--r-- | ui-shared.c | 98 |
1 files changed, 5 insertions, 93 deletions
diff --git a/ui-shared.c b/ui-shared.c index 9eb48a9..97d1839 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -7,8 +7,6 @@ * Implement ci link tab * Check repo existence * Replace memrchr() for macOS compatibility - * Allow multiple favicons of different mime types to be used - * Include favicon.svg as default * * Licensed under GNU General Public License v2 * (see COPYING for full license text) @@ -494,21 +492,6 @@ void cgit_diff_link(const char *name, const char *title, const char *class, html_url_arg(old_rev); delim = "&"; } - /* - * Emit the ref offsets after the refs so that they follow the - * refs through file-level links; a zero offset means the ref - * itself. - */ - if (ctx.qry.idoff) { - html(delim); - htmlf("idoff=%d", ctx.qry.idoff); - delim = "&"; - } - if (ctx.qry.id2off) { - html(delim); - htmlf("id2off=%d", ctx.qry.id2off); - delim = "&"; - } if (ctx.qry.difftype) { html(delim); htmlf("dt=%d", ctx.qry.difftype); @@ -791,51 +774,6 @@ void cgit_redirect(const char *url, bool permanent) html("\n\n"); } -static const struct { - const char *ext; - const char *mimetype; -} favicon_mimetypes[] = { - { "ico", "image/x-icon" }, - { "png", "image/png" }, - { "svg", "image/svg+xml" }, - { "gif", "image/gif" }, - { "jpg", "image/jpeg" }, - { "jpeg", "image/jpeg" }, - { "webp", "image/webp" }, - { "avif", "image/avif" }, -}; - -/* Deduce the mimetype of a favicon from the extension of its url, ignoring - * any query string or fragment. Returns NULL for unknown extensions. - */ -static const char *favicon_mimetype(const char *url) -{ - const char *p, *end, *ext = NULL; - size_t len; - int i; - - end = strpbrk(url, "?#"); - if (!end) - end = url + strlen(url); - - for (p = url; p < end; p++) { - if (*p == '/') - ext = NULL; - else if (*p == '.') - ext = p + 1; - } - if (!ext) - return NULL; - len = end - ext; - - for (i = 0; i < ARRAY_SIZE(favicon_mimetypes); i++) { - if (strlen(favicon_mimetypes[i].ext) == len && - !strncasecmp(favicon_mimetypes[i].ext, ext, len)) - return favicon_mimetypes[i].mimetype; - } - return NULL; -} - static void print_rel_vcs_link(const char *url) { html("<link rel='vcs-git' href='"); @@ -877,27 +815,6 @@ static int emit_js_link(struct string_list_item *s, void *arg) return 0; } -static int emit_favicon_link(struct string_list_item *s, void *arg) -{ - const char *url = s ? s->string : (const char *)arg; - const char *mimetype; - - /* Do not emit anything if favicon= is specified. */ - if (!*url) - return 0; - - html("<link rel='shortcut icon' href='"); - html_attr(url); - mimetype = favicon_mimetype(url); - if (mimetype) { - html("' type='"); - html_attr(mimetype); - } - html("'/>\n"); - - return 0; -} - void cgit_print_docstart(void) { char *host = cgit_hosturl(); @@ -928,12 +845,11 @@ void cgit_print_docstart(void) else emit_js_link(NULL, "/cgit.js"); - if (ctx.cfg.favicon.items) - for_each_string_list(&ctx.cfg.favicon, emit_favicon_link, NULL); - else - emit_favicon_link(NULL, "/favicon.svg"); - emit_favicon_link(NULL, "/favicon.ico"); - + if (ctx.cfg.favicon && *ctx.cfg.favicon) { + html("<link rel='shortcut icon' href='"); + html_attr(ctx.cfg.favicon); + html("'/>\n"); + } if (host && ctx.repo && ctx.qry.head) { char *fileurl; struct strbuf sb = STRBUF_INIT; @@ -1066,10 +982,6 @@ void cgit_add_hidden_formfields(int incl_head, int incl_search, html_hidden("id", ctx.qry.oid); if (ctx.qry.oid2) html_hidden("id2", ctx.qry.oid2); - if (ctx.qry.idoff) - html_hidden("idoff", fmt("%d", ctx.qry.idoff)); - if (ctx.qry.id2off) - html_hidden("id2off", fmt("%d", ctx.qry.id2off)); if (ctx.qry.showmsg) html_hidden("showmsg", "1"); |