__init__.py 441 B

123456789101112131415161718192021
  1. from pelican import signals
  2. import logging
  3. import os
  4. import time
  5. logger = logging.getLogger(__name__)
  6. def touch_file(path, context):
  7. content = context.get('article', context.get('page'))
  8. if content and hasattr(content, 'date'):
  9. mtime = time.mktime(content.date.timetuple())
  10. logger.info('touching %s', path)
  11. os.utime(path, (mtime, mtime))
  12. def register():
  13. signals.content_written.connect(touch_file)