Skip to content
Permalink
Browse files
Merge branch 'master' into category_destpath_names_compat_for_follow
  • Loading branch information
Kwpolska committed May 10, 2018
2 parents 1eb1e12 + 4e2a8e0 commit 2ca685cab9bc83c7979ed8fa5dd08788e3f2d09d
@@ -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)
@@ -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)

@@ -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>"""

@@ -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:
@@ -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,
@@ -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
@@ -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:
@@ -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 = [
@@ -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):

0 comments on commit 2ca685c

Please sign in to comment.