registration.py 927 B

12345678910111213141516171819202122232425262728293031
  1. # -*- coding: utf-8 -*-
  2. """
  3. Handle registration and setup for plugin
  4. """
  5. import logging
  6. from blinker import signal
  7. from .content_adapter import GitContentAdapter
  8. from pelican import signals
  9. DEV_LOGGER = logging.getLogger(__name__)
  10. content_git_object_init = signal('content_git_object_init')
  11. def send_content_git_object_init(content):
  12. content_git_object_init.send(content, git_content=GitContentAdapter(content))
  13. def setup_option_defaults(pelican_inst):
  14. pelican_inst.settings.setdefault('GIT_FILETIME_FROM_GIT', True)
  15. pelican_inst.settings.setdefault('GIT_HISTORY_FOLLOWS_RENAME', True)
  16. pelican_inst.settings.setdefault('GIT_SHA_METADATA', True)
  17. pelican_inst.settings.setdefault('GIT_GENERATE_PERMALINK', False)
  18. def register():
  19. signals.content_object_init.connect(send_content_git_object_init)
  20. signals.initialized.connect(setup_option_defaults)
  21. # Import actions
  22. from . import actions