diff --git a/docs/themes.rst b/docs/themes.rst index 86a754bc..0c053fce 100644 --- a/docs/themes.rst +++ b/docs/themes.rst @@ -327,6 +327,8 @@ period A tuple of the form (`year`, `month`, `day`) that given year. It contains both `year` and `month` if the time period is over years and months and so on. +period_num A tuple of the form (``year``, ``month``, ``day``), + as in ``period``, except all values are numbers. =================== =================================================== diff --git a/pelican/generators.py b/pelican/generators.py index 63e20a0a..07370264 100644 --- a/pelican/generators.py +++ b/pelican/generators.py @@ -511,6 +511,7 @@ class ArticlesGenerator(CachingGenerator): if key == period_date_key['year']: context["period"] = (_period,) + context["period_num"] = (_period,) else: month_name = calendar.month_name[_period[1]] if key == period_date_key['month']: @@ -520,6 +521,7 @@ class ArticlesGenerator(CachingGenerator): context["period"] = (_period[0], month_name, _period[2]) + context["period_num"] = tuple(_period) write(save_as, template, context, articles=articles, dates=archive, template_name='period_archives', diff --git a/pelican/tests/test_generators.py b/pelican/tests/test_generators.py index 169765ac..be43aa0e 100644 --- a/pelican/tests/test_generators.py +++ b/pelican/tests/test_generators.py @@ -413,6 +413,7 @@ class TestArticlesGenerator(unittest.TestCase): self.assertEqual(len(dates), 1) # among other things it must have at least been called with this context["period"] = (1970,) + context["period_num"] = (1970,) write.assert_called_with("posts/1970/index.html", generator.get_template("period_archives"), context, blog=True, articles=articles, @@ -437,6 +438,7 @@ class TestArticlesGenerator(unittest.TestCase): if d.date.year == 1970 and d.date.month == 1] self.assertEqual(len(dates), 1) context["period"] = (1970, "January") + context["period_num"] = (1970, 1) # among other things it must have at least been called with this write.assert_called_with("posts/1970/Jan/index.html", generator.get_template("period_archives"), @@ -470,6 +472,7 @@ class TestArticlesGenerator(unittest.TestCase): ] self.assertEqual(len(dates), 1) context["period"] = (1970, "January", 1) + context["period_num"] = (1970, 1, 1) # among other things it must have at least been called with this write.assert_called_with("posts/1970/Jan/01/index.html", generator.get_template("period_archives"),