# HG changeset patch # User Goffi # Date 1457552427 -3600 # Node ID 763da94ba28b0e14517e96c43a0d819240ab0e6e # Parent 74be6217d913b9ccf500ff9bbe472a215e1a5f30 blog (atom): base_url_ext can now only specify scheme, or netloc, or path, it will be used to complete data coming from request's path diff -r 74be6217d913 -r 763da94ba28b src/server/blog.py --- a/src/server/blog.py Wed Mar 09 20:40:27 2016 +0100 +++ b/src/server/blog.py Wed Mar 09 20:40:27 2016 +0100 @@ -35,6 +35,7 @@ import re import os import sys +import urlparse import urllib from libervia.server.html_tools import sanitizeHtml, convertNewLinesToXHTML @@ -398,11 +399,17 @@ feed_elt = domish.Element((NS_ATOM, u'feed')) title = _(u"{user}'s blog").format(user=profile) feed_elt.addElement(u'title', content=title) - if self.host.base_url_ext is not None: - base_blog_url = u"{}blog/{user}".format(self.host.base_url_ext, user=profile) - else: - url_path = request.URLPath() - base_blog_url = u"{0.scheme}://{0.netloc}/blog/{user}".format(url_path, user=profile) + + # to construct base blog url, we use base_url_ext if given by user + # and complete unknown parts with what we find in request's url + url_path = request.URLPath() + ext_data = self.host.base_url_ext_data + base_blog_url = urlparse.urlunsplit(( + ext_data.scheme or url_path.scheme.decode('utf-8'), + ext_data.netloc or url_path.netloc.decode('utf-8'), + u'{}blog/{user}'.format(ext_data.path or u'/', user=profile), + '', + '')) # atom link link_feed_elt = feed_elt.addElement('link') diff -r 74be6217d913 -r 763da94ba28b src/server/server.py --- a/src/server/server.py Wed Mar 09 20:40:27 2016 +0100 +++ b/src/server/server.py Wed Mar 09 20:40:27 2016 +0100 @@ -1469,8 +1469,13 @@ self.base_url_ext = self.options.pop('base_url_ext') if self.base_url_ext[-1] != '/': self.base_url_ext += '/' + self.base_url_ext_data = urlparse.urlsplit(self.base_url_ext) else: self.base_url_ext = None + # we split empty string anyway so we can do things like + # scheme = self.base_url_ext_data.scheme or 'https' + self.base_url_ext_data = urlparse.urlsplit('') + if not self.options['port_https_ext']: self.options['port_https_ext'] = self.options['port_https'] if self.options['data_dir'] == DATA_DIR_DEFAULT: