Skip to content

Commit

Permalink
Merge branch 'master' into category_destpath_names_compat_for_follow
Browse files Browse the repository at this point in the history
  • Loading branch information
Kwpolska committed May 10, 2018
2 parents 1eb1e12 + 4e2a8e0 commit 2ca685c
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGES.txt
Expand Up @@ -6,9 +6,14 @@ Changes since v8 Beta 1
Features
--------

* Use youtube-nocookie.com for better privacy in ``youtube`` reST
directive and improve the appearance of the player

Bugfixes
--------

* Make ``smartjoin`` more flexible (Issue #3080)
* Make post-list and post_list synonymous (Issue #3083)
* Support ``CATEGORY_DESTPATH_NAMES`` with pages following destpath
* Make ``CATEGORY_PAGES_FOLLOW_DESTPATH`` more resilient (Issue #3081)
* Guard against null items in gallery meta files (Issues #3076, #3077)
Expand Down
1 change: 1 addition & 0 deletions nikola/plugins/compile/rest/post_list.py
Expand Up @@ -46,6 +46,7 @@ def set_site(self, site):
"""Set Nikola site."""
self.site = site
directives.register_directive('post-list', PostListDirective)
directives.register_directive('post_list', PostListDirective)
PostListDirective.site = site
return super(Plugin, self).set_site(site)

Expand Down
7 changes: 4 additions & 3 deletions nikola/plugins/compile/rest/youtube.py
Expand Up @@ -48,7 +48,8 @@ def set_site(self, site):
CODE = """\
<div class="youtube-video{align}">
<iframe width="{width}" height="{height}"
src="https://www.youtube.com/embed/{yid}?rel=0&amp;hd=1&amp;wmode=transparent"
src="https://www.youtube-nocookie.com/embed/{yid}?rel=0&wmode=transparent"
frameborder="0" allow="encrypted-media" allowfullscreen
></iframe>
</div>"""

Expand Down Expand Up @@ -76,8 +77,8 @@ def run(self):
self.check_content()
options = {
'yid': self.arguments[0],
'width': 425,
'height': 344,
'width': 560,
'height': 315,
}
options.update(self.options)
if self.options.get('align') in _align_options_base:
Expand Down
5 changes: 5 additions & 0 deletions nikola/plugins/shortcode/post_list.py
Expand Up @@ -120,6 +120,11 @@ class PostListShortcode(ShortcodePlugin):

name = "post_list"

def set_site(self, site):
"""Set the site."""
super(PostListShortcode, self).set_site(site)
site.register_shortcode('post-list', self.handler)

def handler(self, start=None, stop=None, reverse=False, tags=None, require_all_tags=False, categories=None,
sections=None, slugs=None, post_type='post', type=False,
lang=None, template='post_list_directive.tmpl', sort=None,
Expand Down
10 changes: 7 additions & 3 deletions nikola/utils.py
Expand Up @@ -69,7 +69,7 @@
husl = None

from blinker import signal
from collections import defaultdict, Callable, OrderedDict
from collections import defaultdict, Callable, OrderedDict, Iterable
from importlib import reload as _reload
from logbook.compat import redirect_logging
from logbook.more import ExceptionHandler, ColorizedStderrHandler
Expand Down Expand Up @@ -1870,17 +1870,21 @@ def sort_posts(posts, *keys):


def smartjoin(join_char: str, string_or_iterable) -> str:
"""Join string_or_iterable with join_char if it is not a string already.
"""Join string_or_iterable with join_char if it is iterable; otherwise converts it to string.
>>> smartjoin('; ', 'foo, bar')
'foo, bar'
>>> smartjoin('; ', ['foo', 'bar'])
'foo; bar'
>>> smartjoin(' to ', ['count', 42])
'count to 42'
"""
if isinstance(string_or_iterable, (unicode_str, bytes_str)):
return string_or_iterable
elif isinstance(string_or_iterable, Iterable):
return join_char.join([str(e) for e in string_or_iterable])
else:
return join_char.join(string_or_iterable)
return str(string_or_iterable)


def _smartjoin_filter(string_or_iterable, join_char: str) -> str:
Expand Down
2 changes: 2 additions & 0 deletions scripts/jinjify.py
Expand Up @@ -26,6 +26,8 @@
['sorted(translations)', 'translations|sort'],
['abs(i - current_page)', '(i - current_page)|abs'],
['loop.index', 'loop.index0'],
['is None', 'is none'],
['is not None', 'is not none'],
]

dumber_replacements = [
Expand Down
8 changes: 5 additions & 3 deletions tests/test_rst_compiler.py
Expand Up @@ -170,10 +170,12 @@ def test_youtube(self):
""" Test Youtube iframe tag generation """
self.basic_test()
self.assertHTMLContains("iframe",
attributes={"src": ("https://www.youtube.com/"
"embed/YID?rel=0&hd=1&"
attributes={"src": ("https://www.youtube-nocookie.com/"
"embed/YID?rel=0&"
"wmode=transparent"),
"height": "400", "width": "600"})
"height": "400", "width": "600",
"frameborder": "0", "allowfullscreen": "",
"allow": "encrypted-media"})


class ListingTestCase(ReSTExtensionTestCase):
Expand Down

0 comments on commit 2ca685c

Please sign in to comment.