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