mirror of
https://git.zx2c4.com/cgit
synced 2025-07-16 05:04:35 +02:00
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>
This commit is contained in:
parent
0f0ab148c6
commit
b2a3d31e88
7 changed files with 168 additions and 0 deletions
23
ui-shared.c
23
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");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue