summaryrefslogtreecommitdiffabout
path: root/ui-shared.c
authorLars Hjemli <hjemli@gmail.com>2008-05-21 06:17:54 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2008-08-01 20:12:34 (UTC)
commitb2a3d31e8839b53a623b4c99124c2c637d0e3cbb (patch) (side-by-side diff)
tree7335ff15fdbe92aa0afb31e4a54e2f863760c217 /ui-shared.c
parent0f0ab148c6d444316af10e6b4c7a60630fed45d3 (diff)
downloadcgit-b2a3d31e8839b53a623b4c99124c2c637d0e3cbb.zip
cgit-b2a3d31e8839b53a623b4c99124c2c637d0e3cbb.tar.gz
cgit-b2a3d31e8839b53a623b4c99124c2c637d0e3cbb.tar.bz2
Add atom-support
This enables a page which generates atom feeds for the current branch and path, heavily inspired by the atom-support in gitweb. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'ui-shared.c') (more/less context) (ignore whitespace changes)
-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
@@ -35,4 +35,19 @@ 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()
{
@@ -429,4 +444,5 @@ 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");
@@ -446,4 +462,11 @@ void cgit_print_docstart(struct cgit_context *ctx)
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");