Skip to content

Commit

Permalink
add video embeds
Browse files Browse the repository at this point in the history
  • Loading branch information
otothea committed Jul 4, 2020
1 parent 7ef5630 commit 6ba307a
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 17 deletions.
5 changes: 5 additions & 0 deletions docs/commands/custom/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ You can create custom commands by visiting the `commands page <https://botisimo.

../default/command
../default/commands

Related Videos
^^^^^^^^^^^^^^

.. youtube:: 5j-QSMc23nk
35 changes: 19 additions & 16 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
import os
import sys
sys.path.insert(0, os.path.abspath('.'))

import sphinx_rtd_theme
import youtube

# -- Project information -----------------------------------------------------

project = 'Botisimo'
copyright = '2020, Botisimo'
author = 'Botisimo'

# -- YouTube Embed Directive -------------------------------------------------
youtube.setup()

# -- General configuration ---------------------------------------------------

Expand Down Expand Up @@ -49,30 +52,30 @@

# Theme options
html_theme_options = {
# 'typekit_id': 'hiw1hhg',
# 'analytics_id': '',
# 'sticky_navigation': True # Set to False to disable the sticky nav while scrolling.
'logo_only': True, # if we have a html_logo below, this shows /only/ the logo with no title text
'collapse_navigation': False, # Collapse navigation (False makes it tree-like)
# 'display_version': True, # Display the docs version
# 'navigation_depth': 4, # Depth of the headers shown in the navigation bar
# 'typekit_id': 'hiw1hhg',
# 'analytics_id': '',
# 'sticky_navigation': True # Set to False to disable the sticky nav while scrolling.
'logo_only': True, # if we have a html_logo below, this shows /only/ the logo with no title text
'collapse_navigation': False, # Collapse navigation (False makes it tree-like)
# 'display_version': True, # Display the docs version
# 'navigation_depth': 4, # Depth of the headers shown in the navigation bar
}

# VCS options: https://docs.readthedocs.io/en/latest/vcs.html#github
html_context = {
"display_github": True, # Integrate GitHub
"github_user": "botisimochatbot", # Username
"github_repo": "botisimo-documentation", # Repo name
"github_version": "master", # Version
"conf_py_path": "/", # Path in the checkout to the docs root
"display_github": True, # Integrate GitHub
"github_user": "botisimochatbot", # Username
"github_repo": "botisimo-documentation", # Repo name
"github_version": "master", # Version
"conf_py_path": "/", # Path in the checkout to the docs root
}

html_logo = 'images/botisimo-logo.png'

# These paths are either relative to html_static_path
# or fully qualified paths (eg. https://...)
html_css_files = [
'css/custom.css',
'css/custom.css',
]

# Add any paths that contain custom static files (such as style sheets) here,
Expand Down
2 changes: 1 addition & 1 deletion docs/directives/index.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Directives
==========

Response directives are used to make dynamic actions for your `custom commands <https://botisimo.com/account/commands>`_ and `timers <https://botisimo.com/account/timers>`_. Directives will be processed after :doc:`response variables <variables/index>` and in the order they appear in the response text.
Response directives are used to make dynamic actions for your `custom commands <https://botisimo.com/account/commands>`_ and `timers <https://botisimo.com/account/timers>`_. Directives will be processed after :doc:`response variables </variables/index>` and in the order they appear in the response text.

.. note::

Expand Down
5 changes: 5 additions & 0 deletions docs/timers/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ You can create timers by visiting the `timers page <https://botisimo.com/account
:caption: Related Commands

../commands/default/timer

Related Videos
^^^^^^^^^^^^^^

.. youtube:: 5CYHP_1KEKc
59 changes: 59 additions & 0 deletions docs/youtube.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# -- https://gist.github.com/dbrgn/2922648 -----------------------------------

# -*- coding: utf-8 -*-
"""
ReST directive for embedding Youtube and Vimeo videos.
There are two directives added: ``youtube``. The only
argument is the video id of the video to include.
Both directives have three optional arguments: ``height``, ``width``
and ``align``. Default height is 281 and default width is 500.
Example::
.. youtube:: anwy2MPT5RE
:height: 315
:width: 560
:align: left
:copyright: (c) 2012 by Danilo Bargen.
:license: BSD 3-clause
"""
from __future__ import absolute_import
from docutils import nodes
from docutils.parsers.rst import Directive, directives


def align(argument):
"""Conversion function for the "align" option."""
return directives.choice(argument, ('left', 'center', 'right'))


class IframeVideo(Directive):
has_content = False
required_arguments = 1
optional_arguments = 0
final_argument_whitespace = False
option_spec = {
'height': directives.nonnegative_int,
'width': directives.nonnegative_int,
'align': align,
}
default_width = 500
default_height = 281

def run(self):
self.options['video_id'] = directives.uri(self.arguments[0])
if not self.options.get('width'):
self.options['width'] = self.default_width
if not self.options.get('height'):
self.options['height'] = self.default_height
if not self.options.get('align'):
self.options['align'] = 'left'
return [nodes.raw('', self.html % self.options, format='html')]


class Youtube(IframeVideo):
html = '<iframe style="margin-bottom: 20px" src="http://www.youtube.com/embed/%(video_id)s" \
width="%(width)u" height="%(height)u" frameborder="0" \
webkitAllowFullScreen mozallowfullscreen allowfullscreen></iframe>'


def setup():
directives.register_directive('youtube', Youtube)

0 comments on commit 6ba307a

Please sign in to comment.