Skip to content

Commit

Permalink
Merge pull request jupyterhub#729 from betatim/about-page
Browse files Browse the repository at this point in the history
Add about page to BinderHub
  • Loading branch information
choldgraf authored Nov 15, 2018
2 parents f0fb674 + 1a18e5a commit 6bb3257
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 3 deletions.
19 changes: 16 additions & 3 deletions binderhub/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from traitlets.config import Application
from jupyterhub.services.auth import HubOAuthCallbackHandler

from .base import Custom404
from .base import AboutHandler, Custom404
from .build import Build
from .builder import BuildHandler
from .launcher import Launcher
Expand Down Expand Up @@ -94,6 +94,17 @@ def _log_level(self):
config=True
)

about_message = Unicode(
'',
help="""
Additional message to display on the about page.
Will be directly inserted into the about page's source so you can use
raw HTML.
""",
config=True
)

extra_footer_scripts = Dict(
{},
help="""
Expand Down Expand Up @@ -123,8 +134,8 @@ def _valid_base_url(self, proposal):

auth_enabled = Bool(
False,
help="""If JupyterHub authentication enabled,
require user to login (don't create temporary users during launch) and
help="""If JupyterHub authentication enabled,
require user to login (don't create temporary users during launch) and
start the new server for the logged in user.""",
config=True)

Expand Down Expand Up @@ -489,6 +500,7 @@ def initialize(self, *args, **kwargs):
'traitlets_config': self.config,
'google_analytics_code': self.google_analytics_code,
'google_analytics_domain': self.google_analytics_domain,
'about_message': self.about_message,
'extra_footer_scripts': self.extra_footer_scripts,
'jinja2_env': jinja_env,
'build_memory_limit': self.build_memory_limit,
Expand Down Expand Up @@ -533,6 +545,7 @@ def initialize(self, *args, **kwargs):
(r'/(favicon\_building\.ico)',
tornado.web.StaticFileHandler,
{'path': os.path.join(self.tornado_settings['static_path'], 'images')}),
(r'/about', AboutHandler),
(r'/', MainHandler),
(r'.*', Custom404),
]
Expand Down
17 changes: 17 additions & 0 deletions binderhub/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from tornado import web
from jupyterhub.services.auth import HubOAuthenticated, HubOAuth

from ._version import __version__ as binder_version


class BaseHandler(HubOAuthenticated, web.RequestHandler):
"""HubAuthenticated by default allows all successfully identified users (see allow_all property)."""
Expand Down Expand Up @@ -87,3 +89,18 @@ class Custom404(BaseHandler):

def prepare(self):
raise web.HTTPError(404)


class AboutHandler(BaseHandler):
"""Serve the about page"""
async def get(self):
self.render_template(
"about.html",
base_url=self.settings['base_url'],
submit=False,
binder_version=binder_version,
message=self.settings['about_message'],
google_analytics_code=self.settings['google_analytics_code'],
google_analytics_domain=self.settings['google_analytics_domain'],
extra_footer_scripts=self.settings['extra_footer_scripts'],
)
27 changes: 27 additions & 0 deletions binderhub/templates/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{% extends "page.html" %}


{% block main %}
<div id="main" class="container">
<div class="row">
<h4 class="text-center logo-subtext">(beta)</h4>
<div class="col-lg-10 col-lg-offset-1">
{% block header %}
<div id="header" class="text-center">
<h3>BinderHub</h3>
<div id="explanation">
<p>This website is powered by <a href="https://github.com/jupyterhub/binderhub">BinderHub</a> v{{ binder_version }}.
</p>
<p>
{{ message | safe }}
</p>
</div>
</div>
{% endblock header %}
</div>
</div>
</div>
{% endblock main %}

{% block footer %}
{% endblock footer %}
13 changes: 13 additions & 0 deletions doc/customizing.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Customizing your BinderHub deployment
=====================================

JupyterHub customization
------------------------

Because BinderHub uses JupyterHub to manage all user sessions, you can
customize many aspects of the resources available to the user. This is
primarily done by modifications to your BinderHub's Helm chart (``config.yaml``).
Expand All @@ -18,3 +21,13 @@ For example, see `this section of the mybinder.org Helm Chart
For information on how to configure your JupyterHub deployment, see the
`JupyterHub for Kubernetes Customization Guide
<https://zero-to-jupyterhub.readthedocs.io/en/latest/#customization-guide>`_.


About page customization
------------------------

BinderHub serves a simple about page at ``https://BINDERHOST/about``. By default
this shows the version of BinderHub you are running. You can add additional
HTML to the page by setting the ``c.BinderHub.about_message`` configuration
option to the raw HTML you would like to add. You can use this to display
contact information or other details about your deployment.
2 changes: 2 additions & 0 deletions testing/localonly/binderhub_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
c.BinderHub.builder_required = False
c.BinderHub.repo_providers = {'gh': FakeProvider}
c.BinderHub.tornado_settings.update({'fake_build':True})

c.BinderHub.about_message = "<blink>Hello world.</blink>"

0 comments on commit 6bb3257

Please sign in to comment.