author | Lars Hjemli <hjemli@gmail.com> | 2009-07-25 09:40:25 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2009-07-25 09:41:06 (UTC) |
commit | fbe091a716447be496519ce439451d36d5b9fc24 (patch) (side-by-side diff) | |
tree | c6560c6f2ab6b4760ac6eaecda1759321da2746e /ui-shared.c | |
parent | e429fb0cca1e8c78da0ec38fe578bafdeec65534 (diff) | |
parent | 694dd43886f23723f415aed3afb62131cdbcaa51 (diff) | |
download | cgit-fbe091a716447be496519ce439451d36d5b9fc24.zip cgit-fbe091a716447be496519ce439451d36d5b9fc24.tar.gz cgit-fbe091a716447be496519ce439451d36d5b9fc24.tar.bz2 |
Merge branch 'do/https'
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-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) return fmt("%s, %02d %s %04d %02d:%02d:%02d GMT", day[tm->tm_wday], tm->tm_mday, month[tm->tm_mon], 1900+tm->tm_year, tm->tm_hour, tm->tm_min, tm->tm_sec); } void cgit_print_error(char *msg) { html("<div class='error'>"); html_txt(msg); html("</div>\n"); } +char *cgit_httpscheme() +{ + char *https; + + https = getenv("HTTPS"); + if (https != NULL && strcmp(https, "on") == 0) + return "https://"; + else + return "http://"; +} + char *cgit_hosturl() { char *host, *port; host = getenv("HTTP_HOST"); if (host) { host = xstrdup(host); } else { host = getenv("SERVER_NAME"); if (!host) return NULL; port = getenv("SERVER_PORT"); @@ -485,25 +496,26 @@ void cgit_print_docstart(struct cgit_context *ctx) 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); html("<link rel='stylesheet' type='text/css' href='"); html_attr(ctx->cfg.css); html("'/>\n"); if (ctx->cfg.favicon) { html("<link rel='shortcut icon' href='"); html_attr(ctx->cfg.favicon); html("'/>\n"); } if (host && ctx->repo) { - html("<link rel='alternate' title='Atom feed' href='http://"); + html("<link rel='alternate' title='Atom feed' href='"); + html(cgit_httpscheme()); html_attr(cgit_hosturl()); html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.path, fmt("h=%s", ctx->qry.head))); html("' type='application/atom+xml'/>"); } html("</head>\n"); html("<body>\n"); if (ctx->cfg.header) html_include(ctx->cfg.header); } void cgit_print_docend() |