-rw-r--r-- | ui-shared.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/ui-shared.c b/ui-shared.c index 197ee37..37c60b2 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -31,12 +31,27 @@ 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_hosturl() | ||
38 | { | ||
39 | char *host, *port; | ||
40 | |||
41 | host = getenv("SERVER_NAME"); | ||
42 | if (!host) | ||
43 | return NULL; | ||
44 | port = getenv("SERVER_PORT"); | ||
45 | if (port && atoi(port) != 80) | ||
46 | host = xstrdup(fmt("%s:%d", host, atoi(port))); | ||
47 | else | ||
48 | host = xstrdup(host); | ||
49 | return host; | ||
50 | } | ||
51 | |||
37 | char *cgit_rooturl() | 52 | char *cgit_rooturl() |
38 | { | 53 | { |
39 | if (ctx.cfg.virtual_root) | 54 | if (ctx.cfg.virtual_root) |
40 | return fmt("%s/", ctx.cfg.virtual_root); | 55 | return fmt("%s/", ctx.cfg.virtual_root); |
41 | else | 56 | else |
42 | return ctx.cfg.script_name; | 57 | return ctx.cfg.script_name; |
@@ -425,12 +440,13 @@ void cgit_print_http_headers(struct cgit_context *ctx) | |||
425 | htmlf("Expires: %s\n", http_date(ctx->page.expires)); | 440 | htmlf("Expires: %s\n", http_date(ctx->page.expires)); |
426 | html("\n"); | 441 | html("\n"); |
427 | } | 442 | } |
428 | 443 | ||
429 | void cgit_print_docstart(struct cgit_context *ctx) | 444 | void cgit_print_docstart(struct cgit_context *ctx) |
430 | { | 445 | { |
446 | char *host = cgit_hosturl(); | ||
431 | html(cgit_doctype); | 447 | html(cgit_doctype); |
432 | html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"); | 448 | html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"); |
433 | html("<head>\n"); | 449 | html("<head>\n"); |
434 | html("<title>"); | 450 | html("<title>"); |
435 | html_txt(ctx->page.title); | 451 | html_txt(ctx->page.title); |
436 | html("</title>\n"); | 452 | html("</title>\n"); |
@@ -442,12 +458,19 @@ void cgit_print_docstart(struct cgit_context *ctx) | |||
442 | html("'/>\n"); | 458 | html("'/>\n"); |
443 | if (ctx->cfg.favicon) { | 459 | if (ctx->cfg.favicon) { |
444 | html("<link rel='shortcut icon' href='"); | 460 | html("<link rel='shortcut icon' href='"); |
445 | html_attr(ctx->cfg.favicon); | 461 | html_attr(ctx->cfg.favicon); |
446 | html("'/>\n"); | 462 | html("'/>\n"); |
447 | } | 463 | } |
464 | if (host && ctx->repo) { | ||
465 | html("<link rel='alternate' title='Atom feed' href='http://"); | ||
466 | html_attr(cgit_hosturl()); | ||
467 | html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.path, | ||
468 | fmt("h=%s", ctx->qry.head))); | ||
469 | html("' type='application/atom+xml'/>"); | ||
470 | } | ||
448 | html("</head>\n"); | 471 | html("</head>\n"); |
449 | html("<body>\n"); | 472 | html("<body>\n"); |
450 | } | 473 | } |
451 | 474 | ||
452 | void cgit_print_docend() | 475 | void cgit_print_docend() |
453 | { | 476 | { |