Show More
@@ -11,22 +11,32 b' class IFrame(object):' | |||||
11 | Generic class to embed an iframe in an IPython notebook |
|
11 | Generic class to embed an iframe in an IPython notebook | |
12 | """ |
|
12 | """ | |
13 |
|
13 | |||
14 | def __init__(self, id, width=400, height=300, **kwargs): |
|
14 | iframe = """ | |
15 | self.id = id |
|
15 | <iframe | |
|
16 | width="{width}" | |||
|
17 | height={height}" | |||
|
18 | src="{src}{params}" | |||
|
19 | frameborder="0" | |||
|
20 | allowfullscreen | |||
|
21 | ></iframe> | |||
|
22 | """ | |||
|
23 | ||||
|
24 | def __init__(self, src, width, height, **kwargs): | |||
|
25 | self.src = src | |||
16 | self.width = width |
|
26 | self.width = width | |
17 | self.height = height |
|
27 | self.height = height | |
18 | self.params = kwargs |
|
28 | self.params = kwargs | |
19 |
|
29 | |||
20 | def _repr_html_(self): |
|
30 | def _repr_html_(self): | |
21 |
"""return the embed iframe |
|
31 | """return the embed iframe""" | |
22 | if self.params: |
|
32 | if self.params: | |
23 | from urllib import urlencode |
|
33 | from urllib import urlencode | |
24 | params = "?" + urlencode(self.params) |
|
34 | params = "?" + urlencode(self.params) | |
25 | else: |
|
35 | else: | |
26 | params = "" |
|
36 | params = "" | |
27 |
return self.iframe.format( |
|
37 | return self.iframe.format(src=self.src, | |
|
38 | width=self.width, | |||
28 | height=self.height, |
|
39 | height=self.height, | |
29 | id=self.id, |
|
|||
30 | params=params) |
|
40 | params=params) | |
31 |
|
41 | |||
32 | class YouTubeVideo(IFrame): |
|
42 | class YouTubeVideo(IFrame): | |
@@ -53,32 +63,18 b' class YouTubeVideo(IFrame):' | |||||
53 | https://developers.google.com/youtube/player_parameters#parameter-subheader |
|
63 | https://developers.google.com/youtube/player_parameters#parameter-subheader | |
54 | """ |
|
64 | """ | |
55 |
|
65 | |||
56 | iframe = """ |
|
66 | def __init__(self, id, width=400, height=300, **kwargs): | |
57 | <iframe |
|
67 | src = "http://www.youtube.com/embed/{0}".format(id) | |
58 | width="{width}" |
|
68 | super(YouTubeVideo, self).__init__(src, width, height, **kwargs) | |
59 | height={height}" |
|
|||
60 | src="http://www.youtube.com/embed/{id}{params}" |
|
|||
61 | frameborder="0" |
|
|||
62 | allowfullscreen |
|
|||
63 | ></iframe> |
|
|||
64 | """ |
|
|||
65 |
|
69 | |||
66 | class VimeoVideo(IFrame): |
|
70 | class VimeoVideo(IFrame): | |
67 | """ |
|
71 | """ | |
68 | Class for embedding a Vimeo video in an IPython session, based on its video id. |
|
72 | Class for embedding a Vimeo video in an IPython session, based on its video id. | |
69 | """ |
|
73 | """ | |
70 |
|
74 | |||
71 | iframe = """ |
|
75 | def __init__(self, id, width=400, height=300, **kwargs): | |
72 | <iframe |
|
76 | src="http://player.vimeo.com/video/{0}".format(id) | |
73 | width = "{width}" |
|
77 | super(VimeoVideo, self).__init__(src, width, height, **kwargs) | |
74 | height = "{height}" |
|
|||
75 | src="http://player.vimeo.com/video/{id}{params}" |
|
|||
76 | frameborder="0" |
|
|||
77 | webkitAllowFullScreen |
|
|||
78 | mozallowfullscreen |
|
|||
79 | allowFullScreen |
|
|||
80 | ></iframe> |
|
|||
81 | """ |
|
|||
82 |
|
78 | |||
83 | class ScribdDocument(IFrame): |
|
79 | class ScribdDocument(IFrame): | |
84 | """ |
|
80 | """ | |
@@ -92,16 +88,9 b' class ScribdDocument(IFrame):' | |||||
92 | ScribdDocument(71048089, width=800, height=400, start_page=3, view_mode="book") |
|
88 | ScribdDocument(71048089, width=800, height=400, start_page=3, view_mode="book") | |
93 | """ |
|
89 | """ | |
94 |
|
90 | |||
95 | iframe = """ |
|
91 | def __init__(self, id, width=400, height=300, **kwargs): | |
96 | <iframe |
|
92 | src="http://www.scribd.com/embeds/{0}/content".format(id) | |
97 | width = "{width}" |
|
93 | super(ScribdDocument, self).__init__(src, width, height, **kwargs) | |
98 | height = "{height}" |
|
|||
99 | src="http://www.scribd.com/embeds/{id}/content{params}" |
|
|||
100 | data-auto-height="false" |
|
|||
101 | scrolling="no" |
|
|||
102 | frameborder="0"> |
|
|||
103 | </iframe> |
|
|||
104 | """ |
|
|||
105 |
|
94 | |||
106 | class FileLink(object): |
|
95 | class FileLink(object): | |
107 | """Class for embedding a local file link in an IPython session, based on path |
|
96 | """Class for embedding a local file link in an IPython session, based on path |
General Comments 0
You need to be logged in to leave comments.
Login now