[Bf-docboard-svn] bf-manual: [8205] trunk/blender_docs: Peertube: Add the ability to set a default and override instance
Aaron Carlisle
noreply at blender.org
Sat Jul 17 17:02:25 CEST 2021
Revision: 8205
https://developer.blender.org/rBM8205
Author: Blendify
Date: 2021-07-17 17:02:24 +0200 (Sat, 17 Jul 2021)
Log Message:
-----------
Peertube: Add the ability to set a default and override instance
Not so much useful for us but it is useful for other who might want to use our extension
Modified Paths:
--------------
trunk/blender_docs/exts/peertube.py
trunk/blender_docs/manual/conf.py
Modified: trunk/blender_docs/exts/peertube.py
===================================================================
--- trunk/blender_docs/exts/peertube.py 2021-07-17 01:25:27 UTC (rev 8204)
+++ trunk/blender_docs/exts/peertube.py 2021-07-17 15:02:24 UTC (rev 8205)
@@ -4,7 +4,12 @@
import re
from docutils import nodes
from docutils.parsers.rst import directives, Directive
+from sphinx.environment import BuildEnvironment
+from sphinx.locale import __
+from sphinx.util import logging
+logger = logging.getLogger(__name__)
+
CONTROL_HEIGHT = 30
def get_size(d, key):
@@ -21,10 +26,18 @@
class peertube(nodes.General, nodes.Element): pass
def visit_peertube_node(self, node):
+ instance = node["instance"]
aspect = node["aspect"]
width = node["width"]
height = node["height"]
+ if not (self.config.peertube_instance or instance):
+ logger.warning(__("No peertube instance defined"))
+ return
+
+ if instance is None:
+ instance = self.config.peertube_instance
+
if aspect is None:
aspect = 16, 9
@@ -45,7 +58,7 @@
"border": "0",
}
attrs = {
- "src": "<https://video.blender.org/videos/embed/%s" % node["id"],
+ "src": instance + "videos/embed/%s" % node["id"],
"style": css(style),
}
else:
@@ -62,7 +75,7 @@
"border": "0",
}
attrs = {
- "src": "https://video.blender.org/videos/embed/%s" % node["id"],
+ "src": instance + "videos/embed/%s" % node["id"],
"style": css(style),
}
attrs["allowfullscreen"] = "true"
@@ -77,10 +90,19 @@
def depart_peertube_node(self, node):
pass
-def visit_peertube_node_latex(self,node):
- self.body.append(r'\begin{quote}\begin{center}\fbox{\url{https://video.blender.org/videos/watch/%s}}\end{center}\end{quote}'%node['id'])
+def visit_peertube_node_latex(self, node):
+ instance = node["instance"]
+ if not (self.config.peertube_instance or instance):
+ logger.warning(__("No peertube instance defined"))
+ return
+ if instance is None:
+ instance = self.config.peertube_instance
+
+ self.body.append(r'\begin{quote}\begin{center}\fbox{\url{' + instance + r'videos/watch/%s}}\end{center}\end{quote}'%node['id'])
+
+
class PeerTube(Directive):
has_content = True
required_arguments = 1
@@ -87,6 +109,7 @@
optional_arguments = 0
final_argument_whitespace = False
option_spec = {
+ "instance": directives.unchanged,
"width": directives.unchanged,
"height": directives.unchanged,
"aspect": directives.unchanged,
@@ -93,6 +116,7 @@
}
def run(self):
+ instance = self.options.get("instance")
if "aspect" in self.options:
aspect = self.options.get("aspect")
m = re.match("(\d+):(\d+)", aspect)
@@ -103,7 +127,7 @@
aspect = None
width = get_size(self.options, "width")
height = get_size(self.options, "height")
- return [peertube(id=self.arguments[0], aspect=aspect, width=width, height=height)]
+ return [peertube(id=self.arguments[0], instance=instance, aspect=aspect, width=width, height=height)]
def unsupported_visit_peertube(self, node):
@@ -123,6 +147,7 @@
def setup(app):
app.add_node(peertube, **_NODE_VISITORS)
app.add_directive("peertube", PeerTube)
+ app.add_config_value('peertube_instance', "", True, [str])
return {
'parallel_read_safe': True,
'parallel_write_safe': True,
Modified: trunk/blender_docs/manual/conf.py
===================================================================
--- trunk/blender_docs/manual/conf.py 2021-07-17 01:25:27 UTC (rev 8204)
+++ trunk/blender_docs/manual/conf.py 2021-07-17 15:02:24 UTC (rev 8205)
@@ -66,6 +66,7 @@
extensions.append('sphinx.ext.imgconverter')
image_converter = "magick"
+peertube_instance = "https://video.blender.org/"
intersphinx_mapping = {'blender_api': ('https://docs.blender.org/api/' + blender_version + '/', None)}
# Add any paths that contain templates here, relative to this directory.
More information about the Bf-docboard-svn
mailing list