From fa82e19c1ffa18bfb5e03a8311727a022525c53f Mon Sep 17 00:00:00 2001 From: Bruno Binet Date: Sat, 24 Nov 2012 00:26:46 +0100 Subject: [PATCH 1/5] change default value for DEFAULT_DATE to None (was 'fs' => guess from file mtime) --- docs/settings.rst | 2 +- pelican/generators.py | 2 +- pelican/settings.py | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/settings.rst b/docs/settings.rst index be091596..a7cf107b 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -43,7 +43,7 @@ Setting name (default value) What doe `DISPLAY_PAGES_ON_MENU` (``True``) Whether to display pages on the menu of the template. Templates may or not honor this setting. -`DEFAULT_DATE` (``fs``) The default date you want to use. +`DEFAULT_DATE` (``None``) The default date you want to use. If 'fs', Pelican will use the file system timestamp information (mtime) if it can't get date information from the metadata. diff --git a/pelican/generators.py b/pelican/generators.py index b1d9ec12..020a3711 100644 --- a/pelican/generators.py +++ b/pelican/generators.py @@ -331,7 +331,7 @@ class ArticlesGenerator(Generator): if category != '': metadata['category'] = Category(category, self.settings) - if 'date' not in metadata and self.settings['DEFAULT_DATE']: + if 'date' not in metadata and self.settings.get('DEFAULT_DATE'): if self.settings['DEFAULT_DATE'] == 'fs': metadata['date'] = datetime.datetime.fromtimestamp( os.stat(f).st_ctime) diff --git a/pelican/settings.py b/pelican/settings.py index 49879f84..d2c0cef5 100644 --- a/pelican/settings.py +++ b/pelican/settings.py @@ -36,7 +36,6 @@ _DEFAULT_CONFIG = {'PATH': '.', 'OUTPUT_SOURCES_EXTENSION': '.text', 'USE_FOLDER_AS_CATEGORY': True, 'DEFAULT_CATEGORY': 'misc', - 'DEFAULT_DATE': 'fs', 'WITH_FUTURE_DATES': True, 'CSS_FILE': 'main.css', 'NEWEST_FIRST_ARCHIVES': True, From 4d6ddd0af3775c992fed642153c0cb96c66fed23 Mon Sep 17 00:00:00 2001 From: Bruno Binet Date: Sat, 24 Nov 2012 00:41:25 +0100 Subject: [PATCH 2/5] fix failing tests --- tests/content/TestCategory/article_with_category.rst | 1 + tests/test_generators.py | 3 +++ tests/test_webassets.py | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/content/TestCategory/article_with_category.rst b/tests/content/TestCategory/article_with_category.rst index 7ed6e6d1..69ffa98b 100644 --- a/tests/content/TestCategory/article_with_category.rst +++ b/tests/content/TestCategory/article_with_category.rst @@ -2,5 +2,6 @@ This is an article with category ! ################################## :category: yeah +:date: 1970-01-01 This article should be in 'yeah' category. diff --git a/tests/test_generators.py b/tests/test_generators.py index ba7ff240..f8f6a3f4 100644 --- a/tests/test_generators.py +++ b/tests/test_generators.py @@ -31,6 +31,7 @@ class TestArticlesGenerator(unittest.TestCase): settings = _DEFAULT_CONFIG.copy() settings['ARTICLE_DIR'] = 'content' settings['DEFAULT_CATEGORY'] = 'Default' + settings['DEFAULT_DATE'] = (1970, 01, 01) self.generator = ArticlesGenerator(settings.copy(), settings, CUR_DIR, _DEFAULT_CONFIG['THEME'], None, _DEFAULT_CONFIG['MARKUP']) @@ -93,6 +94,7 @@ class TestArticlesGenerator(unittest.TestCase): settings = _DEFAULT_CONFIG.copy() settings['ARTICLE_DIR'] = 'content' settings['DEFAULT_CATEGORY'] = 'Default' + settings['DEFAULT_DATE'] = (1970, 01, 01) settings['USE_FOLDER_AS_CATEGORY'] = False generator = ArticlesGenerator(settings.copy(), settings, CUR_DIR, _DEFAULT_CONFIG['THEME'], None, @@ -175,6 +177,7 @@ class TestPageGenerator(unittest.TestCase): settings = _DEFAULT_CONFIG.copy() settings['PAGE_DIR'] = 'TestPages' + settings['DEFAULT_DATE'] = (1970, 01, 01) generator = PagesGenerator(settings.copy(), settings, CUR_DIR, _DEFAULT_CONFIG['THEME'], None, _DEFAULT_CONFIG['MARKUP']) diff --git a/tests/test_webassets.py b/tests/test_webassets.py index 52a7fa17..afe1674d 100644 --- a/tests/test_webassets.py +++ b/tests/test_webassets.py @@ -80,7 +80,7 @@ class TestWebAssetsRelativeURLS(TestWebAssets): self.check_link_tag( '.././theme/gen/style.{0}.min.css'.format(CSS_HASH), - os.path.join(self.temp_path, 'category/misc.html')) + os.path.join(self.temp_path, 'category/yeah.html')) class TestWebAssetsAbsoluteURLS(TestWebAssets): From 080c884c1ad52587ccff7d742422625c06e3a8a1 Mon Sep 17 00:00:00 2001 From: Bruno Binet Date: Sat, 24 Nov 2012 00:46:03 +0100 Subject: [PATCH 3/5] restore test_basic_generation_works functional test --- tests/test_pelican.py | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/tests/test_pelican.py b/tests/test_pelican.py index 762663d2..39c820c8 100644 --- a/tests/test_pelican.py +++ b/tests/test_pelican.py @@ -62,22 +62,17 @@ class TestPelican(unittest.TestCase): self.assertEqual(diff['right_only'], [], msg=msg) self.assertEqual(diff['diff_files'], [], msg=msg) - @unittest.skip("Test failing") def test_basic_generation_works(self): # when running pelican without settings, it should pick up the default - # ones and generate the output without raising any exception / issuing - # any warning. - with patch("pelican.contents.getenv") as mock_getenv: - # force getenv('USER') to always return the same value - mock_getenv.return_value = "Dummy Author" - settings = read_settings(filename=None, override={ - 'PATH': INPUT_PATH, - 'OUTPUT_PATH': self.temp_path, - }) - pelican = Pelican(settings=settings) - pelican.run() - dcmp = dircmp(self.temp_path, os.sep.join((OUTPUT_PATH, "basic"))) - self.assertFilesEqual(recursiveDiff(dcmp)) + # ones and generate correct output without raising any exception + settings = read_settings(filename=None, override={ + 'PATH': INPUT_PATH, + 'OUTPUT_PATH': self.temp_path, + }) + pelican = Pelican(settings=settings) + pelican.run() + dcmp = dircmp(self.temp_path, os.sep.join((OUTPUT_PATH, "basic"))) + self.assertFilesEqual(recursiveDiff(dcmp)) def test_custom_generation_works(self): # the same thing with a specified set of settings should work From 07ccf477d06a2a2c1b0290ef33628b86a99324d6 Mon Sep 17 00:00:00 2001 From: Bruno Binet Date: Sat, 24 Nov 2012 00:29:48 +0100 Subject: [PATCH 4/5] update "basic" output for functional tests so that test pass LC_ALL="C" pelican -o tests/output/basic/ samples/content/ --- .../output/basic/author/alexis-metaireau.html | 4 +- tests/output/basic/author/dummy-author.html | 288 ------------------ tests/output/basic/category/bar.html | 4 +- tests/output/basic/category/content.html | 147 --------- .../output/basic/drafts/a-draft-article.html | 67 ---- tests/output/basic/feeds/all-fr.atom.xml | 3 +- tests/output/basic/feeds/all.atom.xml | 3 +- tests/output/basic/feeds/content.atom.xml | 4 - tests/output/basic/index.html | 4 +- tests/output/basic/oh-yeah-fr.html | 68 ----- tests/output/basic/oh-yeah.html | 4 +- tests/output/basic/tag/bar.html | 4 +- tests/output/basic/tag/oh.html | 4 +- tests/output/basic/tag/yeah.html | 4 +- 14 files changed, 9 insertions(+), 599 deletions(-) delete mode 100644 tests/output/basic/author/dummy-author.html delete mode 100644 tests/output/basic/category/content.html delete mode 100644 tests/output/basic/drafts/a-draft-article.html delete mode 100644 tests/output/basic/feeds/content.atom.xml delete mode 100644 tests/output/basic/oh-yeah-fr.html diff --git a/tests/output/basic/author/alexis-metaireau.html b/tests/output/basic/author/alexis-metaireau.html index 014127c5..07caba91 100644 --- a/tests/output/basic/author/alexis-metaireau.html +++ b/tests/output/basic/author/alexis-metaireau.html @@ -44,9 +44,7 @@ By Alexis Métaireau

In bar.

-

tags: ohbaryeah

Translations: - fr - +

tags: ohbaryeah

Why not ?

After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst ! diff --git a/tests/output/basic/author/dummy-author.html b/tests/output/basic/author/dummy-author.html deleted file mode 100644 index bd47adde..00000000 --- a/tests/output/basic/author/dummy-author.html +++ /dev/null @@ -1,288 +0,0 @@ - - - - A Pelican Blog - Dummy Author - - - - - - - - - - - - - - - - - -

- - - - - - - - -
-

Other articles

-
-
    - - - - - - - - - -
  1. - - - - - - - -
  2. - - - - - - - -
  3. - - - - - - - -
  4. - - - - - - - -
  5. - - -
- - - -
- - - - -
- - -
- - - - - - - - \ No newline at end of file diff --git a/tests/output/basic/category/bar.html b/tests/output/basic/category/bar.html index b47d7522..4fe9447c 100644 --- a/tests/output/basic/category/bar.html +++ b/tests/output/basic/category/bar.html @@ -44,9 +44,7 @@ By Alexis Métaireau

In bar.

-

tags: ohbaryeah

Translations: - fr - +

tags: ohbaryeah

Why not ?

After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst ! diff --git a/tests/output/basic/category/content.html b/tests/output/basic/category/content.html deleted file mode 100644 index 19ceef2c..00000000 --- a/tests/output/basic/category/content.html +++ /dev/null @@ -1,147 +0,0 @@ - - - - A Pelican Blog - content - - - - - - - - - - - - - - - -

- - - - - - - - -
-

Other articles

-
-
    - - - - - - - - - - -
  1. - - - - - -
-
- - - - -
- - -
- - - - - - - - \ No newline at end of file diff --git a/tests/output/basic/drafts/a-draft-article.html b/tests/output/basic/drafts/a-draft-article.html deleted file mode 100644 index 71e778ce..00000000 --- a/tests/output/basic/drafts/a-draft-article.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - A draft article - - - - - - - - - - - - - - -
-
-
-

- A draft article

-
- -
-
- - Mon 17 September 2012 - - -

In misc.

- -

This is a draft article, it should live under the /drafts/ folder and not be -listed anywhere else.

- -
- -
-
-
-
- - - - - \ No newline at end of file diff --git a/tests/output/basic/feeds/all-fr.atom.xml b/tests/output/basic/feeds/all-fr.atom.xml index 2cfb5ea6..98b9a681 100644 --- a/tests/output/basic/feeds/all-fr.atom.xml +++ b/tests/output/basic/feeds/all-fr.atom.xml @@ -1,4 +1,3 @@ -A Pelican Blog/2012-09-17T15:02:39ZTrop bien !2012-09-17T15:02:39Ztag:,2012-09-17:oh-yeah-fr.html<p>Et voila du contenu en français</p> -Deuxième article2012-02-29T00:00:00Ztag:,2012-02-29:second-article-fr.html<p>Ceci est un article, en français.</p> +A Pelican Blog/2012-02-29T00:00:00ZDeuxième article2012-02-29T00:00:00Ztag:,2012-02-29:second-article-fr.html<p>Ceci est un article, en français.</p> \ No newline at end of file diff --git a/tests/output/basic/feeds/all.atom.xml b/tests/output/basic/feeds/all.atom.xml index a439882f..c715db8c 100644 --- a/tests/output/basic/feeds/all.atom.xml +++ b/tests/output/basic/feeds/all.atom.xml @@ -1,6 +1,5 @@ -A Pelican Blog/2012-09-17T15:02:39ZTrop bien !2012-09-17T15:02:39Ztag:,2012-09-17:oh-yeah-fr.html<p>Et voila du contenu en français</p> -Second article2012-02-29T00:00:00Ztag:,2012-02-29:second-article.html<p>This is some article, in english</p> +A Pelican Blog/2012-02-29T00:00:00ZSecond article2012-02-29T00:00:00Ztag:,2012-02-29:second-article.html<p>This is some article, in english</p> Deuxième article2012-02-29T00:00:00Ztag:,2012-02-29:second-article-fr.html<p>Ceci est un article, en français.</p> A markdown powered article2011-04-20T00:00:00Ztag:,2011-04-20:a-markdown-powered-article.html<p>You're mutually oblivious.</p>Article 12011-02-17T00:00:00Ztag:,2011-02-17:article-1.html<p>Article 1</p> Article 22011-02-17T00:00:00Ztag:,2011-02-17:article-2.html<p>Article 2</p> diff --git a/tests/output/basic/feeds/content.atom.xml b/tests/output/basic/feeds/content.atom.xml deleted file mode 100644 index 1fa740b4..00000000 --- a/tests/output/basic/feeds/content.atom.xml +++ /dev/null @@ -1,4 +0,0 @@ - -A Pelican Blog.././2012-02-29T00:00:00ZSecond article2012-02-29T00:00:00ZDummy Authortag:../.,2012-02-29:second-article.html<p>This is some article, in english</p> -Unbelievable !2010-10-15T20:30:00ZDummy Authortag:../.,2010-10-15:unbelievable.html<p>Or completely awesome. Depends the needs.</p> - \ No newline at end of file diff --git a/tests/output/basic/index.html b/tests/output/basic/index.html index 8a063033..04a4fd12 100644 --- a/tests/output/basic/index.html +++ b/tests/output/basic/index.html @@ -183,9 +183,7 @@ as well as inline markup.

By Alexis Métaireau

In bar.

-

tags: ohbaryeah

Translations: - fr - +

tags: ohbaryeah

Why not ?

After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst ! diff --git a/tests/output/basic/oh-yeah-fr.html b/tests/output/basic/oh-yeah-fr.html deleted file mode 100644 index 5143907f..00000000 --- a/tests/output/basic/oh-yeah-fr.html +++ /dev/null @@ -1,68 +0,0 @@ - - - - Trop bien ! - - - - - - - - - - - - - -

-
-
-
-

- Trop bien !

-
- -
-
- - Mon 17 September 2012 - - -

In misc.

-Translations: - en - -

Et voila du contenu en français

- -
- -
-
-
-
- - - - - \ No newline at end of file diff --git a/tests/output/basic/oh-yeah.html b/tests/output/basic/oh-yeah.html index 0e06699d..1c7bb43e 100644 --- a/tests/output/basic/oh-yeah.html +++ b/tests/output/basic/oh-yeah.html @@ -47,9 +47,7 @@ By Alexis Métaireau

In bar.

-

tags: ohbaryeah

Translations: - fr - +

tags: ohbaryeah

Why not ?

After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst ! diff --git a/tests/output/basic/tag/bar.html b/tests/output/basic/tag/bar.html index 4bc5adc0..f2d0bf72 100644 --- a/tests/output/basic/tag/bar.html +++ b/tests/output/basic/tag/bar.html @@ -120,9 +120,7 @@ as well as inline markup.

By Alexis Métaireau

In bar.

-

tags: ohbaryeah

Translations: - fr - +

tags: ohbaryeah

Why not ?

After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst ! diff --git a/tests/output/basic/tag/oh.html b/tests/output/basic/tag/oh.html index a286ca8d..36731c8c 100644 --- a/tests/output/basic/tag/oh.html +++ b/tests/output/basic/tag/oh.html @@ -44,9 +44,7 @@ By Alexis Métaireau

In bar.

-

tags: ohbaryeah

Translations: - fr - +

tags: ohbaryeah

Why not ?

After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst ! diff --git a/tests/output/basic/tag/yeah.html b/tests/output/basic/tag/yeah.html index 1e91b765..fb6909b4 100644 --- a/tests/output/basic/tag/yeah.html +++ b/tests/output/basic/tag/yeah.html @@ -44,9 +44,7 @@ By Alexis Métaireau

In bar.

-

tags: ohbaryeah

Translations: - fr - +

tags: ohbaryeah

Why not ?

After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst ! From ce0723cf48a5bc0c77e6e93e4e5a9bc5dc945315 Mon Sep 17 00:00:00 2001 From: Bruno Binet Date: Sat, 24 Nov 2012 00:48:47 +0100 Subject: [PATCH 5/5] update contribute.rst doc $USER environment variable is no longer needed --- docs/contribute.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/contribute.rst b/docs/contribute.rst index 0820d5c3..c302dcc6 100644 --- a/docs/contribute.rst +++ b/docs/contribute.rst @@ -56,7 +56,7 @@ To do so, you can use the following two commands:: $ LC_ALL="C" pelican -o tests/output/custom/ -s samples/pelican.conf.py \ samples/content/ - $ LC_ALL="C" USER="Dummy Author" pelican -o tests/output/basic/ samples/content/ + $ LC_ALL="C" pelican -o tests/output/basic/ samples/content/ Coding standards ================