List for cgit developers and users
 help / color / mirror / Atom feed
* [PATCH] add new option atom-root
@ 2015-08-13  4:49 hacking
  2015-08-13  9:46 ` Jason
  0 siblings, 1 reply; 3+ messages in thread
From: hacking @ 2015-08-13  4:49 UTC (permalink / raw)


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 <hacking at nachtgeist.net>
---
 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




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] add new option atom-root
  2015-08-13  4:49 [PATCH] add new option atom-root hacking
@ 2015-08-13  9:46 ` Jason
  2015-08-13  9:49   ` hacking
  0 siblings, 1 reply; 3+ messages in thread
From: Jason @ 2015-08-13  9:46 UTC (permalink / raw)


Wouldn't it be better to just use a relative URL?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20150813/04891d3b/attachment.html>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] add new option atom-root
  2015-08-13  9:46 ` Jason
@ 2015-08-13  9:49   ` hacking
  0 siblings, 0 replies; 3+ messages in thread
From: hacking @ 2015-08-13  9:49 UTC (permalink / raw)


You yourself got me thinking about this (see previous archive link) :)

The problem is, we don't know how different browsers would call external feed reader programs
a) with the correctly assembled feed url
b) dumb as hell with just the relative part...


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-08-13  9:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-13  4:49 [PATCH] add new option atom-root hacking
2015-08-13  9:46 ` Jason
2015-08-13  9:49   ` hacking

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).