-rw-r--r-- | ui-shared.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/ui-shared.c b/ui-shared.c index 2630f23..29036d0 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -25,24 +25,35 @@ static char *http_date(time_t t) | |||
25 | return fmt("%s, %02d %s %04d %02d:%02d:%02d GMT", day[tm->tm_wday], | 25 | return fmt("%s, %02d %s %04d %02d:%02d:%02d GMT", day[tm->tm_wday], |
26 | tm->tm_mday, month[tm->tm_mon], 1900+tm->tm_year, | 26 | tm->tm_mday, month[tm->tm_mon], 1900+tm->tm_year, |
27 | tm->tm_hour, tm->tm_min, tm->tm_sec); | 27 | tm->tm_hour, tm->tm_min, tm->tm_sec); |
28 | } | 28 | } |
29 | 29 | ||
30 | void cgit_print_error(char *msg) | 30 | void cgit_print_error(char *msg) |
31 | { | 31 | { |
32 | html("<div class='error'>"); | 32 | html("<div class='error'>"); |
33 | html_txt(msg); | 33 | html_txt(msg); |
34 | html("</div>\n"); | 34 | html("</div>\n"); |
35 | } | 35 | } |
36 | 36 | ||
37 | char *cgit_httpscheme() | ||
38 | { | ||
39 | char *https; | ||
40 | |||
41 | https = getenv("HTTPS"); | ||
42 | if (https != NULL && strcmp(https, "on") == 0) | ||
43 | return "https://"; | ||
44 | else | ||
45 | return "http://"; | ||
46 | } | ||
47 | |||
37 | char *cgit_hosturl() | 48 | char *cgit_hosturl() |
38 | { | 49 | { |
39 | char *host, *port; | 50 | char *host, *port; |
40 | 51 | ||
41 | host = getenv("HTTP_HOST"); | 52 | host = getenv("HTTP_HOST"); |
42 | if (host) { | 53 | if (host) { |
43 | host = xstrdup(host); | 54 | host = xstrdup(host); |
44 | } else { | 55 | } else { |
45 | host = getenv("SERVER_NAME"); | 56 | host = getenv("SERVER_NAME"); |
46 | if (!host) | 57 | if (!host) |
47 | return NULL; | 58 | return NULL; |
48 | port = getenv("SERVER_PORT"); | 59 | port = getenv("SERVER_PORT"); |
@@ -485,25 +496,26 @@ void cgit_print_docstart(struct cgit_context *ctx) | |||
485 | htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); | 496 | htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); |
486 | if (ctx->cfg.robots && *ctx->cfg.robots) | 497 | if (ctx->cfg.robots && *ctx->cfg.robots) |
487 | htmlf("<meta name='robots' content='%s'/>\n", ctx->cfg.robots); | 498 | htmlf("<meta name='robots' content='%s'/>\n", ctx->cfg.robots); |
488 | html("<link rel='stylesheet' type='text/css' href='"); | 499 | html("<link rel='stylesheet' type='text/css' href='"); |
489 | html_attr(ctx->cfg.css); | 500 | html_attr(ctx->cfg.css); |
490 | html("'/>\n"); | 501 | html("'/>\n"); |
491 | if (ctx->cfg.favicon) { | 502 | if (ctx->cfg.favicon) { |
492 | html("<link rel='shortcut icon' href='"); | 503 | html("<link rel='shortcut icon' href='"); |
493 | html_attr(ctx->cfg.favicon); | 504 | html_attr(ctx->cfg.favicon); |
494 | html("'/>\n"); | 505 | html("'/>\n"); |
495 | } | 506 | } |
496 | if (host && ctx->repo) { | 507 | if (host && ctx->repo) { |
497 | html("<link rel='alternate' title='Atom feed' href='http://"); | 508 | html("<link rel='alternate' title='Atom feed' href='"); |
509 | html(cgit_httpscheme()); | ||
498 | html_attr(cgit_hosturl()); | 510 | html_attr(cgit_hosturl()); |
499 | html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.path, | 511 | html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.path, |
500 | fmt("h=%s", ctx->qry.head))); | 512 | fmt("h=%s", ctx->qry.head))); |
501 | html("' type='application/atom+xml'/>"); | 513 | html("' type='application/atom+xml'/>"); |
502 | } | 514 | } |
503 | html("</head>\n"); | 515 | html("</head>\n"); |
504 | html("<body>\n"); | 516 | html("<body>\n"); |
505 | if (ctx->cfg.header) | 517 | if (ctx->cfg.header) |
506 | html_include(ctx->cfg.header); | 518 | html_include(ctx->cfg.header); |
507 | } | 519 | } |
508 | 520 | ||
509 | void cgit_print_docend() | 521 | void cgit_print_docend() |