diff --git a/models/blog.ini b/models/blog.ini index c44b28b..e6ee115 100644 --- a/models/blog.ini +++ b/models/blog.ini @@ -12,3 +12,4 @@ slug_format = {{ (this.pub_date|dateformat('YYYY/MM/dd/') if this.pub_date) ~ "- [pagination] enabled = yes per_page = 4 +items = this.children.filter(F.pub_date <= datetime.date.today()) diff --git a/packages/template-datetime/.gitignore b/packages/template-datetime/.gitignore new file mode 100644 index 0000000..463960b --- /dev/null +++ b/packages/template-datetime/.gitignore @@ -0,0 +1,5 @@ +dist +build +*.pyc +*.pyo +*.egg-info diff --git a/packages/template-datetime/lektor_template_datetime.py b/packages/template-datetime/lektor_template_datetime.py new file mode 100644 index 0000000..9cbdda2 --- /dev/null +++ b/packages/template-datetime/lektor_template_datetime.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- +import datetime + + +from lektor.pluginsystem import Plugin + + +class TemplateDatetimePlugin(Plugin): + name = u'template-datetime' + description = u'Adds the datetime package to the template context' + + def on_process_template_context(self, context, **extra): + context['datetime'] = datetime diff --git a/packages/template-datetime/setup.py b/packages/template-datetime/setup.py new file mode 100644 index 0000000..23bac09 --- /dev/null +++ b/packages/template-datetime/setup.py @@ -0,0 +1,15 @@ +from setuptools import setup + +setup( + name='lektor-template-datetime', + version='0.1', + author=u'Felipe Martin', + author_email='me@fmartingr.com', + license='MIT', + py_modules=['lektor_template_datetime'], + entry_points={ + 'lektor.plugins': [ + 'template-datetime = lektor_template_datetime:TemplateDatetimePlugin', + ] + } +)