diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 345e9483..8a88d638 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -1,6 +1,15 @@ Changelog ####################################### +0.10.0 +======================================= + +- Add title parameter to :doc:`processors/video` processor for translations. +- Dependency updates: + + - Update ``setuptools`` to 40.4.3 + - Update ``sphinx`` to 1.8.1 + 0.9.3 ======================================= - Resolve issues of broken package due to unpinned dependencies. @@ -8,10 +17,12 @@ Changelog 0.9.2 ======================================= + - Broken release, removed from PyPI. 0.9.1 ======================================= + - Broken release, removed from PyPI. 0.9.0 diff --git a/docs/source/contributing.rst b/docs/source/contributing.rst index 08a63e77..042de057 100644 --- a/docs/source/contributing.rst +++ b/docs/source/contributing.rst @@ -395,7 +395,7 @@ Other notes ======================================= Why are requirements split across two files? -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The ``requirements.txt`` file is used to specify required dependencies for Verto (and are automatically installed as dependencies when installed via ``pip``). The ``requirements-dev.txt`` file is used to specify dependencies for developing Verto (for example, documentation generators). diff --git a/docs/source/processors/video.rst b/docs/source/processors/video.rst index 940674cf..c4e01c34 100644 --- a/docs/source/processors/video.rst +++ b/docs/source/processors/video.rst @@ -24,6 +24,12 @@ Required Tag Parameters - ``https://vimeo.com/94502406`` - Standard URL - ``https://player.vimeo.com/video/94502406``- Embed URL +Optional Tag Parameters +*************************************** + +- ``title`` - The title text for the video. + + The default HTML for a video is: .. literalinclude:: ../../../verto/html-templates/video.html @@ -57,6 +63,7 @@ Overriding HTML for Videos When overriding the HTML for videos, the following Jinja2 placeholders are available: - ``{{ video_url }}`` - The URL of the video to be embedded. +- ``{{ title }}`` - The title of the video. In the ``video-youtube.html``, the following Jinja2 placeholders are available: diff --git a/requirements-dev.txt b/requirements-dev.txt index 8c33440b..1db56498 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,5 @@ -setuptools==40.2.0 -sphinx==1.8.0 +setuptools==40.4.3 +sphinx==1.8.1 sphinx_rtd_theme==0.4.1 coverage==4.5.1 flake8==3.5.0 diff --git a/verto/__init__.py b/verto/__init__.py index eb08a914..063e653b 100644 --- a/verto/__init__.py +++ b/verto/__init__.py @@ -1,4 +1,4 @@ # flake8: noqa from .Verto import Verto -__version__ = '0.9.3' +__version__ = '0.10.0' diff --git a/verto/html-templates/video.html b/verto/html-templates/video.html index 88f11eff..3ec11b90 100644 --- a/verto/html-templates/video.html +++ b/verto/html-templates/video.html @@ -1,3 +1,6 @@
+{% if title %} +
{{ title }}
+{% endif %}
diff --git a/verto/processor-info.json b/verto/processor-info.json index 7251cad1..ec7fce7c 100644 --- a/verto/processor-info.json +++ b/verto/processor-info.json @@ -509,6 +509,14 @@ "arguments": { "url": { "required": true + }, + "title": { + "required": false + } + }, + "template_parameters": { + "title": { + "argument": "title" } } } diff --git a/verto/processors/VideoBlockProcessor.py b/verto/processors/VideoBlockProcessor.py index 7706388c..e60d4c76 100644 --- a/verto/processors/VideoBlockProcessor.py +++ b/verto/processors/VideoBlockProcessor.py @@ -64,7 +64,7 @@ def run(self, parent, blocks): if not identifier: raise NoVideoIdentifierError(block, url, 'missing video identifier') - context = dict() + context = self.process_parameters(self.processor, self.template_parameters, argument_values) context['identifier'] = identifier context['video_url'] = '' diff --git a/verto/tests/VideoTest.py b/verto/tests/VideoTest.py index 33827513..8c499fc0 100644 --- a/verto/tests/VideoTest.py +++ b/verto/tests/VideoTest.py @@ -3,6 +3,7 @@ from verto.VertoExtension import VertoExtension from verto.processors.VideoBlockProcessor import VideoBlockProcessor +from verto.errors.ArgumentMissingError import ArgumentMissingError from verto.errors.NoVideoIdentifierError import NoVideoIdentifierError from verto.errors.UnsupportedVideoPlayerError import UnsupportedVideoPlayerError from verto.tests.ProcessorTest import ProcessorTest @@ -173,6 +174,18 @@ def test_contains_multiple_videos(self): expected_file_string = self.read_test_file(self.processor_name, 'contains_multiple_videos_expected.html', strip=True) self.assertEqual(converted_test_string, expected_file_string) + def test_contains_title(self): + '''Tests output for video with title. + ''' + test_string = self.read_test_file(self.processor_name, 'contains_title.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True], [VideoBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) + expected_file_string = self.read_test_file(self.processor_name, 'contains_title_expected.html', strip=True) + self.assertEqual(converted_test_string, expected_file_string) + def test_url_false_custom_argument_rules(self): '''Tests to ensure that video tag is rendered correctly when url argument is not required. ''' @@ -195,6 +208,27 @@ def test_url_false_custom_argument_rules(self): expected_string = self.read_test_file(self.processor_name, 'url_false_expected.html', strip=True) self.assertEqual(expected_string, converted_test_string) + def test_custom_argument_rules_title_true_not_provided(self): + '''Tests to ensure that error is raised when title argument is required but not provided. + ''' + custom_argument_rules = { + "video": { + "title": True + } + } + verto_extension_custom_rules = VertoExtension( + processors=[self.processor_name], + custom_argument_rules=custom_argument_rules + ) + + test_string = self.read_test_file(self.processor_name, 'title_true_not_provided.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True], [VideoBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + self.assertRaises(ArgumentMissingError, lambda x: markdown.markdown(x, extensions=[verto_extension_custom_rules]), test_string) + + # ~ # Doc Tests # ~ diff --git a/verto/tests/assets/video/contains_title.md b/verto/tests/assets/video/contains_title.md new file mode 100644 index 00000000..c4b915de --- /dev/null +++ b/verto/tests/assets/video/contains_title.md @@ -0,0 +1 @@ +{video url="https://vimeo.com/94502406" title="this is the video title"} diff --git a/verto/tests/assets/video/contains_title_expected.html b/verto/tests/assets/video/contains_title_expected.html new file mode 100644 index 00000000..666ba725 --- /dev/null +++ b/verto/tests/assets/video/contains_title_expected.html @@ -0,0 +1,4 @@ +
+
this is the video title
+ +
diff --git a/verto/tests/assets/video/title_true_not_provided.md b/verto/tests/assets/video/title_true_not_provided.md new file mode 100644 index 00000000..2a0e3c25 --- /dev/null +++ b/verto/tests/assets/video/title_true_not_provided.md @@ -0,0 +1 @@ +{video url="https://vimeo.com/94502406"}