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

adding federation page #868

Merged
merged 4 commits into from
Jul 1, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,5 @@ helm.txt
travis
helm-chart/travis-binder.yaml

# Federation data page
doc/federation/data-federation.txt
41 changes: 41 additions & 0 deletions doc/_static/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,44 @@ img.logo {
.prev-next-top {
margin-bottom: 1em;
}


/* Federation page CSS */
.contrib_entry p {
margin: 2px;
text-align: center;
}

p.contrib_affiliation {
font-size: .7em;
font-weight: bold;
}

.contribs_text {
font-size: .8em;
}

.contrib_entry p.contribs {
float: left;
margin: 0px;
}

td.contrib_entry {
width: 100px;
height: 200px;
padding: 1em !important;
vertical-align: top;
text-align: center;
}

td.contrib_entry a {
text-decoration: none;
}

td.contrib_entry img {
max-width: 120px;
}

table.contributors {
margin: 0px auto;
}
6 changes: 6 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import os.path as op
import sys
import requests
curdir = os.path.dirname(__file__)
Expand Down Expand Up @@ -209,3 +210,8 @@
# -- Add custom CSS ----------------------------------------------
def setup(app):
app.add_stylesheet('https://gitcdn.link/repo/jupyterhub/binder/master/doc/_static/custom.css')

# -- Run Federation script ----------------------------------------------
from subprocess import run
cmd = ["python", op.join('script', 'gen_federation.py')]
run(cmd)
3 changes: 3 additions & 0 deletions doc/doc-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ recommonmark==0.4.0
sphinx-copybutton
alabaster_jupyterhub
traitlets
pandas
ruamel.yaml

# install BinderHub from source but because `pip install` is executed in the
# root directory (not this directory) of this repository we write '.' here
# not '..' as you might expect when thinking relative to this file.
Expand Down
12 changes: 12 additions & 0 deletions doc/federation/data-federation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- url_binderhub: https://gke.mybinder.org
url_info: https://gke.mybinder.org/about
funded_by: Google Cloud Platform
run_by: The Binder Team
logo: https://binderhub.readthedocs.io/en/latest/_static/logo.png

- url_binderhub: https://ovh.mybinder.org
url_info: https://ovh.mybinder.org/about
funded_by: OVH
run_by: The OVH Team
logo: https://www.ovh.com/fr/images/logos/logo-ovh-twitter.jpg

14 changes: 14 additions & 0 deletions doc/federation/federation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
========================
The BinderHub Federation
========================

While it may seem like ``mybinder.org`` is a single website, it is
in fact a **federation** of teams that deploy public BinderHubs to serve
the community. This page lists the BinderHubs that currently help
power ``mybinder.org``.

Note that visiting ``mybinder.org`` will randomly redirect you to one
of the following BinderHubs. You may also directly access a BinderHub
choldgraf marked this conversation as resolved.
Show resolved Hide resolved
by using its respective sub-domain in your URL.

.. include:: data-federation.txt
1 change: 1 addition & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ in the community have done.
customizing
authentication
known-deployments
federation/federation
betatim marked this conversation as resolved.
Show resolved Hide resolved

BinderHub Developer and Architecture Documentation
==================================================
Expand Down
51 changes: 51 additions & 0 deletions doc/script/gen_federation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

"""Generate HTML binderhubs tables for team pages
"""
import pandas as pd
import os
import os.path as op
from ruamel import yaml

# Variables
N_PER_ROW = 4

# Code to generate the HTML grid
template_binderhub = '<td align="center" class="contrib_entry"><a href="{URL_BINDERHUB}"><img src="{LOGO}" class="fed_logo" alt="{RUN_BY}" /></a><br /><p class="name">{BINDERHUB_SUBDOMAIN}</p><br /><p class="name">Run by</p><p class="name"><b><a href={URL_INFO}>{RUN_BY}</a></b></p><br /><p class="name">Funded by</p><p class="name"><b>{FUNDED_BY}</b></p>'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make the "funded by" a link to the website of those that pay.


def _generate_binderhubs(binderhubs):
"""Generate an HTML list of BinderHubs, given a dataframe of their information."""
s = ['<table class="docutils binderhubs">', '<tr class="row-even">']
for ix, binderhub in binderhubs.iterrows():
if ix % N_PER_ROW == 0 and ix != 0:
s += ['</tr><tr class="row-even">']

# Add user
format_dict = dict(URL_BINDERHUB=binderhub['url_binderhub'],
BINDERHUB_SUBDOMAIN=binderhub['url_binderhub'].split('//')[-1],
LOGO=binderhub['logo'],
RUN_BY=binderhub['run_by'],
URL_INFO=binderhub['url_info'],
FUNDED_BY=binderhub['funded_by'])

# Render
s += [template_binderhub.format(**format_dict)]
s += ['</table>']
final_text = ['.. raw:: html', '']
for line in s:
final_text += [' ' + line]
final_text = '\n'.join(final_text)
return final_text


# Run the function
path_data = op.join(op.dirname(op.abspath(__file__)), '..', 'federation', 'data-federation.yml')
yaml = yaml.YAML()

with open(path_data, 'r') as ff:
data = yaml.load(ff)

binderhubs = pd.DataFrame(data)
table = _generate_binderhubs(binderhubs)
new_name = os.path.splitext(path_data)[0]
with open(new_name+'.txt', 'w') as ff:
ff.write(table)