-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 @@ -36,2 +36,17 @@ void cgit_print_error(char *msg) +char *cgit_hosturl() +{ + char *host, *port; + + host = getenv("SERVER_NAME"); + if (!host) + return NULL; + port = getenv("SERVER_PORT"); + if (port && atoi(port) != 80) + host = xstrdup(fmt("%s:%d", host, atoi(port))); + else + host = xstrdup(host); + return host; +} + char *cgit_rooturl() @@ -430,2 +445,3 @@ void cgit_print_docstart(struct cgit_context *ctx) { + char *host = cgit_hosturl(); html(cgit_doctype); @@ -447,2 +463,9 @@ void cgit_print_docstart(struct cgit_context *ctx) } + if (host && ctx->repo) { + html("<link rel='alternate' title='Atom feed' href='http://"); + 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"); |