about summary refs log tree commit diff
path: root/ui-shared.c
diff options
context:
space:
mode:
authorLars Hjemli <hjemli@gmail.com>2008-05-21 08:17:54 +0200
committerLars Hjemli <hjemli@gmail.com>2008-08-01 22:12:34 +0200
commitb2a3d31e8839b53a623b4c99124c2c637d0e3cbb (patch)
tree7335ff15fdbe92aa0afb31e4a54e2f863760c217 /ui-shared.c
parentAdded `local-time` option to cgitrc (diff)
downloadcgit-pink-b2a3d31e8839b53a623b4c99124c2c637d0e3cbb.tar.gz
cgit-pink-b2a3d31e8839b53a623b4c99124c2c637d0e3cbb.zip
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 '')
-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");
 }
sg'> 2018-09-28Add sans6x10 basic glyphsJune McEnroe 2018-09-28Make sans6x8 double quote narrowerJune McEnroe 2018-09-28Add greek glyphs to sans6x8June McEnroe 2018-09-28Add png target in etc/psfJune McEnroe 2018-09-28Disable visual bell in light terminal profileJune McEnroe 2018-09-28Add psf2pngJune McEnroe 2018-09-27Add HJKL for moving glyphs to psfedJune McEnroe 2018-09-27Move psfed paste to edit modeJune McEnroe 2018-09-27Export PWDJune McEnroe Without it, $(PWD) is unset in GNU make. 2018-09-27Add sans6x8 PSF2 fontJune McEnroe 2018-09-26Add copy paste to psfedJune McEnroe 2018-09-25Add r to psfed for invertJune McEnroe 2018-09-24Add psfed, a PSF2 font editorJune McEnroe 2018-09-21Add scheme -i to swap white and blackJune McEnroe 2018-09-21Map caps lock to escape on Linux consoleJune McEnroe 2018-09-19Fix README mandoc lintsJune McEnroe 2018-09-19Un-NOT trans.alpha values in pngoJune McEnroe 2018-09-18Refactor reads in pngo and clear palette between filesJune McEnroe 2018-09-17Add tRNS support to pngoJune McEnroe 2018-09-11Move gfx man pages to gfx/manJune McEnroe 2018-09-11Move bin man pages to bin/manJune McEnroe 2018-09-11Rewrite gfx.7 and render plaintext READMEJune McEnroe 2018-09-11Remove GAMES from BINSJune McEnroe 2018-09-11Rewrite bin.7 and render to plaintext READMEJune McEnroe 2018-09-11Add "blank" lines to man pagesJune McEnroe 2018-09-10Add mdoc syntax fileJune McEnroe 2018-09-08Fix Nm usage in multi-name man pagesJune McEnroe 2018-09-08Put real dates on man pagesJune McEnroe 2018-09-08Replace gfx README with REAMDE.7June McEnroe 2018-09-08Link gfx man pages in ~/.localJune McEnroe