Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

diverse fixes for project url #2723

Merged
merged 1 commit into from
Jan 3, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions IPython/frontend/html/notebook/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -874,25 +874,6 @@ def get_version(cls, settings, path):
return None


# make_static_url and parse_url_path totally unchanged from tornado 2.2.0
# but needed for tornado < 2.2.0 compat
@classmethod
def make_static_url(cls, settings, path):
"""Constructs a versioned url for the given path.

This method may be overridden in subclasses (but note that it is
a class method rather than an instance method).

``settings`` is the `Application.settings` dictionary. ``path``
is the static path being requested. The url returned should be
relative to the current host.
"""
static_url_prefix = settings.get('static_url_prefix', '/static/')
version_hash = cls.get_version(settings, path)
if version_hash:
return static_url_prefix + path + "?v=" + version_hash
return static_url_prefix + path

def parse_url_path(self, url_path):
"""Converts a static URL path into a filesystem path.

Expand Down
29 changes: 25 additions & 4 deletions IPython/frontend/html/notebook/notebookapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,9 @@ def __init__(self, ipython_app, kernel_manager, notebook_manager,
template_path=os.path.join(os.path.dirname(__file__), "templates"),
static_path=ipython_app.static_file_path,
static_handler_class = FileFindHandler,
static_url_prefix = url_path_join(base_project_url,'/static/'),
cookie_secret=os.urandom(1024),
login_url="%s/login"%(base_project_url.rstrip('/')),
login_url=url_path_join(base_project_url,'/login'),
cookie_name='username-%s' % uuid.uuid4(),
)

Expand Down Expand Up @@ -363,13 +364,33 @@ def _enable_mathjax_changed(self, name, old, new):
self.mathjax_url = u''

base_project_url = Unicode('/', config=True,
help='''The base URL for the notebook server''')
help='''The base URL for the notebook server.

Leading and trailing slashes can be omitted,
and will automatically be added.
''')
def _base_project_url_changed(self, name, old, new):
if not new.startswith('/'):
self.base_project_url = '/'+new
elif not new.endswith('/'):
self.base_project_url = new+'/'

base_kernel_url = Unicode('/', config=True,
help='''The base URL for the kernel server''')
help='''The base URL for the kernel server

Leading and trailing slashes can be omitted,
and will automatically be added.
''')
def _base_kernel_url_changed(self, name, old, new):
if not new.startswith('/'):
self.base_kernel_url = '/'+new
elif not new.endswith('/'):
self.base_kernel_url = new+'/'

websocket_host = Unicode("", config=True,
help="""The hostname for the websocket server."""
)

extra_static_paths = List(Unicode, config=True,
help="""Extra paths to search for serving static files.

Expand Down
4 changes: 2 additions & 2 deletions IPython/frontend/html/notebook/templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!DOCTYPE HTML>
{% macro static_url(name) -%}
/static/{{ name }}
{{ base_project_url }}static/{{ name }}
{%- endmacro %}
<html>

Expand All @@ -28,7 +28,7 @@
<body {% block params %}{% endblock %}>

<div id="header">
<span id="ipython_notebook"><div><a href={{base_project_url}} alt='dashboard'><img src='{{static_url("ipynblogo.png") }}' alt='IPython Notebook'/></a></div></span>
<span id="ipython_notebook"><div><a href="{{base_project_url}}" alt='dashboard'><img src='{{static_url("ipynblogo.png") }}' alt='IPython Notebook'/></a></div></span>

{% block login_widget %}

Expand Down