summaryrefslogtreecommitdiffabout
path: root/ui-shared.c
Unidiff
Diffstat (limited to 'ui-shared.c') (more/less context) (show whitespace changes)
-rw-r--r--ui-shared.c49
1 files changed, 21 insertions, 28 deletions
diff --git a/ui-shared.c b/ui-shared.c
index 015c52b..cf06511 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -38,6 +38,3 @@ char *cgit_httpscheme()
38{ 38{
39 char *https; 39 if (ctx.env.https && !strcmp(ctx.env.https, "on"))
40
41 https = getenv("HTTPS");
42 if (https != NULL && strcmp(https, "on") == 0)
43 return "https://"; 40 return "https://";
@@ -49,18 +46,9 @@ char *cgit_hosturl()
49{ 46{
50 char *host, *port; 47 if (ctx.env.http_host)
51 48 return ctx.env.http_host;
52 host = getenv("HTTP_HOST"); 49 if (!ctx.env.server_name)
53 if (host) {
54 host = xstrdup(host);
55 } else {
56 host = getenv("SERVER_NAME");
57 if (!host)
58 return NULL; 50 return NULL;
59 port = getenv("SERVER_PORT"); 51 if (!ctx.env.server_port || atoi(ctx.env.server_port) == 80)
60 if (port && atoi(port) != 80) 52 return ctx.env.server_name;
61 host = xstrdup(fmt("%s:%d", host, atoi(port))); 53 return xstrdup(fmt("%s:%s", ctx.env.server_name, ctx.env.server_port));
62 else
63 host = xstrdup(host);
64 }
65 return host;
66} 54}
@@ -469,5 +457,3 @@ void cgit_print_http_headers(struct cgit_context *ctx)
469{ 457{
470 const char *method = getenv("REQUEST_METHOD"); 458 if (ctx->env.no_http && !strcmp(ctx->env.no_http, "1"))
471
472 if (ctx->cfg.embedded)
473 return; 459 return;
@@ -491,3 +477,3 @@ void cgit_print_http_headers(struct cgit_context *ctx)
491 html("\n"); 477 html("\n");
492 if (method && !strcmp(method, "HEAD")) 478 if (ctx->env.request_method && !strcmp(ctx->env.request_method, "HEAD"))
493 exit(0); 479 exit(0);
@@ -497,4 +483,7 @@ void cgit_print_docstart(struct cgit_context *ctx)
497{ 483{
498 if (ctx->cfg.embedded) 484 if (ctx->cfg.embedded) {
485 if (ctx->cfg.header)
486 html_include(ctx->cfg.header);
499 return; 487 return;
488 }
500 489
@@ -536,3 +525,9 @@ void cgit_print_docend()
536{ 525{
537 html("</div>"); 526 html("</div> <!-- class=content -->\n");
527 if (ctx.cfg.embedded) {
528 html("</div> <!-- id=cgit -->\n");
529 if (ctx.cfg.footer)
530 html_include(ctx.cfg.footer);
531 return;
532 }
538 if (ctx.cfg.footer) 533 if (ctx.cfg.footer)
@@ -545,5 +540,3 @@ void cgit_print_docend()
545 } 540 }
546 html("</div>"); 541 html("</div> <!-- id=cgit -->\n");
547 if (ctx.cfg.embedded)
548 return;
549 html("</body>\n</html>\n"); 542 html("</body>\n</html>\n");