mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Merge pull request #1795 from ingwinlu/add_warning_to_replacer
Add warning for unknown replacement indicators
This commit is contained in:
commit
a55217ef36
2 changed files with 26 additions and 3 deletions
|
|
@ -248,6 +248,11 @@ class Content(object):
|
||||||
origin = '/'.join((siteurl, Category(path, self.settings).url))
|
origin = '/'.join((siteurl, Category(path, self.settings).url))
|
||||||
elif what == 'tag':
|
elif what == 'tag':
|
||||||
origin = '/'.join((siteurl, Tag(path, self.settings).url))
|
origin = '/'.join((siteurl, Tag(path, self.settings).url))
|
||||||
|
else:
|
||||||
|
logger.warning(
|
||||||
|
"Replacement Indicator '%s' not recognized, "
|
||||||
|
"skipping replacement",
|
||||||
|
what)
|
||||||
|
|
||||||
# keep all other parts, such as query, fragment, etc.
|
# keep all other parts, such as query, fragment, etc.
|
||||||
parts = list(value)
|
parts = list(value)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
from __future__ import unicode_literals, absolute_import
|
from __future__ import unicode_literals, absolute_import
|
||||||
|
|
||||||
|
import logging
|
||||||
import locale
|
import locale
|
||||||
import os.path
|
import os.path
|
||||||
import six
|
import six
|
||||||
|
|
@ -11,7 +12,7 @@ from pelican.contents import (Page, Article, Static, URLWrapper,
|
||||||
Author, Category)
|
Author, Category)
|
||||||
from pelican.settings import DEFAULT_CONFIG
|
from pelican.settings import DEFAULT_CONFIG
|
||||||
from pelican.signals import content_object_init
|
from pelican.signals import content_object_init
|
||||||
from pelican.tests.support import unittest, get_settings
|
from pelican.tests.support import LoggedTestCase, mute, unittest, get_settings
|
||||||
from pelican.utils import (path_to_url, truncate_html_words, SafeDatetime,
|
from pelican.utils import (path_to_url, truncate_html_words, SafeDatetime,
|
||||||
posix_join)
|
posix_join)
|
||||||
|
|
||||||
|
|
@ -413,10 +414,10 @@ class TestArticle(TestPage):
|
||||||
self.assertEqual(article.save_as, 'obrien/csharp-stuff/fnord/index.html')
|
self.assertEqual(article.save_as, 'obrien/csharp-stuff/fnord/index.html')
|
||||||
|
|
||||||
|
|
||||||
class TestStatic(unittest.TestCase):
|
class TestStatic(LoggedTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
super(TestStatic, self).setUp()
|
||||||
self.settings = get_settings(
|
self.settings = get_settings(
|
||||||
STATIC_SAVE_AS='{path}',
|
STATIC_SAVE_AS='{path}',
|
||||||
STATIC_URL='{path}',
|
STATIC_URL='{path}',
|
||||||
|
|
@ -578,3 +579,20 @@ class TestStatic(unittest.TestCase):
|
||||||
content = page.get_content('')
|
content = page.get_content('')
|
||||||
|
|
||||||
self.assertNotEqual(content, html)
|
self.assertNotEqual(content, html)
|
||||||
|
|
||||||
|
def test_unknown_link_syntax(self):
|
||||||
|
"{unknown} link syntax should trigger warning."
|
||||||
|
|
||||||
|
html = '<a href="{unknown}foo">link</a>'
|
||||||
|
page = Page(content=html,
|
||||||
|
metadata={'title': 'fakepage'}, settings=self.settings,
|
||||||
|
source_path=os.path.join('dir', 'otherdir', 'fakepage.md'),
|
||||||
|
context=self.context)
|
||||||
|
content = page.get_content('')
|
||||||
|
|
||||||
|
self.assertEqual(content, html)
|
||||||
|
self.assertLogCountEqual(
|
||||||
|
count=1,
|
||||||
|
msg="Replacement Indicator 'unknown' not recognized, "
|
||||||
|
"skipping replacement",
|
||||||
|
level=logging.WARNING)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue