Show More
@@ -343,7 +343,30 b' class NotebookApp(BaseIPythonApplication):' | |||||
343 | return static_url_prefix+u"mathjax/MathJax.js" |
|
343 | return static_url_prefix+u"mathjax/MathJax.js" | |
344 | else: |
|
344 | else: | |
345 | self.log.info("Using MathJax from CDN") |
|
345 | self.log.info("Using MathJax from CDN") | |
346 | return u"http://cdn.mathjax.org/mathjax/latest/MathJax.js" |
|
346 | hostname = "cdn.mathjax.org" | |
|
347 | try: | |||
|
348 | # resolve mathjax cdn alias to cloudfront, because Amazon's SSL certificate | |||
|
349 | # only works on *.cloudfront.net | |||
|
350 | true_host, aliases, IPs = socket.gethostbyname_ex(hostname) | |||
|
351 | # I've run this on a few machines, and some put the right answer in true_host, | |||
|
352 | # while others gave it in the aliases list, so we check both. | |||
|
353 | aliases.insert(0, true_host) | |||
|
354 | except Exception: | |||
|
355 | self.log.warn("Couldn't determine MathJax CDN info") | |||
|
356 | else: | |||
|
357 | for alias in aliases: | |||
|
358 | parts = alias.split('.') | |||
|
359 | # want static foo.cloudfront.net, not dynamic foo.lax3.cloudfront.net | |||
|
360 | if len(parts) == 3 and alias.endswith(".cloudfront.net"): | |||
|
361 | hostname = alias | |||
|
362 | break | |||
|
363 | ||||
|
364 | if not hostname.endswith(".cloudfront.net"): | |||
|
365 | self.log.error("Couldn't resolve CloudFront host, required for HTTPS MathJax.") | |||
|
366 | self.log.error("Loading from https://cdn.mathjax.org will probably fail due to invalid certificate.") | |||
|
367 | self.log.error("For unsecured HTTP access to MathJax use config:") | |||
|
368 | self.log.error("NotebookApp.mathjax_url='http://cdn.mathjax.org/mathjax/latest/MathJax.js'") | |||
|
369 | return u"https://%s/mathjax/latest/MathJax.js" % hostname | |||
347 |
|
370 | |||
348 | def _mathjax_url_changed(self, name, old, new): |
|
371 | def _mathjax_url_changed(self, name, old, new): | |
349 | if new and not self.enable_mathjax: |
|
372 | if new and not self.enable_mathjax: |
General Comments 0
You need to be logged in to leave comments.
Login now