A Python content management system designed for kirsle.net featuring a blog, comments and photo albums. https://rophako.kirsle.net/
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

30 lignes
1.1 KiB

  1. #!/usr/bin/env python
  2. """Dynamic CMS plugin loader."""
  3. import os
  4. from importlib import import_module
  5. from rophako.app import app, BLUEPRINT_PATHS
  6. def load_plugin(name, as_blueprint=True, template_path=None):
  7. """Load a Rophako CMS plugin.
  8. * `name` is a Python module name, i.e. `rophako.modules.blog`
  9. * `as_blueprint` is True if the module exports a blueprint object called
  10. `mod` that can be attached to the Flask app. Set this value to False if
  11. you simply need to include a Python module that isn't a blueprint.
  12. * `template_path` is a filesystem path where the blueprint's templates
  13. can be found. If not provided, the path is automatically determined
  14. based on the module name, which is suitable for the built-in plugins."""
  15. module = import_module(name)
  16. if as_blueprint:
  17. mod = getattr(module, "mod")
  18. app.register_blueprint(mod)
  19. # Get the template path to add to the BLUEPRINT_PATHS.
  20. if template_path is None:
  21. module_path = name.replace(".", "/")
  22. template_path = os.path.join(module_path, "templates")
  23. BLUEPRINT_PATHS.append(template_path)