##// END OF EJS Templates
generic IFrame(src, with, height), refactored YouTubeVideo, VimeoVideo, ScribdDocument
Eugene Van den Bulke -
Show More
@@ -11,22 +11,32 b' class IFrame(object):'
11 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):
15 self.id = id
14 iframe = """
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 26 self.width = width
17 27 self.height = height
18 28 self.params = kwargs
19 29
20 30 def _repr_html_(self):
21 """return the embed iframe for this video id"""
31 """return the embed iframe"""
22 32 if self.params:
23 33 from urllib import urlencode
24 34 params = "?" + urlencode(self.params)
25 35 else:
26 36 params = ""
27 return self.iframe.format(width=self.width,
37 return self.iframe.format(src=self.src,
38 width=self.width,
28 39 height=self.height,
29 id=self.id,
30 40 params=params)
31 41
32 42 class YouTubeVideo(IFrame):
@@ -53,32 +63,18 b' class YouTubeVideo(IFrame):'
53 63 https://developers.google.com/youtube/player_parameters#parameter-subheader
54 64 """
55 65
56 iframe = """
57 <iframe
58 width="{width}"
59 height={height}"
60 src="http://www.youtube.com/embed/{id}{params}"
61 frameborder="0"
62 allowfullscreen
63 ></iframe>
64 """
66 def __init__(self, id, width=400, height=300, **kwargs):
67 src = "http://www.youtube.com/embed/{0}".format(id)
68 super(YouTubeVideo, self).__init__(src, width, height, **kwargs)
65 69
66 70 class VimeoVideo(IFrame):
67 71 """
68 72 Class for embedding a Vimeo video in an IPython session, based on its video id.
69 73 """
70 74
71 iframe = """
72 <iframe
73 width = "{width}"
74 height = "{height}"
75 src="http://player.vimeo.com/video/{id}{params}"
76 frameborder="0"
77 webkitAllowFullScreen
78 mozallowfullscreen
79 allowFullScreen
80 ></iframe>
81 """
75 def __init__(self, id, width=400, height=300, **kwargs):
76 src="http://player.vimeo.com/video/{0}".format(id)
77 super(VimeoVideo, self).__init__(src, width, height, **kwargs)
82 78
83 79 class ScribdDocument(IFrame):
84 80 """
@@ -92,16 +88,9 b' class ScribdDocument(IFrame):'
92 88 ScribdDocument(71048089, width=800, height=400, start_page=3, view_mode="book")
93 89 """
94 90
95 iframe = """
96 <iframe
97 width = "{width}"
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 """
91 def __init__(self, id, width=400, height=300, **kwargs):
92 src="http://www.scribd.com/embeds/{0}/content".format(id)
93 super(ScribdDocument, self).__init__(src, width, height, **kwargs)
105 94
106 95 class FileLink(object):
107 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