-
Notifications
You must be signed in to change notification settings - Fork 2
/
talktools.py
39 lines (26 loc) · 996 Bytes
/
talktools.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""Tools to style a talk."""
from IPython.display import HTML, display, YouTubeVideo
def prefix(url):
prefix = '' if url.startswith('http') else 'http://'
return prefix + url
def simple_link(url, name=None):
name = url if name is None else name
url = prefix(url)
return '<a href="%s" target="_blank">%s</a>' % (url, name)
def html_link(url, name=None):
return HTML(simple_link(url, name))
# Utility functions
def website(url, name=None, width=800, height=450):
html = []
if name:
html.extend(['<div class="nb_link">',
simple_link(url, name),
'</div>'] )
html.append('<iframe src="%s" width="%s" height="%s">' %
(prefix(url), width, height))
return HTML('\n'.join(html))
def nbviewer(url, name=None, width=800, height=450):
return website('nbviewer.ipython.org/url/' + url, name, width, height)
# Load and publish CSS
style = HTML(open('style.css').read())
display(style)