In reverse-proxy setups cgit's auto-determination of the hostname doesn't work. When set, this option will be used as prefix to all atom-related URLs. While the rest of cgit's URLs are not absolute, this option, if set, should be absolute and include a scheme. Default value: none.
Signed-off-by: Daniel Reichelt <[email protected]> --- cgit.c | 2 ++ cgit.h | 1 + cgitrc.5.txt | 6 ++++++ ui-atom.c | 16 ++++++++++++---- ui-shared.c | 8 ++++++-- 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/cgit.c b/cgit.c index d84b4be..351f9bd 100644 --- a/cgit.c +++ b/cgit.c @@ -142,6 +142,8 @@ static void config_cb(const char *name, const char *value) ctx.cfg.strict_export = xstrdup(value); else if (!strcmp(name, "virtual-root")) { ctx.cfg.virtual_root = ensure_end(value, '/'); + } else if (!strcmp(name, "atom-root")) { + ctx.cfg.atom_root = xstrdup(value); } else if (!strcmp(name, "nocache")) ctx.cfg.nocache = atoi(value); else if (!strcmp(name, "noplainemail")) diff --git a/cgit.h b/cgit.h index 3120562..a3bb3aa 100644 --- a/cgit.h +++ b/cgit.h @@ -209,6 +209,7 @@ struct cgit_config { char *section; char *repository_sort; char *virtual_root; /* Always ends with '/'. */ + char *atom_root; char *strict_export; int cache_size; int cache_dynamic_ttl; diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 759f353..4cb5be9 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -42,6 +42,12 @@ agefile:: hh:mm:ss". You may want to generate this file from a post-receive hook. Default value: "info/web/last-modified". +atom-root:: + In reverse-proxy setups cgit's auto-determination of the hostname doesn't + work. When set, this option will be used as prefix to all atom-related + URLs. While the rest of cgit's URLs are not absolute, this option, if set, + should be absolute and include a scheme. Default value: none. + auth-filter:: Specifies a command that will be invoked for authenticating repository access. Receives quite a few arguments, and data on both stdin and diff --git a/ui-atom.c b/ui-atom.c index e2b39ee..038a168 100644 --- a/ui-atom.c +++ b/ui-atom.c @@ -54,8 +54,12 @@ static void add_entry(struct commit *commit, const char *host) html("</published>\n"); if (host) { html("<link rel='alternate' type='text/html' href='"); - html(cgit_httpscheme()); - html_attr(host); + if (ctx.cfg.atom_root) { + html(ctx.cfg.atom_root); + } else { + html(cgit_httpscheme()); + html_attr(host); + } html_attr(cgit_pageurl(ctx.repo->url, "commit", NULL)); if (ctx.cfg.virtual_root) delim = '?'; @@ -126,8 +130,12 @@ void cgit_print_atom(char *tip, char *path, int max_count) html("</subtitle>\n"); if (host) { html("<link rel='alternate' type='text/html' href='"); - html(cgit_httpscheme()); - html_attr(host); + if (ctx.cfg.atom_root) { + html(ctx.cfg.atom_root); + } else { + html(cgit_httpscheme()); + html_attr(host); + } html_attr(cgit_repourl(ctx.repo->url)); html("'/>\n"); } diff --git a/ui-shared.c b/ui-shared.c index 6be0c2e..a051cd8 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -751,8 +751,12 @@ void cgit_print_docstart(void) strbuf_addf(&sb, "h=%s", ctx.qry.head); html("<link rel='alternate' title='Atom feed' href='"); - html(cgit_httpscheme()); - html_attr(cgit_hosturl()); + if (ctx.cfg.atom_root) { + html(ctx.cfg.atom_root); + } else { + html(cgit_httpscheme()); + html_attr(host); + } html_attr(cgit_fileurl(ctx.repo->url, "atom", ctx.qry.vpath, sb.buf)); html("' type='application/atom+xml'/>\n"); -- 2.1.4 _______________________________________________ CGit mailing list [email protected] http://lists.zx2c4.com/mailman/listinfo/cgit
