-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
389ff9c
commit cb55a13
Showing
6 changed files
with
124 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,40 @@ | ||
# sphinxcontrib-panopto | ||
A Sphinx extension for embedding Panopto videos | ||
This module defines a directive, `ggb`. It takes a single, required | ||
argument, a geogebra tube ID:: | ||
|
||
.. ggb:: 1264951 | ||
|
||
The referenced geogebra applet will be embedded into HTML output. | ||
Installation | ||
============ | ||
1. Install this extension: | ||
|
||
python setup.py build | ||
sudo python setup.py install OR python setup.py install --user | ||
|
||
2. Move 'layout.html' to your '_templates' directory | ||
(if there is already a custom layout file then copy lines 2-7 of | ||
'layout.html' and paste to that file). | ||
|
||
3. Add 'ggbextension.ggb' to your extensions in 'conf.py' | ||
|
||
Options | ||
======= | ||
|
||
There are 5 optional parameters. | ||
"width" and "height" are the applet width and height, the defaults are 700 px width and 400 px height. | ||
|
||
"img" is the location of an image file to be put in place of the applet into latex output, relative to the _build/latex folder (or wherever the generated latex output ends up). If the img parameter is not listed no image is included in the output. | ||
|
||
"imgwidth" is the width of that image, default value is 8cm. | ||
|
||
|
||
"zoom_drag" (default setting: false) to control whether the user can drag the applet image around and zoom in and out. | ||
|
||
.. ggb:: 1264951 | ||
:width: 846 | ||
:height: 664 | ||
:img: ../../_static/hi_logo.jpg | ||
:imgwidth: 4cm | ||
:zoom_drag: true |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__import__("pkg_resources").declare_namespace(__name__) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
from docutils import nodes | ||
from docutils.parsers.rst import directives | ||
|
||
try: | ||
from sphinx.util.compat import Directive | ||
except ImportError: | ||
from docutils.parsers.rst import Directive | ||
|
||
|
||
class panopto(nodes.General, nodes.Element): | ||
pass | ||
|
||
|
||
def html_visit_panopto_node(self, node): | ||
self.body.append("<figure>") | ||
self.body.append( | ||
"<iframe src='https://rec.hi.is/Panopto/Pages/Embed.aspx?id=" | ||
+ node["id"] | ||
+ "' width=" | ||
+ node["width"] | ||
+ " height=" | ||
+ node["height"] | ||
+ " style=padding: 0px; border: 1px solid #464646; frameborder='0'>" | ||
) | ||
self.body.append("</iframe>") | ||
self.body.append("</figure>") | ||
|
||
|
||
def tex_visit_panopto_node(self, node): | ||
if node["img"] != None: | ||
self.body.append("\n\n") | ||
self.body.append("\\begin{center}\n") | ||
self.body.append( | ||
"\\includegraphics[width=" | ||
+ node["imgwidth"] | ||
+ ",keepaspectratio=true]{" | ||
+ node["img"] | ||
+ "}\n" | ||
) | ||
self.body.append("\\end{center}") | ||
self.body.append("\n\n") | ||
|
||
|
||
def html_depart_panopto_node(self, node): | ||
pass | ||
|
||
|
||
def tex_depart_panopto_node(self, node): | ||
pass | ||
|
||
|
||
class PANOPTO(Directive): | ||
has_content = True | ||
required_arguments = 1 | ||
optional_arguments = 2 | ||
final_argument_whitespace = False | ||
option_spec = { | ||
"width": directives.unchanged, | ||
"height": directives.unchanged, | ||
} | ||
|
||
def run(self): | ||
node = panopto() | ||
node["id"] = self.arguments[0] | ||
node["width"] = self.options.get("width", "700") | ||
node["height"] = self.options.get("height", "400") | ||
|
||
return [node] | ||
|
||
|
||
def setup(app): | ||
app.add_node( | ||
panopto, | ||
html=(html_visit_panopto_node, html_depart_panopto_node), | ||
latex=(tex_visit_panopto_node, tex_depart_panopto_node), | ||
) | ||
app.add_directive("panopto", PANOPTO) |