Skip to content

Commit

Permalink
Merge pull request #296 from Carreau/simpledev
Browse files Browse the repository at this point in the history
Add option to not use minified javascript and ease development.
  • Loading branch information
minrk committed Aug 19, 2015
2 parents 51fabeb + d4b1e9a commit e122f06
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
7 changes: 7 additions & 0 deletions docs/source/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,10 @@ You can then build the Javascript and CSS by running::

This will automatically fetch the remaining dependencies (bower, less) and
install them in a subdirectory.

For quick iteration on the Notebook's Javascript you can deactivate the use of
the bundled and minified Javacript by using the option
``--NotebookApp.ignore_minified_js=True``. This might though highly increase the
number of requests that the browser make to the server, but can allow to test
Javascript file modification without going through the compilation step that
can take up to 30 sec.
12 changes: 11 additions & 1 deletion notebook/base/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,16 @@ class IPythonHandler(AuthenticatedHandler):
Mostly property shortcuts to IPython-specific settings.
"""



@property
def ignore_minified_js(self):
"""Wether to user bundle in template. (*.min files)
Mainly use for development and avoid file recompilation
"""
return self.settings.get('ignore_minified_js', False)

@property
def config(self):
return self.settings.get('config', None)
Expand Down Expand Up @@ -261,6 +270,7 @@ def template_namespace(self):
sys_info=sys_info,
contents_js_source=self.contents_js_source,
version_hash=self.version_hash,
ignore_minified_js=self.ignore_minified_js,
**self.jinja_template_vars
)

Expand Down
6 changes: 6 additions & 0 deletions notebook/notebookapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def init_settings(self, ipython_app, kernel_manager, contents_manager,
'no_cache_paths': [url_path_join(base_url, 'static', 'custom')],
},
version_hash=version_hash,
ignore_minified_js=ipython_app.ignore_minified_js,

# authentication
cookie_secret=ipython_app.cookie_secret,
Expand Down Expand Up @@ -396,6 +397,11 @@ def _log_format_default(self):
# create requested profiles by default, if they don't exist:
auto_create = Bool(True)

ignore_minified_js = Bool(False,
config=True,
help='Use minified JS file or not, mainly use during dev to avoid JS recompilation',
)

# file to be opened in the notebook server
file_to_run = Unicode('', config=True)

Expand Down
6 changes: 5 additions & 1 deletion notebook/templates/notebook.html
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,10 @@

<script src="{{ static_url("components/text-encoding/lib/encoding.js") }}" charset="utf-8"></script>

<script src="{{ static_url("notebook/js/main.min.js") }}" charset="utf-8"></script>
{% if ignore_minified_js %}
<script src="{{ static_url("notebook/js/main.js") }}" charset="utf-8"></script>
{% else %}
<script src="{{ static_url("notebook/js/main.min.js") }}" charset="utf-8"></script>
{% endif %}

{% endblock %}

0 comments on commit e122f06

Please sign in to comment.