Merge pull request #1710 from minrk/mathjaxcdn

update MathJax CDN url for https

As discussed on mathjax-users, the MathJax CDN is moving. This doesn't affect mathjax from http, which just uses cdn.mathjax.org, but for SSL-certiificates the actual CDN url must be used (formerly cloudfront, now rackcdn).

Also, forgo gethostbyname_ex hack, that was me solving a theoretical problem that could not officially happen.

0.12-series is unaffected, as the https-cdn hack was not backported to 0.12.1.
This commit is contained in:
Fernando Perez 2012-05-09 17:02:20 -07:00
commit 72721e208d

View File

@ -349,31 +349,15 @@ class NotebookApp(BaseIPythonApplication):
self.log.info("Using local MathJax")
return static_url_prefix+u"mathjax/MathJax.js"
else:
self.log.info("Using MathJax from CDN")
hostname = "cdn.mathjax.org"
try:
# resolve mathjax cdn alias to cloudfront, because Amazon's SSL certificate
# only works on *.cloudfront.net
true_host, aliases, IPs = socket.gethostbyname_ex(hostname)
# I've run this on a few machines, and some put the right answer in true_host,
# while others gave it in the aliases list, so we check both.
aliases.insert(0, true_host)
except Exception:
self.log.warn("Couldn't determine MathJax CDN info")
if self.certfile:
# HTTPS: load from Rackspace CDN, because SSL certificate requires it
base = u"https://c328740.ssl.cf1.rackcdn.com"
else:
for alias in aliases:
parts = alias.split('.')
# want static foo.cloudfront.net, not dynamic foo.lax3.cloudfront.net
if len(parts) == 3 and alias.endswith(".cloudfront.net"):
hostname = alias
break
base = u"http://cdn.mathjax.org"
if not hostname.endswith(".cloudfront.net"):
self.log.error("Couldn't resolve CloudFront host, required for HTTPS MathJax.")
self.log.error("Loading from https://cdn.mathjax.org will probably fail due to invalid certificate.")
self.log.error("For unsecured HTTP access to MathJax use config:")
self.log.error("NotebookApp.mathjax_url='http://cdn.mathjax.org/mathjax/latest/MathJax.js'")
return u"https://%s/mathjax/latest/MathJax.js" % hostname
url = base + u"/mathjax/latest/MathJax.js"
self.log.info("Using MathJax from CDN: %s", url)
return url
def _mathjax_url_changed(self, name, old, new):
if new and not self.enable_mathjax: