always_modified.py 579 B

123456789101112131415161718192021
  1. """
  2. If "modified" date/time is not defined in article metadata, fall back to the "created" date.
  3. """
  4. from pelican import signals
  5. from pelican.contents import Content, Article
  6. def add_modified(content):
  7. if not isinstance(content, Article):
  8. return
  9. if not content.settings.get('ALWAYS_MODIFIED', False):
  10. return
  11. if hasattr(content, 'date') and not hasattr(content, 'modified'):
  12. content.modified = content.date
  13. content.locale_modified = content.locale_date
  14. def register():
  15. signals.content_object_init.connect(add_modified)