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