Skip to content

Commit

Permalink
Merge pull request #128 from Zsailer/extension-browser-open
Browse files Browse the repository at this point in the history
[MRG] add open_browser trait to ExtensionApp
  • Loading branch information
Zsailer authored Dec 14, 2019
2 parents ffb0744 + e0fdaf4 commit 1ba5a57
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions jupyter_server/extension/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from traitlets import (
Unicode,
List,
Dict,
Dict,
Bool,
default,
validate
)
Expand Down Expand Up @@ -80,6 +81,12 @@ def _preparse_for_stopping_flags(Application, argv):
app.exit(0)


flags['no-browser']=(
{'ExtensionApp' : {'open_browser' : True}},
_("Prevent the opening of the default url in the browser.")
)


class ExtensionApp(JupyterApp):
"""Base class for configurable Jupyter Server Extension Applications.
Expand Down Expand Up @@ -176,6 +183,11 @@ def _config_file_name_default(self):
help=_("The default URL to redirect to from `/`")
)

open_browser = Bool(
True,
help=_("Should the extension open a browser window?")
)

custom_display_url = Unicode(u'', config=True,
help=_("""Override URL shown to users.
Expand Down Expand Up @@ -335,7 +347,7 @@ def start(self):
# Override the server's display url to show extension's display URL.
self.serverapp.custom_display_url = self.custom_display_url
# Override the server's default option and open a broswer window.
self.serverapp.open_browser = True
self.serverapp.open_browser = self.open_browser
# Hijack the server's browser-open file to land on
# the extensions home page.
self.serverapp._write_browser_open_file = self._write_browser_open_file
Expand Down

0 comments on commit 1ba5a57

Please sign in to comment.