use Tornado's handler.static_url() in templates

This commit is contained in:
Andrew Straw 2012-01-26 17:15:41 +01:00
parent 5067e77292
commit 81a636dabf
4 changed files with 55 additions and 53 deletions

View File

@ -285,9 +285,11 @@ class NotebookApp(BaseIPythonApplication):
if not self.enable_mathjax:
return u''
static_path = self.webapp_settings.get("static_path", os.path.join(os.path.dirname(__file__), "static"))
static_url_prefix = self.webapp_settings.get("static_url_prefix",
"/static/")
if os.path.exists(os.path.join(static_path, 'mathjax', "MathJax.js")):
self.log.info("Using local MathJax")
return u"/static/mathjax/MathJax.js"
return static_url_prefix+u"mathjax/MathJax.js"
else:
self.log.info("Using MathJax from CDN")
return u"http://cdn.mathjax.org/mathjax/latest/MathJax.js"

View File

@ -6,10 +6,10 @@
<title>{% block title %}IPython Notebook{% end %}</title>
<link rel="stylesheet" href="/static/jquery/css/themes/base/jquery-ui.min.css" type="text/css" />
<link rel="stylesheet" href="/static/css/boilerplate.css" type="text/css" />
<link rel="stylesheet" href="/static/css/layout.css" type="text/css" />
<link rel="stylesheet" href="/static/css/base.css" type="text/css"/>
<link rel="stylesheet" href="{{static_url("jquery/css/themes/base/jquery-ui.min.css") }}" type="text/css" />
<link rel="stylesheet" href="{{static_url("css/boilerplate.css") }}" type="text/css" />
<link rel="stylesheet" href="{{static_url("css/layout.css") }}" type="text/css" />
<link rel="stylesheet" href="{{static_url("css/base.css") }}" type="text/css"/>
{% block stylesheet %}
{% end %}
@ -21,7 +21,7 @@
<body {% block params %}{% end %}>
<div id="header">
<span id="ipython_notebook"><h1><img src='/static/ipynblogo.png' alt='IPython Notebook'/></h1></span>
<span id="ipython_notebook"><h1><img src='{{static_url("ipynblogo.png") }}' alt='IPython Notebook'/></h1></span>
{% block login_widget %}
@ -72,11 +72,11 @@
</div>
<script src="/static/jquery/js/jquery-1.7.1.min.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/jquery/js/jquery-ui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/namespace.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/loginmain.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/loginwidget.js" type="text/javascript" charset="utf-8"></script>
<script src="{{static_url("jquery/js/jquery-1.7.1.min.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{static_url("jquery/js/jquery-ui.min.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{static_url("js/namespace.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{static_url("js/loginmain.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{static_url("js/loginwidget.js") }}" type="text/javascript" charset="utf-8"></script>
{% block script %}
{% end %}

View File

@ -15,17 +15,17 @@
window.mathjax_url = "{{mathjax_url}}";
</script>
<link rel="stylesheet" href="/static/jquery/css/themes/base/jquery-ui.min.css" type="text/css" />
<link rel="stylesheet" href="/static/codemirror/lib/codemirror.css">
<link rel="stylesheet" href="/static/codemirror/theme/ipython.css">
<link rel="stylesheet" href="{{ static_url("jquery/css/themes/base/jquery-ui.min.css") }}" type="text/css" />
<link rel="stylesheet" href="{{ static_url("codemirror/lib/codemirror.css") }}">
<link rel="stylesheet" href="{{ static_url("codemirror/theme/ipython.css") }}">
<link rel="stylesheet" href="/static/prettify/prettify.css"/>
<link rel="stylesheet" href="{{ static_url("prettify/prettify.css") }}"/>
<link rel="stylesheet" href="/static/css/boilerplate.css" type="text/css" />
<link rel="stylesheet" href="/static/css/layout.css" type="text/css" />
<link rel="stylesheet" href="/static/css/base.css" type="text/css" />
<link rel="stylesheet" href="/static/css/notebook.css" type="text/css" />
<link rel="stylesheet" href="/static/css/renderedhtml.css" type="text/css" />
<link rel="stylesheet" href="{{ static_url("css/boilerplate.css") }}" type="text/css" />
<link rel="stylesheet" href="{{ static_url("css/layout.css") }}" type="text/css" />
<link rel="stylesheet" href="{{ static_url("css/base.css") }}" type="text/css" />
<link rel="stylesheet" href="{{ static_url("css/notebook.css") }}" type="text/css" />
<link rel="stylesheet" href="{{ static_url("css/renderedhtml.css") }}" type="text/css" />
{% comment In the notebook, the read-only flag is used to determine %}
{% comment whether to hide the side panels and switch off input %}
@ -39,7 +39,7 @@
>
<div id="header">
<span id="ipython_notebook"><h1><a href='..' alt='dashboard'><img src='/static/ipynblogo.png' alt='IPython Notebook'/></a></h1></span>
<span id="ipython_notebook"><h1><a href='..' alt='dashboard'><img src='{{static_url("ipynblogo.png")}}' alt='IPython Notebook'/></a></h1></span>
<span id="save_widget">
<span id="notebook_name"></span>
<span id="save_status"></span>
@ -188,39 +188,39 @@
</div>
<script src="/static/jquery/js/jquery-1.7.1.min.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/jquery/js/jquery-ui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="{{ static_url("jquery/js/jquery-1.7.1.min.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ static_url("jquery/js/jquery-ui.min.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="/static/codemirror/lib/codemirror.js" charset="utf-8"></script>
<script src="/static/codemirror/mode/python/python.js" charset="utf-8"></script>
<script src="/static/codemirror/mode/htmlmixed/htmlmixed.js" charset="utf-8"></script>
<script src="/static/codemirror/mode/xml/xml.js" charset="utf-8"></script>
<script src="/static/codemirror/mode/javascript/javascript.js" charset="utf-8"></script>
<script src="/static/codemirror/mode/css/css.js" charset="utf-8"></script>
<script src="/static/codemirror/mode/rst/rst.js" charset="utf-8"></script>
<script src="/static/codemirror/mode/markdown/markdown.js" charset="utf-8"></script>
<script src="{{ static_url("codemirror/lib/codemirror.js") }}" charset="utf-8"></script>
<script src="{{ static_url("codemirror/mode/python/python.js") }}" charset="utf-8"></script>
<script src="{{ static_url("codemirror/mode/htmlmixed/htmlmixed.js") }}" charset="utf-8"></script>
<script src="{{ static_url("codemirror/mode/xml/xml.js") }}" charset="utf-8"></script>
<script src="{{ static_url("codemirror/mode/javascript/javascript.js") }}" charset="utf-8"></script>
<script src="{{ static_url("codemirror/mode/css/css.js") }}" charset="utf-8"></script>
<script src="{{ static_url("codemirror/mode/rst/rst.js") }}" charset="utf-8"></script>
<script src="{{ static_url("codemirror/mode/markdown/markdown.js") }}" charset="utf-8"></script>
<script src="/static/pagedown/Markdown.Converter.js" charset="utf-8"></script>
<script src="{{ static_url("pagedown/Markdown.Converter.js") }}" charset="utf-8"></script>
<script src="/static/prettify/prettify.js" charset="utf-8"></script>
<script src="/static/dateformat/date.format.js" charset="utf-8"></script>
<script src="{{ static_url("prettify/prettify.js") }}" charset="utf-8"></script>
<script src="{{ static_url("dateformat/date.format.js") }}" charset="utf-8"></script>
<script src="/static/js/namespace.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/utils.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/cell.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/codecell.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/textcell.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/kernel.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/kernelstatus.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/layout.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/savewidget.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/quickhelp.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/loginwidget.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/pager.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/menubar.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/toolbar.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/notebook.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/notebookmain.js" type="text/javascript" charset="utf-8"></script>
<script src="{{ static_url("js/namespace.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ static_url("js/utils.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ static_url("js/cell.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ static_url("js/codecell.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ static_url("js/textcell.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ static_url("js/kernel.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ static_url("js/kernelstatus.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ static_url("js/layout.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ static_url("js/savewidget.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ static_url("js/quickhelp.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ static_url("js/loginwidget.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ static_url("js/pager.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ static_url("js/menubar.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ static_url("js/toolbar.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ static_url("js/notebook.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{ static_url("js/notebookmain.js") }}" type="text/javascript" charset="utf-8"></script>
</body>

View File

@ -5,7 +5,7 @@ IPython Dashboard
{% end %}
{% block stylesheet %}
<link rel="stylesheet" href="/static/css/projectdashboard.css" type="text/css" />
<link rel="stylesheet" href="{{static_url("css/projectdashboard.css") }}" type="text/css" />
{% end %}
{% block meta %}
@ -38,6 +38,6 @@ data-base-kernel-url={{base_kernel_url}}
{% end %}
{% block script %}
<script src="/static/js/notebooklist.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/js/projectdashboardmain.js" type="text/javascript" charset="utf-8"></script>
<script src="{{static_url("js/notebooklist.js") }}" type="text/javascript" charset="utf-8"></script>
<script src="{{static_url("js/projectdashboardmain.js") }}" type="text/javascript" charset="utf-8"></script>
{% end %}