##// END OF EJS Templates
serve local mathjax from nb_extensions
MinRK -
Show More
@@ -450,21 +450,32 b' class NotebookApp(BaseIPythonApplication):'
450 static_url_prefix = self.webapp_settings.get("static_url_prefix",
450 static_url_prefix = self.webapp_settings.get("static_url_prefix",
451 url_path_join(self.base_project_url, "static")
451 url_path_join(self.base_project_url, "static")
452 )
452 )
453 try:
453
454 mathjax = filefind(os.path.join('mathjax', 'MathJax.js'), self.static_file_path)
454 # try local mathjax, either in nb_extensions/mathjax or static/mathjax
455 except IOError:
455 for (url_prefix, search_path) in [
456 if self.certfile:
456 (url_path_join(self.base_project_url, "extensions"), self.nb_extensions_path),
457 # HTTPS: load from Rackspace CDN, because SSL certificate requires it
457 (static_url_prefix, self.static_file_path),
458 base = u"https://c328740.ssl.cf1.rackcdn.com"
458 ]:
459 self.log.debug("searching for local mathjax in %s", search_path)
460 try:
461 mathjax = filefind(os.path.join('mathjax', 'MathJax.js'), search_path)
462 except IOError:
463 continue
459 else:
464 else:
460 base = u"http://cdn.mathjax.org"
465 url = url_path_join(url_prefix, u"mathjax/MathJax.js")
461
466 self.log.info("Serving local MathJax from %s at %s", mathjax, url)
462 url = base + u"/mathjax/latest/MathJax.js"
467 return url
463 self.log.info("Using MathJax from CDN: %s", url)
468
464 return url
469 # no local mathjax, serve from CDN
470 if self.certfile:
471 # HTTPS: load from Rackspace CDN, because SSL certificate requires it
472 host = u"https://c328740.ssl.cf1.rackcdn.com"
465 else:
473 else:
466 self.log.info("Using local MathJax from %s" % mathjax)
474 host = u"http://cdn.mathjax.org"
467 return url_path_join(static_url_prefix, u"mathjax/MathJax.js")
475
476 url = host + u"/mathjax/latest/MathJax.js"
477 self.log.info("Using MathJax from CDN: %s", url)
478 return url
468
479
469 def _mathjax_url_changed(self, name, old, new):
480 def _mathjax_url_changed(self, name, old, new):
470 if new and not self.enable_mathjax:
481 if new and not self.enable_mathjax:
General Comments 0
You need to be logged in to leave comments. Login now