Skip to content
Permalink
Browse files
Merge branch 'master' into exif-edit
  • Loading branch information
ralsina committed Apr 24, 2016
2 parents 40a2e70 + 7afd9c1 commit 831fa61652573b47e42a3425ad9920fa85e6fc73
Showing with 31 additions and 237 deletions.
  1. +1 −1 .travis.yml
  2. +2 −1 CHANGES.txt
  3. +2 −7 nikola/nikola.py
  4. +21 −134 nikola/plugins/compile/markdown/mdx_gist.py
  5. +1 −1 requirements-tests.txt
  6. +4 −0 setup.cfg
  7. +0 −43 tests/test_compile_markdown.py
  8. +0 −50 tests/test_rst_compiler.py
@@ -31,7 +31,7 @@ install:
# WARNING: if you edit this, make sure to replicate your changes in dodo.py and appveyor.yml.
script:
- "if [[ $NMODE == 'nikola' ]]; then py.test --doctest-modules nikola/; fi"
- "if [[ $NMODE == 'nikola' ]]; then py.test --cov nikola --cov-report term-missing tests/; fi"
- "if [[ $NMODE == 'nikola' ]]; then py.test tests/; fi"
- "if [[ $NMODE == 'nikola' ]]; then nikola; fi"
- "if [[ $NMODE == 'nikola' ]]; then nikola help; fi"
- "if [[ $NMODE == 'flake8' ]]; then flake8 nikola/; fi"
@@ -11,7 +11,8 @@ Features
Bugfixes
--------

* Warn if a tag appears multiple times in a post (Issue #2315)
* Show “tags too similar” error instead of cryptic doit crash (Issue #2325)
* Fix crashes when tag appears multiple times in a post (Issue #2315)
* Use binary I/O for ``.svg`` files in galleries
* Accept ``.svgz`` extension by default
* Don't randomly load plugins when Nikola is called with no arguments (Issue #2297)
@@ -1746,10 +1746,7 @@ def scan_posts(self, really=False, ignore_quit=False, quiet=False):
self.posts_per_year[str(post.date.year)].append(post)
self.posts_per_month[
'{0}/{1:02d}'.format(post.date.year, post.date.month)].append(post)
for tag in post.alltags:
self.posts_per_tag[tag].append(post)
for lang in self.config['TRANSLATIONS'].keys():
_tags_for_post = []
for tag in post.tags_for_language(lang):
_tag_slugified = utils.slugify(tag, lang)
if _tag_slugified in slugged_tags[lang]:
@@ -1760,12 +1757,10 @@ def scan_posts(self, really=False, ignore_quit=False, quiet=False):
utils.LOGGER.error('Tag {0} is used in: {1}'.format(tag, post.source_path))
utils.LOGGER.error('Tag {0} is used in: {1}'.format(other_tag, ', '.join([p.source_path for p in self.posts_per_tag[other_tag]])))
quit = True
elif _tag_slugified in _tags_for_post:
utils.LOGGER.error("The tag {0} ({1}) appears more than once in post {2}.".format(tag, _tag_slugified, post.source_path))
quit = True
else:
slugged_tags[lang].add(_tag_slugified)
_tags_for_post.append(_tag_slugified)
if post not in self.posts_per_tag[tag]:
self.posts_per_tag[tag].append(post)
self.tags_per_language[lang].extend(post.tags_for_language(lang))
self._add_post_to_category(post, post.meta('category'))

@@ -31,161 +31,48 @@
Basic Example:
>>> import markdown
>>> text = '''
... Text of the gist:
... [:gist: 4747847]
... '''
>>> html = markdown.markdown(text, [GistExtension()])
>>> print(html)
<p>Text of the gist:
<div class="gist">
<script src="https://gist.github.com/4747847.js"></script>
<noscript>
<pre>import this</pre>
</noscript>
</div>
</p>
Text of the gist:
[:gist: 4747847]
Example with filename:
>>> import markdown
>>> text = '''
... Text of the gist:
... [:gist: 4747847 zen.py]
... '''
>>> html = markdown.markdown(text, [GistExtension()])
>>> print(html)
<p>Text of the gist:
<div class="gist">
<script src="https://gist.github.com/4747847.js?file=zen.py"></script>
<noscript>
<pre>import this</pre>
</noscript>
</div>
</p>
Text of the gist:
[:gist: 4747847 zen.py]
Basic Example with hexidecimal id:
>>> import markdown
>>> text = '''
... Text of the gist:
... [:gist: c4a43d6fdce612284ac0]
... '''
>>> html = markdown.markdown(text, [GistExtension()])
>>> print(html)
<p>Text of the gist:
<div class="gist">
<script src="https://gist.github.com/c4a43d6fdce612284ac0.js"></script>
<noscript>
<pre>Moo</pre>
</noscript>
</div>
</p>
Text of the gist:
[:gist: c4a43d6fdce612284ac0]
Example with hexidecimal id filename:
>>> import markdown
>>> text = '''
... Text of the gist:
... [:gist: c4a43d6fdce612284ac0 cow.txt]
... '''
>>> html = markdown.markdown(text, [GistExtension()])
>>> print(html)
<p>Text of the gist:
<div class="gist">
<script src="https://gist.github.com/c4a43d6fdce612284ac0.js?file=cow.txt"></script>
<noscript>
<pre>Moo</pre>
</noscript>
</div>
</p>
Text of the gist:
[:gist: c4a43d6fdce612284ac0 cow.txt]
Example using reStructuredText syntax:
>>> import markdown
>>> text = '''
... Text of the gist:
... .. gist:: 4747847 zen.py
... '''
>>> html = markdown.markdown(text, [GistExtension()])
>>> print(html)
<p>Text of the gist:
<div class="gist">
<script src="https://gist.github.com/4747847.js?file=zen.py"></script>
<noscript>
<pre>import this</pre>
</noscript>
</div>
</p>
Text of the gist:
.. gist:: 4747847 zen.py
Example using hexidecimal ID with reStructuredText syntax:
>>> import markdown
>>> text = '''
... Text of the gist:
... .. gist:: c4a43d6fdce612284ac0
... '''
>>> html = markdown.markdown(text, [GistExtension()])
>>> print(html)
<p>Text of the gist:
<div class="gist">
<script src="https://gist.github.com/c4a43d6fdce612284ac0.js"></script>
<noscript>
<pre>Moo</pre>
</noscript>
</div>
</p>
Text of the gist:
.. gist:: c4a43d6fdce612284ac0
Example using hexidecimal ID and filename with reStructuredText syntax:
>>> import markdown
>>> text = '''
... Text of the gist:
... .. gist:: c4a43d6fdce612284ac0 cow.txt
... '''
>>> html = markdown.markdown(text, [GistExtension()])
>>> print(html)
<p>Text of the gist:
<div class="gist">
<script src="https://gist.github.com/c4a43d6fdce612284ac0.js?file=cow.txt"></script>
<noscript>
<pre>Moo</pre>
</noscript>
</div>
</p>
Text of the gist:
.. gist:: c4a43d6fdce612284ac0 cow.txt
Error Case: non-existent Gist ID:
>>> import markdown
>>> text = '''
... Text of the gist:
... [:gist: 0]
... '''
>>> html = markdown.markdown(text, [GistExtension()])
>>> print(html)
<p>Text of the gist:
<div class="gist">
<script src="https://gist.github.com/0.js"></script>
<noscript><!-- WARNING: Received a 404 response from Gist URL: https://gist.githubusercontent.com/raw/0 --></noscript>
</div>
</p>
Error Case: non-existent file:
>>> import markdown
>>> text = '''
... Text of the gist:
... [:gist: 4747847 doesntexist.py]
... '''
>>> html = markdown.markdown(text, [GistExtension()])
>>> print(html)
<p>Text of the gist:
<div class="gist">
<script src="https://gist.github.com/4747847.js?file=doesntexist.py"></script>
<noscript><!-- WARNING: Received a 404 response from Gist URL: https://gist.githubusercontent.com/raw/4747847/doesntexist.py --></noscript>
</div>
</p>
Text of the gist:
[:gist: 0]
Error Case: non-existent file:
Text of the gist:
[:gist: 4747847 doesntexist.py]
"""

from __future__ import unicode_literals, print_function
@@ -3,6 +3,6 @@ mock==2.0.0
coverage==4.0.3
pytest==2.9.1
pytest-cov==2.2.1
freezegun==0.3.6
freezegun==0.3.7
python-coveralls==2.7.0
colorama>=0.3.4
@@ -3,3 +3,7 @@ universal = 1

[flake8]
ignore=E501

[pytest]
norecursedirs = .git
addopts = --cov nikola --cov-report term-missing
@@ -68,48 +68,5 @@ def test_compile_strikethrough(self):
actual_output = self.compile(input_str)
self.assertEquals(actual_output.strip(), expected_output.strip())

def test_compile_html_gist(self):
input_str = '''\
Here's a gist file inline:
[:gist: 4747847 zen.py]
Cool, eh?
'''
expected_output = '''\
<p>Here's a gist file inline:
<div class="gist">
<script src="https://gist.github.com/4747847.js?file=zen.py"></script>
<noscript>
<pre>import this</pre>
</noscript>
</div>
</p>
<p>Cool, eh?</p>
'''
actual_output = self.compile(input_str)
self.assertEquals(actual_output.strip(), expected_output.strip())

def test_compile_html_gist_2(self):
input_str = '''\
Here's a gist file inline, using reStructuredText syntax:
..gist:: 4747847 zen.py
Cool, eh?
'''
expected_output = '''\
<p>Here's a gist file inline, using reStructuredText syntax:
<div class="gist">
<script src="https://gist.github.com/4747847.js?file=zen.py"></script>
<noscript>
<pre>import this</pre>
</noscript>
</div>
</p>
<p>Cool, eh?</p>
'''
actual_output = self.compile(input_str)
self.assertEquals(actual_output.strip(), expected_output.strip())


if __name__ == '__main__':
unittest.main()
@@ -44,7 +44,6 @@
import unittest

import nikola.plugins.compile.rest
from nikola.plugins.compile.rest import gist
from nikola.plugins.compile.rest import vimeo
import nikola.plugins.compile.rest.listing
from nikola.plugins.compile.rest.doc import Plugin as DocPlugin
@@ -129,55 +128,6 @@ def test_math(self):
text="\(e^{ix} = \cos x + i\sin x\)")


class GistTestCase(ReSTExtensionTestCase):
""" Test GitHubGist.
We will replace get_raw_gist() and get_raw_gist_with_filename()
monkeypatching the GitHubGist class for avoiding network dependency
"""
gist_type = gist.GitHubGist
sample = '.. gist:: fake_id\n :file: spam.py'
sample_without_filename = '.. gist:: fake_id2'

def setUp(self):
""" Patch GitHubGist for avoiding network dependency """
super(GistTestCase, self).setUp()
self.gist_type.get_raw_gist_with_filename = lambda *_: 'raw_gist_file'
self.gist_type.get_raw_gist = lambda *_: "raw_gist"
_reload(nikola.plugins.compile.rest)

@pytest.mark.skipif(True, reason="This test indefinitely skipped.")
def test_gist(self):
""" Test the gist directive with filename """
self.setHtmlFromRst(self.sample)
output = 'https://gist.github.com/fake_id.js?file=spam.py'
self.assertHTMLContains("script", attributes={"src": output})
self.assertHTMLContains("pre", text="raw_gist_file")

@pytest.mark.skipif(True, reason="This test indefinitely skipped.")
def test_gist_without_filename(self):
""" Test the gist directive without filename """
self.setHtmlFromRst(self.sample_without_filename)
output = 'https://gist.github.com/fake_id2.js'
self.assertHTMLContains("script", attributes={"src": output})
self.assertHTMLContains("pre", text="raw_gist")


class GistIntegrationTestCase(ReSTExtensionTestCase):
""" Test requests integration. The gist plugin uses requests to fetch gist
contents and place it in a noscript tag.
"""
sample = '.. gist:: 1812835'

def test_gist_integration(self):
""" Fetch contents of the gist from GH and render in a noscript tag """
self.basic_test()
text = ('Be alone, that is the secret of invention: be alone, that is'
' when ideas are born. -- Nikola Tesla')
self.assertHTMLContains('pre', text=text)


class SlidesTestCase(ReSTExtensionTestCase):
""" Slides test case """

0 comments on commit 831fa61

Please sign in to comment.