about summary refs log tree commit diff
path: root/ui-shared.c
diff options
context:
space:
mode:
authorLars Hjemli <hjemli@gmail.com>2008-08-06 09:50:10 +0200
committerLars Hjemli <hjemli@gmail.com>2008-08-06 09:50:10 +0200
commite352a013aed6e925a10a92916500c7deccf1410a (patch)
tree7c49bf453bee4f624025d62bae92b4926bf83bfe /ui-shared.c
parentcgitrc: explain new local-time option (diff)
parentAdd atom-support (diff)
downloadcgit-pink-e352a013aed6e925a10a92916500c7deccf1410a.tar.gz
cgit-pink-e352a013aed6e925a10a92916500c7deccf1410a.zip
Merge branch 'lh/atom'
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 197ee37..37c60b2 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -34,6 +34,21 @@ void cgit_print_error(char *msg)
 	html("</div>\n");
 }
 
+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()
 {
 	if (ctx.cfg.virtual_root)
@@ -428,6 +443,7 @@ void cgit_print_http_headers(struct cgit_context *ctx)
 
 void cgit_print_docstart(struct cgit_context *ctx)
 {
+	char *host = cgit_hosturl();
 	html(cgit_doctype);
 	html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n");
 	html("<head>\n");
@@ -445,6 +461,13 @@ void cgit_print_docstart(struct cgit_context *ctx)
 		html_attr(ctx->cfg.favicon);
 		html("'/>\n");
 	}
+	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");
 	html("<body>\n");
 }