aboutsummaryrefslogtreecommitdiffstats
path: root/ui-shared.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui-shared.c')
-rw-r--r--ui-shared.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/ui-shared.c b/ui-shared.c
index a2e0dd2..4818e70 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -34,6 +34,21 @@ void cgit_print_error(char *msg)
34 html("</div>\n"); 34 html("</div>\n");
35} 35}
36 36
37char *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
37char *cgit_rooturl() 52char *cgit_rooturl()
38{ 53{
39 if (ctx.cfg.virtual_root) 54 if (ctx.cfg.virtual_root)
@@ -436,6 +451,7 @@ void cgit_print_http_headers(struct cgit_context *ctx)
436 451
437void cgit_print_docstart(struct cgit_context *ctx) 452void cgit_print_docstart(struct cgit_context *ctx)
438{ 453{
454 char *host = cgit_hosturl();
439 html(cgit_doctype); 455 html(cgit_doctype);
440 html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n"); 456 html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n");
441 html("<head>\n"); 457 html("<head>\n");
@@ -453,6 +469,13 @@ void cgit_print_docstart(struct cgit_context *ctx)
453 html_attr(ctx->cfg.favicon); 469 html_attr(ctx->cfg.favicon);
454 html("'/>\n"); 470 html("'/>\n");
455 } 471 }
472 if (host && ctx->repo) {
473 html("<link rel='alternate' title='Atom feed' href='http://");
474 html_attr(cgit_hosturl());
475 html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.path,
476 fmt("h=%s", ctx->qry.head)));
477 html("' type='application/atom+xml'/>");
478 }
456 html("</head>\n"); 479 html("</head>\n");
457 html("<body>\n"); 480 html("<body>\n");
458} 481}