mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-21 04:10:17 +08:00
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:
commit
72721e208d
@ -349,31 +349,15 @@ class NotebookApp(BaseIPythonApplication):
|
|||||||
self.log.info("Using local MathJax")
|
self.log.info("Using local MathJax")
|
||||||
return static_url_prefix+u"mathjax/MathJax.js"
|
return static_url_prefix+u"mathjax/MathJax.js"
|
||||||
else:
|
else:
|
||||||
self.log.info("Using MathJax from CDN")
|
if self.certfile:
|
||||||
hostname = "cdn.mathjax.org"
|
# HTTPS: load from Rackspace CDN, because SSL certificate requires it
|
||||||
try:
|
base = u"https://c328740.ssl.cf1.rackcdn.com"
|
||||||
# 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")
|
|
||||||
else:
|
else:
|
||||||
for alias in aliases:
|
base = u"http://cdn.mathjax.org"
|
||||||
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
|
|
||||||
|
|
||||||
if not hostname.endswith(".cloudfront.net"):
|
url = base + u"/mathjax/latest/MathJax.js"
|
||||||
self.log.error("Couldn't resolve CloudFront host, required for HTTPS MathJax.")
|
self.log.info("Using MathJax from CDN: %s", url)
|
||||||
self.log.error("Loading from https://cdn.mathjax.org will probably fail due to invalid certificate.")
|
return url
|
||||||
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
|
|
||||||
|
|
||||||
def _mathjax_url_changed(self, name, old, new):
|
def _mathjax_url_changed(self, name, old, new):
|
||||||
if new and not self.enable_mathjax:
|
if new and not self.enable_mathjax:
|
||||||
|
Loading…
Reference in New Issue
Block a user