mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Filtration is now being applied before caching the metadata, solving the issue where _DISCARD objects from previous runs were being retrieved from cache.
This commit is contained in:
parent
0da8659d0e
commit
8849721913
4 changed files with 27 additions and 1 deletions
|
|
@ -571,8 +571,9 @@ class Readers(FileStampDataCacher):
|
|||
content, reader_metadata = self.get_cached_data(path, (None, None))
|
||||
if content is None:
|
||||
content, reader_metadata = reader.read(path)
|
||||
reader_metadata = _filter_discardable_metadata(reader_metadata)
|
||||
self.cache_data(path, (content, reader_metadata))
|
||||
metadata.update(_filter_discardable_metadata(reader_metadata))
|
||||
metadata.update(reader_metadata)
|
||||
|
||||
if content:
|
||||
# find images with empty alt
|
||||
|
|
|
|||
4
pelican/tests/content/article_with_markdown_and_empty_tags.md
vendored
Normal file
4
pelican/tests/content/article_with_markdown_and_empty_tags.md
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
Title: Article with markdown and empty tags
|
||||
Tags:
|
||||
|
||||
This is some content.
|
||||
|
|
@ -265,6 +265,8 @@ class TestArticlesGenerator(unittest.TestCase):
|
|||
['This is a super article !', 'published', 'yeah', 'article'],
|
||||
['This is a super article !', 'published', 'Default', 'article'],
|
||||
['Article with an inline SVG', 'published', 'Default', 'article'],
|
||||
['Article with markdown and empty tags', 'published', 'Default',
|
||||
'article'],
|
||||
['This is an article with category !', 'published', 'yeah',
|
||||
'article'],
|
||||
['This is an article with multiple authors!', 'published',
|
||||
|
|
@ -569,6 +571,7 @@ class TestArticlesGenerator(unittest.TestCase):
|
|||
'Article title',
|
||||
'Article with Nonconformant HTML meta tags',
|
||||
'Article with an inline SVG',
|
||||
'Article with markdown and empty tags',
|
||||
'Article with markdown and nested summary metadata',
|
||||
'Article with markdown and summary metadata multi',
|
||||
'Article with markdown and summary metadata single',
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ class ReaderTest(unittest.TestCase):
|
|||
|
||||
def read_file(self, path, **kwargs):
|
||||
# Isolate from future API changes to readers.read_file
|
||||
|
||||
r = readers.Readers(settings=get_settings(**kwargs))
|
||||
return r.read_file(base_path=CONTENT_PATH, path=path)
|
||||
|
||||
|
|
@ -795,6 +796,23 @@ class MdReaderTest(ReaderTest):
|
|||
self.assertEqual(page.content, expected)
|
||||
self.assertEqual(page.title, expected_title)
|
||||
|
||||
def test_metadata_has_no_discarded_data(self):
|
||||
md_filename = 'article_with_markdown_and_empty_tags.md'
|
||||
|
||||
r = readers.Readers(cache_name='cache', settings=get_settings(
|
||||
CACHE_CONTENT=True))
|
||||
page = r.read_file(base_path=CONTENT_PATH, path=md_filename)
|
||||
|
||||
__, cached_metadata = r.get_cached_data(
|
||||
_path(md_filename), (None, None))
|
||||
|
||||
expected = {
|
||||
'title': 'Article with markdown and empty tags'
|
||||
}
|
||||
self.assertEqual(cached_metadata, expected)
|
||||
self.assertNotIn('tags', page.metadata)
|
||||
self.assertDictHasSubset(page.metadata, expected)
|
||||
|
||||
|
||||
class HTMLReaderTest(ReaderTest):
|
||||
def test_article_with_comments(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue