Skip to content

Commit

Permalink
Merge branch 'release/0.7.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
Hayley van Waas committed May 8, 2018
2 parents 1ff1295 + 2542cf4 commit 6a7ea8c
Show file tree
Hide file tree
Showing 71 changed files with 424 additions and 294 deletions.
4 changes: 3 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ markdown:
Example Paragraph
{panel type="example" title="Example Panel"}
{panel type="example"}
# Example Panel
{image file-path="http://placehold.it/350x150" caption="Example Image"}
Expand Down
14 changes: 14 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
Changelog
#######################################

0.7.4
=======================================

- Modify :doc:`processors/interactive` processor to use ``slug`` rather than ``name`` to identify interactives
- Modify :doc:`processors/video` processor template for youtube videos
- Modify :doc:`processors/boxed-text` processor to have optional type parameter
- Update style error message to inclue line numbers
- Dependency updates:

- Update ``python-slugify`` to 1.2.5.
- Update ``setuptools`` to 39.1.0.
- Update ``sphinx`` to 1.6.6.
- Update ``sphinx_rtx_theme`` to 0.3.0.

0.7.3
=======================================

Expand Down
24 changes: 14 additions & 10 deletions docs/source/processors/interactive.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ You can include an interactive using the following text tag:
Required Tag Parameters
***************************************

- ``name`` - The name to the interactive to include/link to.
- ``slug`` - The slug to the interactive to include/link to.
This slug is added to the list of interactives in ``required_files``.
- ``type`` - Sets the way the interactive is included in the page. Must be set
to one of the following values:

Expand All @@ -33,27 +34,30 @@ Required Tag Parameters
page).
- ``whole-page`` - Creates a link to the interactive displayed on a
separate page (this is the preferred method for including an interactive
on a separate page). The link shows a thumbnail of the interactive with
text (the text is set using the ``text`` parameter).
on a separate page).
The link shows a thumbnail of the interactive with text (the text is set using the
``text`` parameter).
By default, the thumbnail should be a ``thumbnail.png`` file found
within the interactive's img folder.
- ``iframe`` - The interactive is included in the page by embedding using
an iframe. This is used if the interactive is included multiple times on
an iframe.
This is used if the interactive is included multiple times on
the page to avoid conflicts in JavaScript/CSS.

Optional Tag Parameters
***************************************

- ``text`` (used with ``whole-page`` value) - Sets the text for the interactive
link. If no text is given, the link uses the text ``Click to load
{{ name }}``.
{{ slug }}``.
- ``parameters`` (used with ``whole-page`` and ``iframe`` values) - Adds the parameters
to interactive link. For example: ``digits=5&start=BBBBB``. Do not include
the ``?`` at the start, as this is already included in the output.
to interactive link.
For example: ``digits=5&start=BBBBB``.
Do not include the ``?`` at the start, as this is already included in the output.
- ``thumbnail`` (optional - used with ``whole-page`` value) - Displays an
alternative thumbnail for the interactive. When not provided, it defaults to
``interactives/interactive-name/img/thumbnail.png``, where ``interactive-name`` is the
value given for the ``name`` tag parameter (see above).
``interactives/interactive-slug/img/thumbnail.png``, where ``interactive-slug`` is the
value given for the ``slug`` tag parameter (see above).

- If the ``thumbnail`` value provided is a relative link (a link that
doesn't start with ``http:``), the link will be rendered with a Django
Expand Down Expand Up @@ -124,7 +128,7 @@ Overriding HTML for Interactives
When overriding the HTML for interactives, the following Jinja2 placeholders are available:

- ``{{ type }}`` - The type of the interactive.
- ``{{ name }}`` - The slug name of the interactive to include/link to.
- ``{{ slug }}`` - The slug of the interactive to include/link to.
- ``{{ text }}`` - The text to to display to a link to a ``whole-page``
interactive.
- ``{{ parameters }}`` - GET parameters to append to the interactive link.
Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Required dependencies for Verto (installed automatically in setup.py)
markdown==2.6.11
Jinja2==2.10
python-slugify==1.2.4
setuptools==38.4.0
python-slugify==1.2.5
setuptools==39.1.0

# Required dependencies for building documentation
sphinx==1.6.6
sphinx_rtd_theme==0.2.4
sphinx==1.7.4
sphinx_rtd_theme==0.3.0
2 changes: 1 addition & 1 deletion verto/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# flake8: noqa
from .Verto import Verto

__version__ = '0.7.3'
__version__ = '0.7.4'
17 changes: 17 additions & 0 deletions verto/errors/StyleError.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
from verto.errors.Error import Error

MESSAGE_TEMPLATE = '''{}
The error occured in the following line(s):
{}
'''


class StyleError(Error):
'''Exception raised when a Style rule is broken.
Expand All @@ -15,3 +20,15 @@ def __init__(self, line_nums, lines, message):
self.line_nums = line_nums
self.lines = lines
self.message = message

def __str__(self):
'''Overried default error string.
Returns:
Error message for incorrect style, including offending lines.
'''
error_lines = ''
for index, line in enumerate(self.lines):
error_lines += '{}: {}\n'.format(self.line_nums[index], line)
return MESSAGE_TEMPLATE.format(self.message, error_lines)
2 changes: 1 addition & 1 deletion verto/html-templates/boxed-text.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class='boxed-text{% if indented %} boxed-text-indented{% endif %}'>
<div class='boxed-text{% if indented %} boxed-text-indented{% endif %}{% if type %} boxed-text-{{ type }}{% endif %}'>
{% autoescape false -%}
{{ text }}
{% endautoescape -%}
Expand Down
8 changes: 4 additions & 4 deletions verto/html-templates/interactive.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{%- if type == 'in-page' -%}
<remove>
{{ "{% include 'interactive/" }}{{ name }}{{ "/index.html' %}" }}
{{ "{% include 'interactive/" }}{{ slug }}{{ "/index.html' %}" }}
</remove>
{% elif type == 'iframe' -%}
<iframe src="{{ "{% url 'interactive' name='" }}{{ name }}{{ "' %}" }}{% if parameters %}?{{ parameters }}{% endif %}">
<iframe src="{{ "{% url 'interactive' slug='" }}{{ slug }}{{ "' %}" }}{% if parameters %}?{{ parameters }}{% endif %}">
<p>Your browser does not support iframes.</p>
</iframe>
{% elif type == 'whole-page' -%}
<a
href="{{ "{% url 'interactive' name='" }}{{ name }}{{ "' %}" }}{% if parameters %}?{{ parameters }}{% endif %}"
href="{{ "{% url 'interactive' slug='" }}{{ slug }}{{ "' %}" }}{% if parameters %}?{{ parameters }}{% endif %}"
class="btn btn-interactive-link">
<img class="btn-interactive-link-image"
{% if thumbnail_file_relative %}
Expand All @@ -22,7 +22,7 @@
{% if text -%}
{{ text }}
{% else -%}
Click to load {{ name }}
Click to load {{ slug }}
{% endif -%}
</div>
</a>
Expand Down
2 changes: 1 addition & 1 deletion verto/html-templates/video-youtube.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://www.youtube.com/embed/{{ identifier }}?rel=0
https://www.youtube.com/embed/{{ identifier }}
14 changes: 11 additions & 3 deletions verto/processor-info.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"required": false,
"dependencies": [],
"values": ["yes", "no"]
},
"type": {
"required": false,
"dependencies": []
}
},
"template_name": "boxed-text",
Expand All @@ -17,6 +21,10 @@
"text": {
"argument": "content",
"transform": null
},
"type": {
"argument": "type",
"transform": "str.lower"
}
}
},
Expand Down Expand Up @@ -305,7 +313,7 @@
"interactive": {
"class": "custom",
"arguments": {
"name": {
"slug": {
"required": true,
"dependencies": []
},
Expand All @@ -331,8 +339,8 @@
"type": {
"argument": "type"
},
"name": {
"argument": "name"
"slug": {
"argument": "slug"
},
"text": {
"argument": "text"
Expand Down
10 changes: 5 additions & 5 deletions verto/processors/InteractiveBlockProcessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class InteractiveBlockProcessor(GenericTagBlockProcessor):
'''Searches a Document for interactive tags:
e.g. {interactive name='example' type='in-page'}
e.g. {interactive slug='example' type='in-page'}
These are then replaced with the html template.
'''

Expand All @@ -29,21 +29,21 @@ def custom_parsing(self, argument_values):
'''
extra_args = {}
interactive_type = argument_values['type']
name = argument_values['name']
slug = argument_values['slug']

# add to list of interactives
self.required_interactives.add(name)
self.required_interactives.add(slug)

if interactive_type == 'in-page':
self.scripts.add('interactive/{}/scripts.html'.format(name))
self.scripts.add('interactive/{}/scripts.html'.format(slug))
elif interactive_type == 'whole-page':
argument = 'thumbnail'
thumbnail_file_path = argument_values.get(argument, None)

if thumbnail_file_path is not None:
del argument_values[argument]
else:
thumbnail_file_path = 'interactives/{}/img/thumbnail.png'.format(name)
thumbnail_file_path = 'interactives/{}/img/thumbnail.png'.format(slug)

external_path_match = re.search(r'^http', thumbnail_file_path)
if external_path_match is None: # internal image
Expand Down
27 changes: 27 additions & 0 deletions verto/tests/BoxedTextTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ def test_single_boxed_text(self):
expected_string = self.read_test_file(self.processor_name, 'single_boxed_text_expected.html', strip=True)
self.assertEqual(expected_string, converted_test_string)

def test_boxed_text_type(self):
'''Tests that, when specified, type is added to class
'''
test_string = self.read_test_file(self.processor_name, 'boxed_text_type.md')
blocks = self.to_blocks(test_string)

self.assertListEqual([True, False, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string))

converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension])
expected_string = self.read_test_file(self.processor_name, 'boxed_text_type_expected.html', strip=True)
self.assertEqual(expected_string, converted_test_string)


def test_indented_boxed_text(self):
'''Tests that the indented argument works as appropriate.
'''
Expand All @@ -61,6 +74,18 @@ def test_indented_boxed_text(self):
expected_string = self.read_test_file(self.processor_name, 'indented_boxed_text_expected.html', strip=True)
self.assertEqual(expected_string, converted_test_string)

def test_indented_and_type_boxed_text(self):
'''Tests that the indented and type arguments work as expected when both used.
'''
test_string = self.read_test_file(self.processor_name, 'indented_type_boxed_text.md')
blocks = self.to_blocks(test_string)

self.assertListEqual([True, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string))

converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension])
expected_string = self.read_test_file(self.processor_name, 'indented_type_boxed_text_expected.html', strip=True)
self.assertEqual(expected_string, converted_test_string)

def test_multiple_boxed_text(self):
'''Tests that multiple different matches (that are not
within others) are matched and processed correctly.
Expand Down Expand Up @@ -88,6 +113,8 @@ def test_recursive_boxed_text(self):
expected_string = self.read_test_file(self.processor_name, 'recursive_boxed_text_expected.html', strip=True)
self.assertEqual(expected_string, converted_test_string)



#~
# Doc Tests
#~
Expand Down
Loading

0 comments on commit 6a7ea8c

Please sign in to comment.